@gem-sdk/core 1.23.0-staging.35 → 1.23.0-staging.357

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 (70) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +54 -32
  2. package/dist/cjs/components/ComponentWrapper.js +2 -1
  3. package/dist/cjs/components/ComponentWrapperPreview.js +18 -2
  4. package/dist/cjs/components/Render.liquid.js +65 -6
  5. package/dist/cjs/components/constant.js +7 -2
  6. package/dist/cjs/components/resize/Spacing.js +64 -7
  7. package/dist/cjs/components/theme-section/CreateThemeSection.js +3 -4
  8. package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +3 -2
  9. package/dist/cjs/contexts/BuilderPreviewContext.js +35 -8
  10. package/dist/cjs/contexts/PageContext.js +44 -0
  11. package/dist/cjs/contexts/ProductContext.js +5 -0
  12. package/dist/cjs/helpers/animations.js +213 -0
  13. package/dist/cjs/helpers/background.js +81 -19
  14. package/dist/cjs/helpers/carousel.js +58 -0
  15. package/dist/cjs/helpers/colors.js +1 -0
  16. package/dist/cjs/helpers/compose-advance-style.js +65 -7
  17. package/dist/cjs/helpers/covert-entities-html.js +19 -0
  18. package/dist/cjs/helpers/icon-list.js +61 -0
  19. package/dist/cjs/helpers/make-style.js +21 -5
  20. package/dist/cjs/helpers/product.js +4 -1
  21. package/dist/cjs/helpers/queries/get-collection.js +8 -2
  22. package/dist/cjs/helpers/size.js +123 -17
  23. package/dist/cjs/helpers/typography.js +1 -1
  24. package/dist/cjs/helpers/variant.js +5 -2
  25. package/dist/cjs/hooks/animation/useAnimationActions.js +39 -0
  26. package/dist/cjs/hooks/animation/useAnimationConfig.js +29 -0
  27. package/dist/cjs/hooks/animation/useAnimationPreview.js +31 -0
  28. package/dist/cjs/hooks/animation/useAnimationTarget.js +120 -0
  29. package/dist/cjs/hooks/animation/useApplyAnimation.js +87 -0
  30. package/dist/cjs/hooks/useAnimations.js +26 -0
  31. package/dist/cjs/hooks/useProduct.js +23 -6
  32. package/dist/cjs/index.js +55 -0
  33. package/dist/cjs/types/animations.js +47 -0
  34. package/dist/cjs/web-components/src/helpers/styles/constant.js +9 -0
  35. package/dist/esm/components/ComponentToolbarPreview.js +54 -32
  36. package/dist/esm/components/ComponentWrapper.js +2 -1
  37. package/dist/esm/components/ComponentWrapperPreview.js +19 -3
  38. package/dist/esm/components/Render.liquid.js +65 -6
  39. package/dist/esm/components/constant.js +7 -3
  40. package/dist/esm/components/resize/Spacing.js +65 -8
  41. package/dist/esm/components/theme-section/CreateThemeSection.js +3 -4
  42. package/dist/esm/components/theme-section/ThemeSectionTooltip.js +3 -2
  43. package/dist/esm/contexts/BuilderPreviewContext.js +35 -8
  44. package/dist/esm/contexts/PageContext.js +41 -0
  45. package/dist/esm/contexts/ProductContext.js +5 -0
  46. package/dist/esm/helpers/animations.js +211 -0
  47. package/dist/esm/helpers/background.js +78 -20
  48. package/dist/esm/helpers/carousel.js +54 -0
  49. package/dist/esm/helpers/colors.js +1 -0
  50. package/dist/esm/helpers/compose-advance-style.js +62 -8
  51. package/dist/esm/helpers/covert-entities-html.js +17 -0
  52. package/dist/esm/helpers/icon-list.js +58 -0
  53. package/dist/esm/helpers/make-style.js +20 -6
  54. package/dist/esm/helpers/product.js +4 -1
  55. package/dist/esm/helpers/queries/get-collection.js +8 -2
  56. package/dist/esm/helpers/size.js +119 -18
  57. package/dist/esm/helpers/typography.js +1 -1
  58. package/dist/esm/helpers/variant.js +5 -2
  59. package/dist/esm/hooks/animation/useAnimationActions.js +37 -0
  60. package/dist/esm/hooks/animation/useAnimationConfig.js +27 -0
  61. package/dist/esm/hooks/animation/useAnimationPreview.js +29 -0
  62. package/dist/esm/hooks/animation/useAnimationTarget.js +118 -0
  63. package/dist/esm/hooks/animation/useApplyAnimation.js +83 -0
  64. package/dist/esm/hooks/useAnimations.js +24 -0
  65. package/dist/esm/hooks/useProduct.js +23 -6
  66. package/dist/esm/index.js +10 -4
  67. package/dist/esm/types/animations.js +47 -0
  68. package/dist/esm/web-components/src/helpers/styles/constant.js +7 -0
  69. package/dist/types/index.d.ts +6472 -67
  70. package/package.json +2 -2
