@gem-sdk/core 1.23.0-staging.369 → 1.23.0-staging.384

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 (46) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +61 -15
  2. package/dist/cjs/components/ComponentWrapper.js +2 -2
  3. package/dist/cjs/components/ComponentWrapperPreview.js +22 -5
  4. package/dist/cjs/components/Render.js +7 -0
  5. package/dist/cjs/components/Render.liquid.js +2 -2
  6. package/dist/cjs/components/constant.js +20 -0
  7. package/dist/cjs/components/resize/Spacing.js +3 -1
  8. package/dist/cjs/components/toolbar/Tooltip.js +8 -2
  9. package/dist/cjs/contexts/BuilderContext.js +6 -4
  10. package/dist/cjs/contexts/PageContext.js +10 -0
  11. package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +17 -0
  12. package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +25 -0
  13. package/dist/cjs/helpers/compose-advance-style.js +46 -2
  14. package/dist/cjs/helpers/filter-toolbar-preview.js +1 -1
  15. package/dist/cjs/helpers/is-empty-children.js +1 -1
  16. package/dist/cjs/helpers/queries/get-products.js +8 -4
  17. package/dist/cjs/hooks/shop/use-products-query.js +3 -2
  18. package/dist/cjs/hooks/useFormatMoney.js +5 -1
  19. package/dist/cjs/hooks/useProduct.js +15 -0
  20. package/dist/cjs/hooks/useToolbarPostPurchase.js +89 -0
  21. package/dist/cjs/index.js +9 -0
  22. package/dist/cjs/types/appAPI.js +2 -0
  23. package/dist/esm/components/ComponentToolbarPreview.js +60 -16
  24. package/dist/esm/components/ComponentWrapper.js +2 -2
  25. package/dist/esm/components/ComponentWrapperPreview.js +22 -5
  26. package/dist/esm/components/Render.js +8 -1
  27. package/dist/esm/components/Render.liquid.js +2 -2
  28. package/dist/esm/components/constant.js +19 -1
  29. package/dist/esm/components/resize/Spacing.js +3 -1
  30. package/dist/esm/components/toolbar/Tooltip.js +8 -2
  31. package/dist/esm/contexts/BuilderContext.js +6 -4
  32. package/dist/esm/contexts/PageContext.js +10 -0
  33. package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +15 -0
  34. package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +23 -0
  35. package/dist/esm/helpers/compose-advance-style.js +46 -3
  36. package/dist/esm/helpers/filter-toolbar-preview.js +1 -1
  37. package/dist/esm/helpers/is-empty-children.js +1 -1
  38. package/dist/esm/helpers/queries/get-products.js +8 -4
  39. package/dist/esm/hooks/shop/use-products-query.js +3 -2
  40. package/dist/esm/hooks/useFormatMoney.js +5 -2
  41. package/dist/esm/hooks/useProduct.js +15 -1
  42. package/dist/esm/hooks/useToolbarPostPurchase.js +87 -0
  43. package/dist/esm/index.js +7 -3
  44. package/dist/esm/types/appAPI.js +1 -0
  45. package/dist/types/index.d.ts +24053 -6004
  46. package/package.json +6 -3
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var jsxRuntime = require('react/jsx-runtime');
4
6
  var react = require('react');
5
7
  require('zustand');
@@ -14,6 +16,7 @@ var CreateThemeSection = require('./theme-section/CreateThemeSection.js');
14
16
  var Tooltip = require('./toolbar/Tooltip.js');
15
17
  var ThemeSectionStatus = require('./theme-section/ThemeSectionStatus.js');
16
18
  var Resize = require('./resize/Resize.js');
19
+ var useToolbarPostPurchase = require('../hooks/useToolbarPostPurchase.js');
17
20
  require('../helpers/convert.js');
18
21
 
19
22
  const SECTION_LIMIT = 25;
@@ -25,7 +28,7 @@ const isSection = (el)=>{
25
28
  const tag = el.getAttribute('data-component-tag');
26
29
  return tag === 'Section';
27
30
  };
28
- const ComponentToolbarPreview = ({ ...props })=>{
31
+ const ComponentToolbarPreview = (props)=>{
29
32
  const isThemeSection = props.isThemeSection;
30
33
  const editingPageType = ShopContext.useShopStore((s)=>s.pageType);
31
34
  const getParents = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getParents);
@@ -35,12 +38,23 @@ const ComponentToolbarPreview = ({ ...props })=>{
35
38
  const [isShowParent, setIsShowParent] = react.useState(false);
36
39
  const [isShowParentRevert, setIsShowParentRevert] = react.useState(false);
37
40
  const [parents, setParents] = react.useState([]);
41
+ const [deleteTooltipPosition, setDeleteTooltipPosition] = react.useState('top');
42
+ const [isDisableDelete, setIsUnableDelete] = react.useState(false);
43
+ const [tooltipText, setTooltipText] = react.useState({
44
+ width: '',
45
+ text: ''
46
+ });
47
+ const [isDisableDuplicate, setIsDisableDuplicate] = react.useState(false);
48
+ const isSaleFunnelPage = react.useMemo(()=>editingPageType === 'POST_PURCHASE', [
49
+ editingPageType
50
+ ]);
51
+ const { checkDisableDelete, getTooltipText, checkDisableDuplicate } = useToolbarPostPurchase.usePostPurchase(props.uid, props.tag || '');
38
52
  const isOverToolbarPosition = (el, parent)=>{
39
- const parentLenght = parents.length;
53
+ const parentLength = parents.length;
40
54
  const rect = el.getBoundingClientRect();
41
55
  const rectP = parent.getBoundingClientRect();
42
56
  // 36px = toolbar active height + 4 spaces
43
- return rect.top - rectP.top < parentLenght * 36;
57
+ return rect.top - rectP.top < parentLength * 36;
44
58
  };
45
59
  const findOverflowParent = (element, initEl)=>{
46
60
  const thisEl = element;
@@ -54,10 +68,27 @@ const ComponentToolbarPreview = ({ ...props })=>{
54
68
  return;
55
69
  }
56
70
  };
71
+ const getDeleteTooltipPosition = react.useCallback(()=>{
72
+ if (props.tag == 'Section') return 'bottom';
73
+ const $toolbar = document.querySelector('[data-toolbar-active="true"]');
74
+ if ($toolbar) {
75
+ const rect = $toolbar.getBoundingClientRect();
76
+ if (rect.top < 60) setDeleteTooltipPosition('bottom');
77
+ else setDeleteTooltipPosition('top');
78
+ }
79
+ }, [
80
+ props.tag
81
+ ]);
57
82
  // Get parents
58
83
  const onActiveComponent = react.useCallback((e)=>{
59
84
  const detail = e.detail;
60
85
  if (detail?.componentUid == props.uid) {
86
+ getDeleteTooltipPosition();
87
+ if (isSaleFunnelPage) {
88
+ setIsUnableDelete(checkDisableDelete());
89
+ setTooltipText(getTooltipText());
90
+ setIsDisableDuplicate(checkDisableDuplicate());
91
+ }
61
92
  const currentParents = getParents(props.uid).filter((parent)=>{
62
93
  if (parent.uid === 'ROOT') return false;
63
94
  if (parent.tag === 'Section' && isThemeSectionEditor) return false;
@@ -71,10 +102,14 @@ const ComponentToolbarPreview = ({ ...props })=>{
71
102
  setIsShowParent(false);
72
103
  }
73
104
  }, [
74
- setParents,
75
- getParents,
76
105
  props.uid,
77
- isThemeSectionEditor
106
+ isSaleFunnelPage,
107
+ getParents,
108
+ checkDisableDelete,
109
+ getTooltipText,
110
+ checkDisableDuplicate,
111
+ isThemeSectionEditor,
112
+ getDeleteTooltipPosition
78
113
  ]);
79
114
  react.useEffect(()=>{
80
115
  window.addEventListener('editor:active-component', onActiveComponent);
@@ -211,6 +246,10 @@ const ComponentToolbarPreview = ({ ...props })=>{
211
246
  }
212
247
  return checkRenamedSection ? `Section ${getIndexSection() + 1}` : props?.name;
213
248
  };
249
+ const isEnableCreateThemeSection = ()=>{
250
+ return editingPageType !== 'STATIC' && editingPageType !== 'POST_PURCHASE';
251
+ };
252
+ // if (!isActive) return null;
214
253
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
215
254
  children: [
216
255
  !(props.tag == 'Section' && isThemeSectionEditor) && /*#__PURE__*/ jsxRuntime.jsxs("div", {
@@ -341,7 +380,7 @@ const ComponentToolbarPreview = ({ ...props })=>{
341
380
  ]
342
381
  }, parent.uid);
343
382
  }),
344
- props.tag === 'Section' && !props.isThemeSection && editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
383
+ props.tag === 'Section' && !props.isThemeSection && isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
345
384
  ...props
346
385
  }),
347
386
  props.tag == 'Sticky' && /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -367,9 +406,10 @@ const ComponentToolbarPreview = ({ ...props })=>{
367
406
  text: "Page has reached Shopify’s 25 section-limit",
368
407
  position: "bottom",
369
408
  "data-toolbar-duplicate": true,
370
- "data-toolbar-disable": props.tag == 'Section' && getSectionNumber() >= SECTION_LIMIT,
371
- onClick: (e)=>onDuplicate(e),
409
+ "data-toolbar-disable": props.tag == 'Section' && getSectionNumber() >= SECTION_LIMIT || isDisableDuplicate,
410
+ onClick: isDisableDuplicate ? undefined : (e)=>onDuplicate(e),
372
411
  "aria-hidden": "true",
412
+ className: isDisableDuplicate ? '!gp-cursor-not-allowed' : '',
373
413
  children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
374
414
  width: "16",
375
415
  height: "16",
@@ -383,9 +423,14 @@ const ComponentToolbarPreview = ({ ...props })=>{
383
423
  })
384
424
  })
385
425
  }),