@@ -25,24 +25,6 @@ const isSection = (el)=>{
25
25
  const tag = el.getAttribute('data-component-tag');
26
26
  return tag === 'Section';
27
27
  };
28
- const isOverToolbarPosition = (el, parent)=>{
29
- const rect = el.getBoundingClientRect();
30
- const rectP = parent.getBoundingClientRect();
31
- // 32px = toolbar active height
32
- return rect.top - rectP.top < 32 + 1;
33
- };
34
- const findOverflowParent = (element, initEl)=>{
35
- const thisEl = element;
36
- const origEl = initEl || thisEl;
37
- if (!thisEl) return;
38
- if (isSection(thisEl)) return;
39
- if (notVisible(thisEl) && isOverToolbarPosition(initEl, thisEl)) return thisEl;
40
- if (thisEl.parentElement) {
41
- return findOverflowParent(thisEl.parentElement, origEl);
42
- } else {
43
- return;
44
- }
45
- };
46
28
  const ComponentToolbarPreview = ({ ...props })=>{
47
29
  const isThemeSection = props.isThemeSection;
48
30
  const editingPageType = ShopContext.useShopStore((s)=>s.pageType);
@@ -53,13 +35,32 @@ const ComponentToolbarPreview = ({ ...props })=>{
53
35
  const [isShowParent, setIsShowParent] = react.useState(false);
54
36
  const [isShowParentRevert, setIsShowParentRevert] = react.useState(false);
55
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
+ };
56
57
  // Get parents
57
58
  const onActiveComponent = react.useCallback((e)=>{
58
59
  const detail = e.detail;
59
60
  if (detail?.componentUid == props.uid) {
60
61
  const currentParents = getParents(props.uid).filter((parent)=>{
61
62
  if (parent.uid === 'ROOT') return false;
62
- if (parent.tag === 'Section') return false;
63
+ if (parent.tag === 'Section' && isThemeSectionEditor) return false;
63
64
  if (parent.editorConfigs?.toolbar?.hide) return false;
64
65
  if (parent.editorConfigs?.component?.noSetting) return false;
65
66
  return true;
@@ -72,7 +73,8 @@ const ComponentToolbarPreview = ({ ...props })=>{
72
73
  }, [
73
74
  setParents,
74
75
  getParents,
75
- props.uid
76
+ props.uid,
77
+ isThemeSectionEditor
76
78
  ]);
77
79
  react.useEffect(()=>{
78
80
  window.addEventListener('editor:active-component', onActiveComponent);
@@ -115,7 +117,7 @@ const ComponentToolbarPreview = ({ ...props })=>{
115
117
  setIsShowParentRevert(true);
116
118
  } else {
117
119
  const rect = $toolbar.getBoundingClientRect();
118
- if (rect.top < parents.length * 24) {
120
+ if (rect.top < parents.length * 36) {
119
121
  setIsShowParentRevert(true);
120
122
  } else {
121
123
  setIsShowParentRevert(false);
@@ -160,6 +162,9 @@ const ComponentToolbarPreview = ({ ...props })=>{
160
162
  window.dispatchEvent(event);
161
163
  return false;
162
164
  };
165
+ const toolbarName = ()=>{
166
+ return props.customLabel || props.label;
167
+ };
163
168
  const onZoomOut = (e)=>{
164
169
  e.preventDefault();
165
170
  e.stopPropagation();
@@ -199,6 +204,13 @@ const ComponentToolbarPreview = ({ ...props })=>{
199
204
  }
200
205
  return false;
201
206
  };
207
+ const getSectionName = ()=>{
208
+ const checkRenamedSection = props.name && props.name === `Section ${props.uid}`;
209
+ if (getSectionNumber() >= SECTION_LIMIT - 5) {
210
+ return `${checkRenamedSection ? 'Section' : props?.name} ${getIndexSection() + 1}/${SECTION_LIMIT}`;
211
+ }
212
+ return checkRenamedSection ? `Section ${getIndexSection() + 1}` : props?.name;
213
+ };
202
214
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
203
215
  children: [
204
216
  !(props.tag == 'Section' && isThemeSectionEditor) && /*#__PURE__*/ jsxRuntime.jsxs("div", {
@@ -249,10 +261,10 @@ const ComponentToolbarPreview = ({ ...props })=>{
249
261
  }),
250
262
  props.tag == 'Section' ? /*#__PURE__*/ jsxRuntime.jsx("div", {
251
263
  "data-toolbar-name": true,
252
- children: isThemeSection ? props.name : `Section ${getIndexSection() + 1}${getSectionNumber() >= SECTION_LIMIT - 5 ? `/${SECTION_LIMIT}` : ''}`
264
+ children: getSectionName()
253
265
  }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
254
266
  "data-toolbar-name": true,
255
- children: props.customLabel || props.label
267
+ children: toolbarName()
256
268
  }),
257
269
  props.tag !== 'Section' && parents.length > 0 && /*#__PURE__*/ jsxRuntime.jsx("div", {
258
270
  "data-toolbar-icon-parent": true,
@@ -270,12 +282,21 @@ const ComponentToolbarPreview = ({ ...props })=>{
270
282
  })
271
283
  ]
272
284
  }),
273
- isShowParent && parents.map((parent, index)=>/*#__PURE__*/ jsxRuntime.jsxs("div", {
285
+ isShowParent && parents.map((parent, index)=>{
286
+ // Update count columns of Row
287
+ const parentLength = parent?.childrens?.length ?? 0;
288
+ let parent_label = parent.label;
289
+ if (parent.label === 'Row') {
290
+ parent_label = parentLength <= 1 ? parent.label + ' ' + parentLength + ' col' : parent.label + ' ' + parentLength + ' cols';
291
+ }
292
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
274
293
  "data-toolbar-parent": true,
275
294
  "data-parent-uid": parent.uid,
276
295
  "data-toolbar-theme-section": isThemeSectionEditor,
296
+ "data-toolbar-parent-revert": isShowParentRevert,
277
297
  style: {
278
- top: !isShowParentRevert ? `${-24 * (index + 1) + index}px` : `${31 + 24 * index - index}px`
298
+ top: !isShowParentRevert ? `${-36 * (index + 1)}px` // 32 height + 4 spacing
299
+ : `${36 * (index + 1)}px`
279
300
  },
280
301
  children: [
281
302
  /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -315,11 +336,12 @@ const ComponentToolbarPreview = ({ ...props })=>{
315
336
  }),
316
337
  /*#__PURE__*/ jsxRuntime.jsx("div", {
317
338
  "data-toolbar-name": true,
318
- children: parent.label
339
+ children: parent_label
319
340
  })
320
341
  ]
321
- }, parent.uid)),
322
- editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
342
+ }, parent.uid);
343
+ }),
344
+ props.tag === 'Section' && !props.isThemeSection && editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
323
345
  ...props
324
346
  }),
325
347
  props.tag == 'Sticky' && /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -406,8 +428,8 @@ const ComponentToolbarPreview = ({ ...props })=>{
406
428
  viewBox: "0 0 16 16",
407
429
  fill: "none",
408
430
  children: /*#__PURE__*/ jsxRuntime.jsx("path", {
409
- 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",
410
- fill: "currentColor"
431
+ 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",
432
+ fill: "#212121"
411
433
  })
412
434
  })
413
435
  }),
@@ -426,8 +448,8 @@ const ComponentToolbarPreview = ({ ...props })=>{
426
448
  viewBox: "0 0 16 16",
427
449
  fill: "none",
428
450
  children: /*#__PURE__*/ jsxRuntime.jsx("path", {
429
- 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",
430
- fill: "currentColor"
451
+ 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",
452
+ fill: "#212121"
431
453
  })
432
454
  })