386
- /*#__PURE__*/ jsxRuntime.jsx("div", {
426
+ /*#__PURE__*/ jsxRuntime.jsx(Tooltip.default, {
387
427
  "data-toolbar-delete": true,
388
- onClick: (e)=>onDelete(e),
428
+ onClick: (e)=>isDisableDelete ? null : onDelete(e),
429
+ enable: isDisableDelete,
430
+ "data-toolbar-disable": isDisableDelete,
431
+ width: tooltipText.width,
432
+ text: tooltipText.text,
433
+ position: deleteTooltipPosition,
389
434
  "aria-hidden": "true",
390
435
  children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
391
436
  width: "16",
@@ -401,8 +446,8 @@ const ComponentToolbarPreview = ({ ...props })=>{
401
446
  })
402
447
  })
403
448
  ]
404
- }),
405
- editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(ThemeSectionStatus.ThemeSectionStatus, {
449
+ }, props.uid),
450
+ isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(ThemeSectionStatus.ThemeSectionStatus, {
406
451
  ...props
407
452
  }),
408
453
  /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -410,7 +455,7 @@ const ComponentToolbarPreview = ({ ...props })=>{
410
455
  "data-outline-section": props.tag == 'Section',
411
456
  "data-outline-theme-section": props.tag == 'Section' && !!isThemeSection || isThemeSectionEditor,
412
457
  "data-outline-limit": getIndexSection() >= SECTION_LIMIT
413
- }),
458
+ }, 'outline-' + props.uid),
414
459
  props.tag == 'Section' && !isThemeSectionEditor && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
415
460
  children: [
416
461
  /*#__PURE__*/ jsxRuntime.jsx(Tooltip.default, {
@@ -461,5 +506,6 @@ const ComponentToolbarPreview = ({ ...props })=>{
461
506
  ]
462
507
  });
463
508
  };
509
+ var ComponentToolbarPreview$1 = /*#__PURE__*/ react.memo(ComponentToolbarPreview);
464
510
 
465
- exports.ComponentToolbarPreview = ComponentToolbarPreview;
511
+ exports.default = ComponentToolbarPreview$1;
@@ -8,9 +8,9 @@ var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
8
8
  var constant = require('./constant.js');
9
9
  var RenderCustomCode = require('./RenderCustomCode.js');
10
10
 
11
- const ComponentWrapper = ({ children, ...props })=>{
11
+ const ComponentWrapper = ({ children, pageType, ...props })=>{
12
12
  if (props.type === 'section') return null;
13
- const style = composeAdvanceStyle.composeAdvanceStyle(props.advanced, props.tag);
13
+ const style = composeAdvanceStyle.composeAdvanceStyle(props.advanced, props.tag, pageType);
14
14
  const advanced = props.advanced;
15
15
  if (constant.disableWrap.includes(props.tag) && /*#__PURE__*/ react.isValidElement(children)) {
16
16
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -9,6 +9,14 @@ var constant = require('./constant.js');
9
9
  var RenderCustomCode = require('./RenderCustomCode.js');
10
10
  var ComponentToolbarPreview = require('./ComponentToolbarPreview.js');
11
11
  var useApplyAnimation = require('../hooks/animation/useApplyAnimation.js');
12
+ require('zustand');
13
+ require('swr');
14
+ require('@gem-sdk/adapter-shopify');
15
+ require('swr/mutation');
16
+ var shop = require('../hooks/shop.js');
17
+ require('vanilla-lazyload');
18
+ require('../hooks/useCartUI.js');
19
+ require('../helpers/convert.js');
12
20
 
13
21
  const ComponentWrapperPreview = ({ children, ...props })=>{
14
22
  react.useEffect(()=>{
@@ -25,6 +33,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
25
33
  useApplyAnimation.default({
26
34
  props
27
35
  });
36
+ const pageType = shop.usePageType();
28
37
  if (props.type === 'section') {
29
38
  return null;
30
39
  }
@@ -73,14 +82,21 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
73
82
  if (!props?.editorConfigs?.toolbar?.hide) {
74
83
  customProps['data-toolbar-wrap'] = true;
75
84
  }
76
- const style = composeAdvanceStyle.composeAdvanceStyle(props.advanced, props.tag);
85
+ const isNotDroppable = (tag)=>{
86
+ return pageType === 'GP_FUNNEL_PAGE' ? [
87
+ 'ProductList',
88
+ 'Header'
89
+ ].includes(tag) : false;
90
+ };
91
+ const style = composeAdvanceStyle.composeAdvanceStyle(props.advanced, props.tag, pageType);
77
92
  const advanced = props.advanced;
78
93
  const builderAttrs = {
79
94
  ...customProps,
80
95
  'data-uid': props.uid,
81
96
  'data-component-type': 'component',
82
97
  'data-component-tag': props.tag,
83
- 'data-component-label': props.label
98
+ 'data-component-label': props.label,
99
+ 'data-not-droppable': isNotDroppable(props.tag)
84
100
  };
85
101
  if (constant.disableWrap.includes(props.tag) && /*#__PURE__*/ react.isValidElement(children)) {
86
102
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -97,7 +113,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
97
113
  advanced,
98
114
  children: [
99
115
  children.props['children'],
100
- /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview, {
116
+ /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.default, {
101
117
  ...props
102
118
  })
103
119
  ]
@@ -127,7 +143,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
127
143
  style,
128
144
  advanced
129
145
  }),
130
- /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview, {
146
+ /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.default, {
131
147
  ...props
132
148
  })
133
149
  ]
@@ -135,5 +151,6 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
135
151
  ]
136
152
  });
137
153
  };
154
+ var ComponentWrapperPreview$1 = /*#__PURE__*/ react.memo(ComponentWrapperPreview);
138
155
 