433
455
  })
@@ -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,6 +8,7 @@ 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 })=>{
13
14
  react.useEffect(()=>{
@@ -21,6 +22,9 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
21
22
  }, [
22
23
  props.uid
23
24
  ]);
25
+ useApplyAnimation.default({
26
+ props
27
+ });
24
28
  if (props.type === 'section') {
25
29
  return null;
26
30
  }
@@ -34,6 +38,9 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
34
38
  if (editorConfigs.placeholder?.notAppendBeforeAfter) {
35
39
  customProps['data-placeholder-not-append-before-after'] = true;
36
40
  }
41
+ if (editorConfigs.placeholder?.notAppendLeftRight) {
42
+ customProps['data-placeholder-not-append-left-right'] = true;
43
+ }
37
44
  if (editorConfigs.toolbar?.parent) {
38
45
  customProps['data-toolbar-parent'] = true;
39
46
  }
@@ -106,11 +113,20 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
106
113
  advanced: advanced
107
114
  }),
108
115
  /*#__PURE__*/ jsxRuntime.jsxs("div", {
109
- 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
+ },
110
121
  className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
111
122
  ...builderAttrs,
112
123
  children: [
113
- 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
+ }),
114
130
  /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview, {
115
131
  ...props
116
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,61 @@ 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 getAnimationType = (settings, type)=>{
208
+ return settings?.triggerConfig?.[type]?.animation ?? 'none';
209
+ };
210
+ const getSettingsByDevice = (device)=>{
211
+ if (device === 'desktop') return animation?.desktop;
212
+ else if (device === 'tablet') return animation?.tablet ?? animation?.desktop;
213
+ else if (device === 'mobile') return animation?.mobile ?? animation?.tablet ?? animation?.desktop;
214
+ return animation?.desktop;
215
+ };
216
+ const appearDesktop = getAnimationType(getSettingsByDevice('desktop'), 'appear');
217
+ const hoverDesktop = getAnimationType(getSettingsByDevice('desktop'), 'hover');
218
+ const appearTablet = getAnimationType(getSettingsByDevice('tablet'), 'appear');
219
+ const appearMobile = getAnimationType(getSettingsByDevice('mobile'), 'appear');
220
+ const enableAnimation = animation?.desktop?.enabled && (appearDesktop !== 'none' || hoverDesktop !== 'none') || animation?.tablet?.enabled && appearTablet !== 'none' || animation?.mobile?.enabled && appearMobile !== 'none';
221
+ if (!enableAnimation) return liquid;
222
+ const getInitOpacity = (device)=>+!(getSettingsByDevice(device)?.enabled && ![
223
+ 'shake',
224
+ 'none'
225
+ ].includes(getAnimationType(getSettingsByDevice(device), 'appear')));
226
+ const opacityObject = {
227
+ desktop: getInitOpacity('desktop'),
228
+ tablet: getInitOpacity('tablet'),
229
+ mobile: getInitOpacity('mobile')
230
+ };
231
+ const inheritParentStyle = {
232
+ all: tag === 'Section' ? '' : 'inherit',
233
+ position: 'static',
234
+ transform: 'unset'
235
+ };
236
+ return render.template`
237
+ ${render.RenderIf(convert.isLocalEnv, `<script src="{{ 'gp-animation.js' | asset_url }}" defer="defer"></script>`, `<script src="${convert.baseAssetURL}/assets-v2/gp-animation.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
238
+ <gp-animation
239
+ gp-data='${JSON.stringify({
240
+ config: animation,
241
+ tag
242
+ })}'
243
+ style="${{
244
+ ...inheritParentStyle
245
+ }}"
246
+ >
247
+ <div class="overflow-x-hidden" style="${{
248
+ ...makeStyle.makeStyleResponsive('op', opacityObject)
249
+ }}">${liquid}</div>
250
+ </gp-animation>
251
+ `;
252
+ };
193
253
  const RenderChildren = (props)=>{
194
254
  const data = Render(props);
195
255
  // Append to prop parent
196
256
  for(const key in data.extraFiles){
197
257
  if (Object.prototype.hasOwnProperty.call(data.extraFiles, key)) {
198
- const value = data.extraFiles[key];
199
- props.customProps.extraFiles[key] = value;
258
+ props.customProps.extraFiles[key] = data.extraFiles[key];
200
259
  }
201
260
  }
202
261
  // Fix limit 256kb
@@ -205,7 +264,7 @@ const RenderChildren = (props)=>{
205
264
  if (Math.ceil(size / 1024) >= 180) {
206
265
  const fileName = `gp-section-snippet-${props.uid}`;
207
266
  props.customProps.extraFiles[fileName] = data.liquid;
208
- return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
267
+ return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
209
268
  }
210
269
  return data.liquid;
211
270
  };
@@ -222,7 +281,7 @@ const WrapRenderChildren = ({ uid, customProps }, codes)=>{
222
281
  if (Math.ceil(size / 1024) >= 180) {
223
282
  const fileName = `gp-section-snippet-${uid + i}`;
224
283
  customProps.extraFiles[fileName] = code;
225
- liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
284
+ liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
226
285
  } else {
227
286
  liquid += code;
228
287
  }
@@ -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,83 @@ 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 isLayoutElement = (el)=>{
120
+ const tag = el.getAttribute('data-component-tag');
121
+ return tag === 'Row' || tag === 'Product';
122
+ };
123
+ const updateSpacing = react.useCallback(()=>{
124
+ const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
125
+ if (!$component) return;
126
+ const toolbar = getChildrenByAttrSelector($component, 'data-toolbar');
127
+ if (!toolbar) return;
128
+ const isActive = toolbar.getAttribute('data-toolbar-active');
129
+ if (!isActive) return;
130
+ const style = getComputedStyle($component);
131
+ const $spacing = getChildrenByAttrSelector($component, 'data-spacing');
132
+ const $marginBottom = ($spacing?.querySelector('[data-spacing-margin-bottom]')) || null;
133
+ if ($marginBottom) {
134
+ if ($bottomBg.current && $bottomDrag.current) {
135
+ let value = style.marginBottom;
136
+ if (parseFloat(value) < 0) {
137
+ value = '0';
138
+ }
139
+ $bottomBg.current.style.height = value;
140
+ $bottomDrag.current.style.top = value;
141
+ $marginBottom.setAttribute('data-spacing-margin-bottom-active', 'true');
142
+ if (isLayoutElement($component)) {
143
+ $bottomBg.current.style.left = '0';
144
+ } else {
145
+ const paddingLeft = style.paddingLeft;
146
+ const leftValue = `-${paddingLeft}`;
147
+ const translateCss = `translate(${leftValue}, -100%)`;
148
+ $bottomBg.current.style.left = leftValue;
149
+ $bottomDrag.current.style.transform = translateCss;
150
+ }
151
+ }
152
+ }
153
+ }, []);
154
+ react.useEffect(()=>{
155
+ updateSpacing();
156
+ });
157
+ react.useEffect(()=>{
158
+ window.addEventListener('editor:toolbar:update-margin-bottom', updateSpacing);
159
+ window.addEventListener('editor:toolbar:update-padding-left', updateSpacing);
160
+ return ()=>{
161
+ window.removeEventListener('editor:toolbar:update-margin-bottom', updateSpacing);
162
+ window.removeEventListener('editor:toolbar:update-padding-left', updateSpacing);
163
+ };
164
+ }, [
165
+ updateSpacing
166
+ ]);
111
167
  return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
112
168
  children: props.tag !== 'Section' && /*#__PURE__*/ jsxRuntime.jsx("div", {
113
169
  "data-spacing": true,
114
170
  "data-spacing-theme-section": isThemeSectionEditor,
171
+ className: "absolute w-full bottom-0",
115
172
  children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
116
173
  "data-spacing-margin-bottom": true,
117
174
  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,
@@ -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, {
@@ -80,7 +81,7 @@ 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,
@@ -412,15 +412,42 @@ const createBuilderPreviewProvider = (args, isThemeSectionEditor)=>zustand.creat
412
412
  }
413
413
  return parents;
414
414
  },
415
- setDynamicProduct: (data)=>{
416
- set({
417
- dynamicProduct: data
418
- });
415
+ updateItemName: (id, name)=>{
416
+ const state = get().state;
417
+ const item = state[id];
418
+ if (item) {
419
+ item.name = name;
420
+ set({
421
+ state: {
422
+ ...state,
423
+ [id]: cloneDeep.cloneDeep(item)
424
+ }
425
+ });
426
+ }
419
427
  },
420
- setDynamicCollection: (data)=>{
421
- set({
422
- dynamicCollection: data
423
- });
428
+ updateItemAttribute: (id, value, attr)=>{
429
+ if (!attr || ![
430
+ 'label',
431
+ 'customLabel'
432
+ ].includes(attr)) return;
433
+ const state = get().state;
434
+ const item = state[id];
435
+ // Ignore section
436
+ if (item?.type === 'section') return;
437
+ if (item) {
438
+ const dateModified = Date.now();
439
+ item.dateModified = dateModified;
440
+ const updatedItem = {
441
+ ...item,
442
+ [attr]: value
443
+ };
444
+ set({
445
+ state: {
446
+ ...state,
447
+ [id]: updatedItem
448
+ }
449
+ });
450
+ }
424
451
  }
425
452
  }));
426
453
  const BuilderPreviewProvider = ({ children, state, isThemeSectionEditor, lazy, ...passProps })=>{
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var zustand = require('zustand');
6
+
7
+ const PageContext = /*#__PURE__*/ react.createContext(null);
8
+ const createPageStoreProvider = (data)=>zustand.createStore((set)=>({
9
+ ...data,
10
+ setDynamicProduct: (data)=>{
11
+ set({
12
+ dynamicProduct: data
13
+ });
14
+ },
15
+ setDynamicCollection: (data)=>{
16
+ set({
17
+ dynamicCollection: data
18
+ });
19
+ }
20
+ }));
21
+ const PageProvider = ({ children, dynamicProduct, dynamicCollection, ...passProps })=>{
22
+ const store = react.useMemo(()=>createPageStoreProvider({
23
+ dynamicProduct,
24
+ dynamicCollection
25
+ }), [
26
+ dynamicProduct,
27
+ dynamicCollection
28
+ ]);
29
+ return /*#__PURE__*/ jsxRuntime.jsx(PageContext.Provider, {
30
+ ...passProps,
31
+ value: store,
32
+ children: children
33
+ });
34
+ };
35
+ const usePageStore = (selector, equalityFn)=>{
36
+ const store = react.useContext(PageContext);
37
+ if (!store) {
38
+ throw new Error('usePageStore must be used within a PageProvider');
39
+ }
40
+ return zustand.useStore(store, selector, equalityFn);
41
+ };
42
+
43
+ exports.PageProvider = PageProvider;
44
+ exports.usePageStore = usePageStore;