139
- exports.default = ComponentWrapperPreview;
156
+ exports.default = ComponentWrapperPreview$1;
@@ -13,6 +13,12 @@ var RenderSection = require('./RenderSection.js');
13
13
  const Render = ({ uid, ...passProps })=>{
14
14
  const item = BuilderContext.useBuilderStore((s)=>s.getItem(uid));
15
15
  const Component = BuilderComponent.useBuilderComponent(item?.tag);
16
+ const isPostPurchase = BuilderContext.useBuilderStore((s)=>s.getIsPostPurchase());
17
+ const pageType = react.useMemo(()=>{
18
+ return isPostPurchase ? 'POST_PURCHASE' : undefined;
19
+ }, [
20
+ isPostPurchase
21
+ ]);
16
22
  if (!item) return null;
17
23
  if (item?.type === 'section') {
18
24
  return /*#__PURE__*/ jsxRuntime.jsx(RenderSection.default, {
@@ -35,6 +41,7 @@ const Render = ({ uid, ...passProps })=>{
35
41
  }),
36
42
  children: /*#__PURE__*/ jsxRuntime.jsx(ComponentWrapper.default, {
37
43
  ...item,
44
+ pageType: pageType,
38
45
  children: item?.childrens?.length ? /*#__PURE__*/ jsxRuntime.jsx(Component, {
39
46
  builderProps: {
40
47
  uid,
@@ -13,10 +13,10 @@ require('vanilla-lazyload');
13
13
  require('../hooks/useCartUI.js');
14
14
  require('react-transition-group');
15
15
  require('@gem-sdk/core');
16
+ var constant = require('./constant.js');
16
17
  var render = require('../helpers/render.js');
17
18
  var convert = require('../helpers/convert.js');
18
19
  var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
19
- var constant = require('./constant.js');
20
20
 
21
21
  const componentsRenderWithParentId = [
22
22
  'CarouselItem'
@@ -234,7 +234,6 @@ const appendAnimation = (props, liquid)=>{
234
234
  transform: 'unset'
235
235
  };
236
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
237
  <gp-animation
239
238
  gp-data='${JSON.stringify({
240
239
  config: animation,
@@ -248,6 +247,7 @@ const appendAnimation = (props, liquid)=>{
248
247
  ...makeStyle.makeStyleResponsive('op', opacityObject)
249
248
  }}">${liquid}</div>
250
249
  </gp-animation>
250
+ ${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>`)}
251
251
  `;
252
252
  };
253
253
  const RenderChildren = (props)=>{
@@ -34,6 +34,7 @@ const disableWrap = [
34
34
  'Product',
35
35
  'ProductImages',
36
36
  'ProductImagesV2',
37
+ 'PostPurchaseProductImages',
37
38
  'Sticky',
38
39
  'Heading'
39
40
  ];
@@ -48,7 +49,26 @@ const excludeApplyStyle = [
48
49
  'IconListV2',
49
50
  'IconList'
50
51
  ];
52
+ const postPurchaseRequiredElements = [
53
+ 'PostPurchaseProductOffer',
54
+ 'PostPurchaseProductTitle',
55
+ 'PostPurchaseProductPrice',
56
+ 'PostPurchaseAcceptButton',
57
+ 'PostPurchaseButton',
58
+ 'PostPurchaseCalloutBox',
59
+ 'PostPurchaseProductPriceBreakdown',
60
+ 'PostPurchaseProductImages',
61
+ 'PostPurchaseCalloutText'
62
+ ];
63
+ const postPurchaseWrapElements = [
64
+ 'Row',
65
+ 'Section',
66
+ 'PostPurchaseCalloutBox',
67
+ 'PostPurchaseProductOffer'
68
+ ];
51
69
 
52
70
  exports.customRenderChildren = customRenderChildren;
53
71
  exports.disableWrap = disableWrap;
54
72
  exports.excludeApplyStyle = excludeApplyStyle;
73
+ exports.postPurchaseRequiredElements = postPurchaseRequiredElements;
74
+ exports.postPurchaseWrapElements = postPurchaseWrapElements;
@@ -9,6 +9,7 @@ var BuilderPreviewContext = require('../../contexts/BuilderPreviewContext.js');
9
9
  require('swr');
10
10
  require('@gem-sdk/adapter-shopify');
11
11
  require('swr/mutation');
12
+ var shop = require('../../hooks/shop.js');
12
13
  require('vanilla-lazyload');
13
14
  require('../../hooks/useCartUI.js');
14
15
  require('react-transition-group');
@@ -17,6 +18,7 @@ require('../../helpers/convert.js');
17
18
 
18
19
  function Spacing(props) {
19
20
  const isThemeSectionEditor = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.isThemeSectionEditor);
21
+ const pageType = shop.usePageType();
20
22
  const $bottomDrag = react.useRef(null);
21
23
  const $bottomBg = react.useRef(null);
22
24
  const delayMouseMove = react.useRef(null);
@@ -165,7 +167,7 @@ function Spacing(props) {
165
167
  updateSpacing
166
168
  ]);
167
169
  return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
168
- children: props.tag !== 'Section' && /*#__PURE__*/ jsxRuntime.jsx("div", {
170
+ children: props.tag !== 'Section' && pageType !== 'POST_PURCHASE' && /*#__PURE__*/ jsxRuntime.jsx("div", {
169
171
  "data-spacing": true,
170
172
  "data-spacing-theme-section": isThemeSectionEditor,
171
173
  className: "gp-absolute gp-w-full gp-bottom-0",
@@ -4,16 +4,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
 
7
- function Tooltip({ children, enable, text = 'Tooltip Text', position = 'right', ...props }) {
7
+ function Tooltip({ children, enable, text = 'Tooltip Text', position = 'right', width, ...props }) {
8
8
  return /*#__PURE__*/ jsxRuntime.jsxs("div", {
9
9
  ...props,
10
10
  "data-toolbar-tooltip-trigger": true,
11
11
  children: [
12
12
  children,
13
13
  enable && /*#__PURE__*/ jsxRuntime.jsx("div", {
14
+ style: {
15
+ width: width,
16
+ zIndex: 50
17
+ },
14
18
  "data-toolbar-tooltip": true,
15
19
  "data-toolbar-tooltip-position": position,
16
- children: text
20
+ dangerouslySetInnerHTML: {
21
+ __html: text
22
+ }
17
23
  })
18
24
  ]
19
25
  });
@@ -5,15 +5,17 @@ var react = require('react');
5
5
  var zustand = require('zustand');
6
6
 
7
7
  const BuilderContext = /*#__PURE__*/ react.createContext(null);
8
- const createBuilderProvider = (data)=>zustand.createStore((_, get)=>({
8
+ const createBuilderProvider = (data, isPostPurchase)=>zustand.createStore((_, get)=>({
9
9
  state: data,
10
+ isPostPurchase: isPostPurchase,
10
11
  getItem: (id)=>{
11
12
  return get().state[id];
12
- }
13
+ },
14
+ getIsPostPurchase: ()=>get().isPostPurchase
13
15
  }));
14
- const BuilderProvider = ({ children, state, lazy, priority, ...passProps })=>{
16
+ const BuilderProvider = ({ children, state, isPostPurchase, lazy, priority, ...passProps })=>{
15
17
  const Component = lazy ? react.Suspense : react.Fragment;
16
- const store = createBuilderProvider(state);
18
+ const store = createBuilderProvider(state, isPostPurchase);
17
19
  return /*#__PURE__*/ jsxRuntime.jsx(Component, {
18
20
  children: /*#__PURE__*/ jsxRuntime.jsx(BuilderContext.Provider, {
19
21
  ...passProps,
@@ -16,6 +16,16 @@ const createPageStoreProvider = (data)=>zustand.createStore((set)=>({
16
16
  set({
17
17
  dynamicCollection: data
18
18
  });
19
+ },
20
+ setPostPurchaseProductOffers: (productOffers)=>{
21
+ set({
22
+ productOffers: productOffers
23
+ });
24
+ },
25
+ setSalePageProductId: (id)=>{
26
+ set({
27
+ salePageProductId: id
28
+ });
19
29
  }
20
30
  }));
21
31
  const PageProvider = ({ children, dynamicProduct, dynamicCollection, ...passProps })=>{
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable */ const LibraryTemplateDocument = `
4
+ query LibraryTemplate($libraryTemplateId: ID!) {
5
+ libraryTemplate(id: $libraryTemplateId) {
6
+ id
7
+ name
8
+ sectionPosition
9
+ sections {
10
+ id
11
+ component
12
+ }
13
+ }
14
+ }
15
+ `;
16
+
17
+ exports.LibraryTemplateDocument = LibraryTemplateDocument;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable */ const ThemePageDocument = `
4
+ query ThemePage($themePageId: ID!) {
5
+ themePage(id: $themePageId) {
6
+ id
7
+ name
8
+ handle
9
+ isMobile
10
+ sectionPosition
11
+ pageSections {
12
+ cid
13
+ component
14
+ id
15
+ }
16
+ themeStyle {
17
+ id
18
+ data
19
+ name
20
+ }
21
+ }
22
+ }
23
+ `;
24
+
25
+ exports.ThemePageDocument = ThemePageDocument;
@@ -44,7 +44,34 @@ const getAttrValue = (attr, value, tag)=>{
44
44
  return value;
45
45
  }
46
46
  };
47
- function composeAdvanceStyle(data, tag) {
47
+ const postPurchasePaddingMapping = {
48
+ loose: '21px',
49
+ extraLoose: '38px',
50
+ tight: '9px',
51
+ extraTight: '5px',
52
+ base: '14px'
53
+ };
54
+ const composeAdvanceStyleForPostPurchase = (data, tag)=>{
55
+ if (!data) return {};
56
+ const styles = {};
57
+ Object.keys(data).forEach((attr)=>{
58
+ const value = data[attr];
59
+ if (attr === 'blockPadding') {
60
+ const valueMapped = postPurchasePaddingMapping[value];
61
+ styles[`--pb`] = getAttrValue(attr, valueMapped, tag);
62
+ styles[`--pt`] = getAttrValue(attr, valueMapped, tag);
63
+ styles[`--mb`] = '0px';
64
+ styles[`--mt`] = '0px';
65
+ }
66
+ if (attr === 'inlinePadding') {
67
+ const valueMapped = postPurchasePaddingMapping[value];
68
+ styles[`--pl`] = getAttrValue(attr, valueMapped, tag);
69
+ styles[`--pr`] = getAttrValue(attr, valueMapped, tag);
70
+ }
71
+ });
72
+ return styles;
73
+ };
74
+ function composeAdvanceStyle(data, tag, pageType) {
48
75
  if (!data) return {};
49
76
  const styles = {
50
77
  '--pos': 'relative'
@@ -196,8 +223,24 @@ function composeAdvanceStyle(data, tag) {
196
223
  }));
197
224
  }
198
225
  }
226
+ if (attr === 'blockPadding' && pageType === "POST_PURCHASE") {
227
+ const valueMapped = postPurchasePaddingMapping[value];
228
+ styles[`--pb`] = getAttrValue(attr, valueMapped, tag);
229
+ styles[`--pt`] = getAttrValue(attr, valueMapped, tag);
230
+ styles[`--mb`] = '0px';
231
+ styles[`--mt`] = '0px';
232
+ }
233
+ if (attr === 'inlinePadding' && pageType === "POST_PURCHASE") {
234
+ const valueMapped = postPurchasePaddingMapping[value];
235
+ styles[`--pl`] = getAttrValue(attr, valueMapped, tag);
236
+ styles[`--pr`] = getAttrValue(attr, valueMapped, tag);
237
+ }
199
238
  });
200
- return styles;
239
+ const advancedPostPurchaseStyles = pageType === "POST_PURCHASE" ? composeAdvanceStyleForPostPurchase(data, tag) : {};
240
+ return {
241
+ ...styles,
242
+ ...advancedPostPurchaseStyles
243
+ };
201
244
  }
202
245
  const splitStyle = (keys, style = {})=>{
203
246
  const fullKeys = keys.map((key)=>makeStyle.makeStyleKey(key)).flat();
@@ -269,6 +312,7 @@ const removePaddingYInStyle = (style)=>{
269
312
  };
270
313
 
271
314
  exports.composeAdvanceStyle = composeAdvanceStyle;
315
+ exports.composeAdvanceStyleForPostPurchase = composeAdvanceStyleForPostPurchase;
272
316
  exports.filterAttrInStyle = filterAttrInStyle;
273
317
  exports.filterCornerInStyle = filterCornerInStyle;
274
318
  exports.removeAttrInStyle = removeAttrInStyle;
@@ -7,7 +7,7 @@ var ComponentToolbarPreview = require('../components/ComponentToolbarPreview.js'
7
7
 
8
8
  const filterToolbarPreview = (children, keep = false)=>{
9
9
  const arrChild = react.Children.toArray(children);
10
- return arrChild.filter((child)=>!keep ? child?.type != ComponentToolbarPreview.ComponentToolbarPreview : child?.type == ComponentToolbarPreview.ComponentToolbarPreview);
10
+ return arrChild.filter((child)=>!keep ? child?.type != ComponentToolbarPreview.default : child?.type == ComponentToolbarPreview.default);
11
11
  };
12
12
 
13
13
  exports.default = filterToolbarPreview;
@@ -7,7 +7,7 @@ var ComponentToolbarPreview = require('../components/ComponentToolbarPreview.js'
7
7
 
8
8
  const isEmptyChildren = (children)=>{
9
9
  let arrChild = react.Children.toArray(children);
10
- arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview.ComponentToolbarPreview);
10
+ arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview.default);
11
11
  return react.Children.count(arrChild) < 1 || !children;
12
12
  };
13
13
 
@@ -4,12 +4,13 @@ var products_generated = require('../../graphql/queries/products.generated.js');
4
4
  var getCollection = require('./get-collection.js');
5
5
  var getProduct = require('./get-product.js');
6
6
 
7
- const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
7
+ const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount, allStatus })=>{
8
8
  const products = await loopFetchProducts(fetcher, {
9
9
  ids,
10
10
  isSample,
11
11
  isStorefront,
12
- defaultSelectedProductCount
12
+ defaultSelectedProductCount,
13
+ allStatus
13
14
  });
14
15
  if (!products) {
15
16
  throw new Error('Product not found');
@@ -62,7 +63,7 @@ const fetchProducts = async (fetcher, variables)=>{
62
63
  variables
63
64
  ]);
64
65
  };
65
- const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
66
+ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount, allStatus })=>{
66
67
  const defaultNumberOfProducts = defaultSelectedProductCount || 4;
67
68
  const numberOfProducts = (ids?.length == 0 ? defaultNumberOfProducts : ids?.length) ?? defaultNumberOfProducts;
68
69
  const productsPerPage = 8; // number of products per page
@@ -75,6 +76,9 @@ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, default
75
76
  // counter number of queries
76
77
  const pages = Math.ceil(numberOfProducts / productsPerPage);
77
78
  while(currentPage <= pages && hasNextPage !== false){
79
+ const status = allStatus ? {} : {
80
+ status: 'ACTIVE'
81
+ };
78
82
  variables = {
79
83
  first: getCollection.calculateFirstProduct(numberOfProducts, currentPage, productsPerPage),
80
84
  firstMedia: 1,
@@ -88,7 +92,7 @@ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, default
88
92
  direction: 'ASC'
89
93
  },
90
94
  where: {
91
- status: 'ACTIVE',
95
+ ...status,
92
96
  isSample,
93
97
  ...isStorefront && {
94
98
  isStorefront
@@ -6,7 +6,7 @@ var query = require('../../helpers/query.js');
6
6
  var shop = require('../shop.js');
7
7
  var useFetchHandle = require('../useFetchHandle.js');
8
8
 
9
- const useProductsQuery = (ids, options, defaultSelectedProductCount)=>{
9
+ const useProductsQuery = (ids, options, params)=>{
10
10
  const fetcher = useFetchHandle.useFetchHandle();
11
11
  const isSample = shop.useIsSampleProduct();
12
12
  const isStorefront = shop.useIsStorefrontProduct();
@@ -14,7 +14,8 @@ const useProductsQuery = (ids, options, defaultSelectedProductCount)=>{
14
14
  ids,
15
15
  isSample,
16
16
  isStorefront,
17
- defaultSelectedProductCount
17
+ defaultSelectedProductCount: params?.defaultSelectedProductCount,
18
+ allStatus: params?.allStatus
18
19
  }) : null, async ([, arg])=>{
19
20
  return getProducts.getProducts(fetcher, arg);
20
21
  }, options);
@@ -2,6 +2,9 @@
2
2
 
3
3
  var shop = require('./shop.js');
4
4
 
5
+ const shopifyPriceRounding = (amount, precision)=>{
6
+ return parseFloat(`${amount}`).toFixed(Number(precision) + 1).slice(0, -1);
7
+ };
5
8
  const useFormatMoney = (amount, withCurrency)=>{
6
9
  const { moneyFormat, moneyWithCurrencyFormat } = shop.useMoneyFormat();
7
10
  const formatMoney = function(cents, format) {
@@ -32,7 +35,7 @@ const useFormatMoney = (amount, withCurrency)=>{
32
35
  return 0;
33
36
  }
34
37
  // shopify làm tròn bằng cách cắt đi các số ở đằng sau chứ không sử dụng toFixed để làm tròn như toán học
35
- number = parseFloat(`${number}`).toFixed(Number(precision) + 1).slice(0, -1);
38
+ number = shopifyPriceRounding(number, Number(precision));
36
39
  const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
37
40
  return dollars + cents;
38
41
  }
@@ -55,4 +58,5 @@ const useFormatMoney = (amount, withCurrency)=>{
55
58
  return withCurrency ? formatMoney(`${amount}`, moneyWithCurrencyFormat || moneyFormat) : formatMoney(`${amount}`, moneyFormat);
56
59
  };
57
60
 
61
+ exports.shopifyPriceRounding = shopifyPriceRounding;
58
62
  exports.useFormatMoney = useFormatMoney;