@gem-sdk/core 1.45.0-dev.93 → 1.45.0

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 (48) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +8 -47
  2. package/dist/cjs/components/ComponentWrapperPreview.js +2 -16
  3. package/dist/cjs/components/Render.liquid.js +3 -2
  4. package/dist/cjs/components/RenderPreview.js +0 -1
  5. package/dist/cjs/components/constant.js +2 -6
  6. package/dist/cjs/components/theme-section/ThemeSectionStatus.js +5 -14
  7. package/dist/cjs/contexts/BuilderPreviewContext.js +1 -5
  8. package/dist/cjs/contexts/ModalContext.js +2 -2
  9. package/dist/cjs/contexts/PageContext.js +1 -29
  10. package/dist/cjs/contexts/SectionContext.js +0 -1
  11. package/dist/cjs/graphql/queries/blogs.generated.js +3 -0
  12. package/dist/cjs/helpers/colors.js +2 -2
  13. package/dist/cjs/helpers/shadow.js +1 -1
  14. package/dist/cjs/helpers/size.js +0 -4
  15. package/dist/cjs/hooks/animation/useAnimationPreview.js +0 -1
  16. package/dist/cjs/hooks/animation/useApplyAnimation.js +0 -2
  17. package/dist/cjs/hooks/articles/useArticlesQuery.js +0 -1
  18. package/dist/cjs/hooks/useFormatMoney.js +60 -61
  19. package/dist/cjs/index.js +0 -13
  20. package/dist/esm/components/ComponentToolbarPreview.js +9 -48
  21. package/dist/esm/components/ComponentWrapperPreview.js +2 -16
  22. package/dist/esm/components/Render.liquid.js +3 -2
  23. package/dist/esm/components/RenderPreview.js +0 -1
  24. package/dist/esm/components/constant.js +2 -6
  25. package/dist/esm/components/theme-section/ThemeSectionStatus.js +5 -14
  26. package/dist/esm/contexts/BuilderPreviewContext.js +1 -5
  27. package/dist/esm/contexts/ModalContext.js +2 -2
  28. package/dist/esm/contexts/PageContext.js +1 -29
  29. package/dist/esm/contexts/SectionContext.js +0 -1
  30. package/dist/esm/graphql/queries/blogs.generated.js +3 -0
  31. package/dist/esm/helpers/colors.js +2 -2
  32. package/dist/esm/helpers/shadow.js +1 -1
  33. package/dist/esm/helpers/size.js +1 -4
  34. package/dist/esm/hooks/animation/useAnimationPreview.js +0 -1
  35. package/dist/esm/hooks/animation/useApplyAnimation.js +0 -2
  36. package/dist/esm/hooks/articles/useArticlesQuery.js +0 -1
  37. package/dist/esm/hooks/useFormatMoney.js +61 -61
  38. package/dist/esm/index.js +2 -4
  39. package/dist/types/index.d.ts +5 -215
  40. package/package.json +3 -3
  41. package/dist/cjs/components/InteractionSuffix.js +0 -107
  42. package/dist/cjs/helpers/align.js +0 -19
  43. package/dist/cjs/hooks/useInteraction.js +0 -19
  44. package/dist/cjs/types/custom.js +0 -44
  45. package/dist/esm/components/InteractionSuffix.js +0 -105
  46. package/dist/esm/helpers/align.js +0 -17
  47. package/dist/esm/hooks/useInteraction.js +0 -17
  48. package/dist/esm/types/custom.js +0 -44
@@ -11,13 +11,12 @@ import 'vanilla-lazyload';
11
11
  import '../hooks/useCartUI.js';
12
12
  import { CreateThemeSection } from './theme-section/CreateThemeSection.js';
13
13
  import Tooltip from './toolbar/Tooltip.js';
14
- import { ThemeSectionStatusWrapper } from './theme-section/ThemeSectionStatus.js';
14
+ import { ThemeSectionStatus } from './theme-section/ThemeSectionStatus.js';
15
15
  import Resize from './resize/Resize.js';
16
16
  import { usePostPurchase } from '../hooks/useToolbarPostPurchase.js';
17
17
  import { ableGenerateContentElements } from './constant.js';
18
18
  import { AIContentGenerator } from './ai-generator/AIContentGenerator.js';
19
19
  import { AIGenContentLoading } from './ai-generator/AIGenContentLoading.js';
20
- import { InteractionSuffix } from './InteractionSuffix.js';
21
20
  import '../helpers/convert.js';
22
21
 
23
22
  const SECTION_LIMIT = 25;
@@ -44,7 +43,6 @@ const ComponentToolbarPreview = (props)=>{
44
43
  const [deleteTooltipPosition, setDeleteTooltipPosition] = useState('top');
45
44
  const [isDisableDelete, setIsUnableDelete] = useState(false);
46
45
  const [parentProductUid, setParentProductUid] = useState('');
47
- const [articleUid, setArticleUid] = useState('');
48
46
  const [tooltipText, setTooltipText] = useState({
49
47
  width: '',
50
48
  text: ''
@@ -59,18 +57,6 @@ const ComponentToolbarPreview = (props)=>{
59
57
  'Product Description',
60
58
  'Product Price'
61
59
  ];
62
- const editArticleElementList = [
63
- 'Article Title',
64
- 'Article Content',
65
- 'Article Image',
66
- 'Article Author',
67
- 'Article Category',
68
- 'Article Date'
69
- ];
70
- const editAbleElementList = [
71
- ...editProductElementList,
72
- ...editArticleElementList
73
- ];
74
60
  const isOverToolbarPosition = (el, parent)=>{
75
61
  const parentLength = parents.length;
76
62
  const rect = el.getBoundingClientRect();
@@ -116,29 +102,15 @@ const ComponentToolbarPreview = (props)=>{
116
102
  }, [
117
103
  storefrontUrl
118
104
  ]);
119
- const linkShopDefault = useMemo(()=>{
120
- return `https://admin.shopify.com/store/${shopName}`;
105
+ const shopifyEditLink = useMemo(()=>{
106
+ return productId ? `https://admin.shopify.com/store/${shopName}/products/${productId}` : '';
121
107
  }, [
108
+ productId,
122
109
  shopName
123
110
  ]);
124
- const linkEditProduct = useMemo(()=>{
125
- return productId ? `${linkShopDefault}/products/${productId}` : '';
126
- }, [
127
- linkShopDefault,
128
- productId
129
- ]);
130
- const linkEditArticle = useMemo(()=>{
131
- return articleUid ? `${linkShopDefault}/articles/${articleUid}` : '';
132
- }, [
133
- articleUid,
134
- linkShopDefault
135
- ]);
136
111
  // Get parents
137
112
  const onActiveComponent = useCallback((e)=>{
138
113
  const detail = e.detail;
139
- if (detail?.articleId) {
140
- setArticleUid(detail.articleId);
141
- }
142
114
  if (detail?.componentUid == props.uid) {
143
115
  getDeleteTooltipPosition();
144
116
  if (isSaleFunnelPage) {
@@ -230,15 +202,7 @@ const ComponentToolbarPreview = (props)=>{
230
202
  window.dispatchEvent(event);
231
203
  };
232
204
  const goToShopifyEditLink = ()=>{
233
- if (editArticleElementList.includes(toolbarName() ?? '')) {
234
- window.open(linkEditArticle, '_blank');
235
- return;
236
- }
237
- if (editProductElementList.includes(toolbarName() ?? '')) {
238
- window.open(linkEditProduct, '_blank');
239
- return;
240
- }
241
- window.open(linkShopDefault, '_blank');
205
+ window.open(shopifyEditLink, '_blank');
242
206
  };
243
207
  const onDelete = (e)=>{
244
208
  e.preventDefault();
@@ -326,6 +290,7 @@ const ComponentToolbarPreview = (props)=>{
326
290
  const isEnableCreateThemeSection = ()=>{
327
291
  return editingPageType !== 'STATIC' && editingPageType !== 'POST_PURCHASE';
328
292
  };
293
+ // if (!isActive) return null;
329
294
  return /*#__PURE__*/ jsxs(Fragment, {
330
295
  children: [
331
296
  !(props.tag == 'Section' && isThemeSectionEditor) && /*#__PURE__*/ jsxs("div", {
@@ -511,7 +476,7 @@ const ComponentToolbarPreview = (props)=>{
511
476
  })
512
477
  })
513
478
  }),
514
- editAbleElementList.includes(toolbarName() ?? '') && /*#__PURE__*/ jsx(Tooltip, {
479
+ editProductElementList.includes(toolbarName() ?? '') && /*#__PURE__*/ jsx(Tooltip, {
515
480
  "data-toolbar-title": true,
516
481
  enable: true,
517
482
  "data-toolbar-disable": false,
@@ -590,14 +555,10 @@ const ComponentToolbarPreview = (props)=>{
590
555
  fill: "currentColor"
591
556
  })
592
557
  })
593
- }),
594
- /*#__PURE__*/ jsx(InteractionSuffix, {
595
- tag: props.tag,
596
- uid: props.uid
597
558
  })
598
559
  ]
599
560
  }, props.uid),
600
- isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsx(ThemeSectionStatusWrapper, {
561
+ isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsx(ThemeSectionStatus, {
601
562
  ...props
602
563
  }),
603
564
  /*#__PURE__*/ jsx("div", {
@@ -660,6 +621,6 @@ const ComponentToolbarPreview = (props)=>{
660
621
  ]
661
622
  });
662
623
  };
663
- var ComponentToolbarPreview$1 = /*#__PURE__*/ memo(ComponentToolbarPreview); /* gem-lint/disallow-import-from-package-path */
624
+ var ComponentToolbarPreview$1 = /*#__PURE__*/ memo(ComponentToolbarPreview);
664
625
 
665
626
  export { ComponentToolbarPreview$1 as default };
@@ -1,7 +1,6 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import { memo, useEffect, isValidElement } from 'react';
3
3
  import { composeAdvanceStyle } from '../helpers/compose-advance-style.js';
4
- import { useInteraction } from '../hooks/useInteraction.js';
5
4
  import { disableWrap, excludeApplyStyle } from './constant.js';
6
5
  import RenderCustomCode from './RenderCustomCode.js';
7
6
  import ComponentToolbarPreview from './ComponentToolbarPreview.js';
@@ -29,19 +28,6 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
29
28
  }, [
30
29
  props.uid
31
30
  ]);
32
- const currentProps = props;
33
- const { getAnimationByUid } = useInteraction();
34
- const animationByInteraction = getAnimationByUid(props.uid);
35
- if (animationByInteraction) {
36
- currentProps.advanced = {
37
- ...currentProps.advanced,
38
- animation: {
39
- desktop: animationByInteraction,
40
- tablet: animationByInteraction,
41
- mobile: animationByInteraction
42
- }
43
- };
44
- }
45
31
  const pageType = usePageType();
46
32
  if (props.type === 'section') {
47
33
  return null;
@@ -146,7 +132,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
146
132
  return /*#__PURE__*/ jsxs(Fragment, {
147
133
  children: [
148
134
  /*#__PURE__*/ jsx(ComponentAnimation, {
149
- ...currentProps
135
+ ...props
150
136
  }),
151
137
  /*#__PURE__*/ jsx(RenderCustomCode, {
152
138
  uid: props.uid,
@@ -175,7 +161,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
175
161
  return /*#__PURE__*/ jsxs(Fragment, {
176
162
  children: [
177
163
  /*#__PURE__*/ jsx(ComponentAnimation, {
178
- ...currentProps
164
+ ...props
179
165
  }),
180
166
  /*#__PURE__*/ jsx(RenderCustomCode, {
181
167
  uid: props.uid,
@@ -35,6 +35,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
35
35
  const item = builder[uid];
36
36
  const Component = components[item?.tag];
37
37
  if (!Component) {
38
+ console.log('Miss component: ', item);
38
39
  return {
39
40
  liquid: '',
40
41
  extraFiles
@@ -216,6 +217,7 @@ const appendAnimation = (props, liquid)=>{
216
217
  const appearTablet = getAnimationType(getSettingsByDevice('tablet'), 'appear');
217
218
  const appearMobile = getAnimationType(getSettingsByDevice('mobile'), 'appear');
218
219
  const enableAnimation = animation?.desktop?.enabled && (appearDesktop !== 'none' || hoverDesktop !== 'none') || animation?.tablet?.enabled && appearTablet !== 'none' || animation?.mobile?.enabled && appearMobile !== 'none';
220
+ if (!enableAnimation) return liquid;
219
221
  const getInitVisibility = (device)=>getSettingsByDevice(device)?.enabled && ![
220
222
  'shake',
221
223
  'none'
@@ -230,8 +232,7 @@ const appendAnimation = (props, liquid)=>{
230
232
  gp-data='${JSON.stringify({
231
233
  config: animation,
232
234
  tag,
233
- opacity,
234
- isEnableInit: enableAnimation
235
+ opacity
235
236
  })}'
236
237
  style="${{
237
238
  display: 'contents'
@@ -41,7 +41,6 @@ const RenderPreview = ({ uid, ...passProps })=>{
41
41
  setting: item.settings,
42
42
  ...passProps,
43
43
  children: item.childrens.map((id)=>/*#__PURE__*/ jsx(RenderPreviewMemo, {
44
- ...passProps,
45
44
  uid: id
46
45
  }, id))
47
46
  }) : /*#__PURE__*/ jsx(Component, {
@@ -35,10 +35,7 @@ const disableWrap = [
35
35
  'PostPurchaseProductImages',
36
36
  'Sticky',
37
37
  'Heading',
38
- 'EstimateDate',
39
- 'ProductBadge',
40
- 'Marquee',
41
- 'MarqueeItem'
38
+ 'EstimateDate'
42
39
  ];
43
40
  const customRenderChildren = [
44
41
  'Accordion',
@@ -49,8 +46,7 @@ const customRenderChildren = [
49
46
  ];
50
47
  const excludeApplyStyle = [
51
48
  'IconListV2',
52
- 'IconList',
53
- 'ProductBadge'
49
+ 'IconList'
54
50
  ];
55
51
  const postPurchaseRequiredElements = [
56
52
  'PostPurchaseProductOffer',
@@ -1,16 +1,7 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
 
3
- const getStatusMessage = (status)=>{
4
- switch(status){
5
- case 'DRAFT':
6
- return 'This Theme Section is Draft. Publish page will also publish Theme Section.';
7
- case 'NEED_PUBLISHING':
8
- return 'Need to republish. Go to global edit and publish this section';
9
- }
10
- };
11
- const ThemeSectionStatusWrapper = ({ tag, status, isThemeSection })=>{
12
- const isRenderThemeSectionStatus = tag === 'Section' && isThemeSection && (status === 'DRAFT' || status === 'NEED_PUBLISHING');
13
- const statusMessage = getStatusMessage(status);
3
+ const ThemeSectionStatus = ({ ...props })=>{
4
+ const isRenderThemeSectionStatus = props.tag === 'Section' && props?.isThemeSection && props?.needPublishing;
14
5
  return /*#__PURE__*/ jsx(Fragment, {
15
6
  children: isRenderThemeSectionStatus && /*#__PURE__*/ jsxs("div", {
16
7
  "data-theme-section-status": true,
@@ -31,13 +22,13 @@ const ThemeSectionStatusWrapper = ({ tag, status, isThemeSection })=>{
31
22
  })
32
23
  })
33
24
  }),
34
- statusMessage && /*#__PURE__*/ jsx("span", {
25
+ /*#__PURE__*/ jsx("span", {
35
26
  "data-theme-section-status-text": true,
36
- children: statusMessage
27
+ children: "Need to republish. Go to global edit and publish this section"
37
28
  })
38
29
  ]
39
30
  })
40
31
  });
41
32
  };
42
33
 
43
- export { ThemeSectionStatusWrapper };
34
+ export { ThemeSectionStatus };
@@ -252,11 +252,7 @@ const createBuilderPreviewProvider = (args, pageName, isThemeSectionEditor)=>cre
252
252
  }
253
253
  },
254
254
  getItem: (id)=>{
255
- const item = get().state[id];
256
- return {
257
- ...item,
258
- rawChildrens: item?.childrens?.map((v)=>get().state[v])
259
- };
255
+ return get().state[id];
260
256
  },
261
257
  removeItem: (id)=>{
262
258
  if (id === 'ROOT') {
@@ -5,8 +5,8 @@ import { useStore, createStore } from 'zustand';
5
5
  const ModalContext = /*#__PURE__*/ createContext(null);
6
6
  const createModalProvider = (data)=>createStore((set)=>({
7
7
  activeId: data,
8
- setModalActive: (id, notPostMessage)=>{
9
- !!notPostMessage && window?.parent?.postMessage?.(JSON.stringify({
8
+ setModalActive: (id)=>{
9
+ window?.parent?.postMessage?.(JSON.stringify({
10
10
  type: 'active-element',
11
11
  uid: id
12
12
  }), '*');
@@ -29,31 +29,6 @@ const createPageStoreProvider = (data)=>createStore((set)=>({
29
29
  set({
30
30
  publicStoreFrontData: publicStoreFrontData
31
31
  });
32
- },
33
- setInteractionIsSelectOnPage: (value)=>{
34
- set((state)=>({
35
- interactionData: {
36
- ...state.interactionData,
37
- isSelectOnPage: value
38
- }
39
- }));
40
- },
41
- setInteractionItem: (item)=>{
42
- set((state)=>({
43
- interactionData: {
44
- ...state.interactionData,
45
- item,
46
- isSelectOnPage: state.interactionData?.isSelectOnPage || false
47
- }
48
- }));
49
- },
50
- setInteractionSelectType: (selectType)=>{
51
- set((state)=>({
52
- interactionData: {
53
- ...state.interactionData,
54
- selectType
55
- }
56
- }));
57
32
  }
58
33
  }));
59
34
  const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffers, publicStoreFrontData, ...passProps })=>{
@@ -61,10 +36,7 @@ const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffe
61
36
  dynamicProduct,
62
37
  dynamicCollection,
63
38
  productOffers,
64
- publicStoreFrontData,
65
- interactionData: {
66
- selectType: 'element'
67
- }
39
+ publicStoreFrontData
68
40
  }), [
69
41
  dynamicProduct,
70
42
  dynamicCollection,
@@ -8,7 +8,6 @@ const SectionContext = /*#__PURE__*/ createContext(null);
8
8
  const createSectionProvider = (data)=>createStore((set, get)=>({
9
9
  data: data ?? {},
10
10
  getSection: (id)=>{
11
- console.log('get().data', get().data);
12
11
  const section = get().data[id];
13
12
  return section ?? undefined;
14
13
  },
@@ -31,6 +31,9 @@ const BlogsDocument = `
31
31
  isSample
32
32
  platformCreatedAt
33
33
  author
34
+ content {
35
+ excerptHtml
36
+ }
34
37
  media {
35
38
  width
36
39
  src
@@ -117,7 +117,7 @@ const getGlobalColorStateStyle = (type, data)=>{
117
117
  return Object.fromEntries(Object.entries(data).map(([state, value])=>{
118
118
  if (state === 'active') return [];
119
119
  return [
120
- `-${stateMapping?.[state] || ''}-${type}`,
120
+ `-${stateMapping?.[state]}-${type}`,
121
121
  getSingleColorVariable(value)
122
122
  ];
123
123
  }).filter(isDefined));
@@ -154,7 +154,7 @@ const getSingleColorVariable = (color)=>{
154
154
  };
155
155
  function isColor(color) {
156
156
  if (!color || typeof color !== 'string') return false;
157
- return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent') || color?.startsWith('linear-gradient');
157
+ return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent');
158
158
  }
159
159
  const getGlobalColorStyle = (data)=>{
160
160
  if (!data) return {};
@@ -25,7 +25,7 @@ const getStyleShadow = (shadowStyle, isActiveState = false)=>{
25
25
  if (typeof value.distance == 'undefined') return {};
26
26
  const { value: distance, unit: unitDistance } = parseValueWithUnit(`${value?.distance}`);
27
27
  return {
28
- [`-${!isActiveState ? stateMapping?.[state] || '' : ''}-${getShortName(styleAppliedFor)}`]: isEnableShadow ? `${Math.cos(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${value?.blur} ${styleAppliedFor === 'box-shadow' ? value?.spread + ' ' : ''}${getSingleColorVariable(value?.color)}` : 'none'
28
+ [`-${!isActiveState ? stateMapping?.[state] : ''}-${getShortName(styleAppliedFor)}`]: isEnableShadow ? `${Math.cos(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${value?.blur} ${styleAppliedFor === 'box-shadow' ? value?.spread + ' ' : ''}${getSingleColorVariable(value?.color)}` : 'none'
29
29
  };
30
30
  };
31
31
  const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
@@ -179,8 +179,5 @@ function getCustomPaddingSizeCSSByDevice(globalSize, device) {
179
179
  const getPaddingGlobalSize = (globalSize)=>{
180
180
  return Object.assign({}, getCustomPaddingSizeCSSByDevice(globalSize, 'desktop'), getCustomPaddingSizeCSSByDevice(globalSize, 'tablet'), getCustomPaddingSizeCSSByDevice(globalSize, 'mobile'));
181
181
  };
182
- const getValueByDevice = (value, device)=>{
183
- return value?.[device] === undefined ? value?.desktop === undefined ? value?.tablet : value?.desktop : value?.[device];
184
- };
185
182
 
186
- export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getGlobalSizeGap, getHeightByShapeGlobalSize, getPaddingGlobalSize, getValueByDevice, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeGlobalSizeIcon, makeStyleWithDefault };
183
+ export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getGlobalSizeGap, getHeightByShapeGlobalSize, getPaddingGlobalSize, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeGlobalSizeIcon, makeStyleWithDefault };
@@ -3,7 +3,6 @@ import { useCallback } from 'react';
3
3
  const useAnimationPreview = ({ props, playAnimation, cancelAnimation, setAnimationOnFinish, setToolbarActive })=>{
4
4
  const previewAnimation = useCallback((e)=>{
5
5
  const { uid, isCancel } = e.detail;
6
- console.log('props.uid !== uid', props.uid !== uid, props.uid, uid);
7
6
  if (props.uid !== uid) return;
8
7
  cancelAnimation();
9
8
  if (isCancel) {
@@ -4,7 +4,6 @@ import { useAnimationTarget } from './useAnimationTarget.js';
4
4
  import { useAnimationConfig } from './useAnimationConfig.js';
5
5
  import { useAnimationActions } from './useAnimationActions.js';
6
6
  import { useAnimationPreview } from './useAnimationPreview.js';
7
- import '../../types/custom.js';
8
7
  import { AnimationType } from '../../types/animations.js';
9
8
 
10
9
  const useApplyAnimation = ({ props })=>{
@@ -37,7 +36,6 @@ const useApplyAnimation = ({ props })=>{
37
36
  setting,
38
37
  target: item.target
39
38
  }));
40
- console.log('listAnimations', listAnimations);
41
39
  cancelAnimation();
42
40
  setAnimation(listAnimations);
43
41
  }, [
@@ -16,7 +16,6 @@ const useArticlesQuery = (variables, options)=>{
16
16
  };
17
17
  const useBlogsQuery = (variables, options)=>{
18
18
  const fetcher = useFetchHandle();
19
- //@ts-ignore
20
19
  const fetchBlogs = ()=>fetcher([
21
20
  BlogsDocument,
22
21
  variables ?? {}
@@ -3,69 +3,69 @@ import { useMoneyFormat } from './shop.js';
3
3
  const shopifyPriceRounding = (amount, precision)=>{
4
4
  return parseFloat(`${amount}`).toFixed(Number(precision) + 1).slice(0, -1);
5
5
  };
6
- const formatMoney = function(cents, format) {
7
- let value = '';
8
- const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
9
- const formatString = format || '${{amount}}';
10
- /**
11
- * check default
12
- * @param opt opt
13
- * @param def def
14
- * @returns any
15
- */ function defaultOption(opt, def) {
16
- return typeof opt == 'undefined' ? def : opt;
17
- }
18
- /**
19
- * formatWithDelimiters
20
- * @param number number
21
- * @param precision precision
22
- * @param thousands thousands
23
- * @param decimal decimal
24
- * @returns any
25
- */ // eslint-disable-next-line max-params
26
- function formatWithDelimiters(number, precision, thousands, decimal) {
27
- precision = defaultOption(precision, 2);
28
- thousands = defaultOption(thousands, ',');
29
- decimal = defaultOption(decimal, '.');
30
- if (isNaN(number) || number == null) {
31
- return 0;
32
- }
33
- // 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
34
- number = shopifyPriceRounding(number, Number(precision));
35
- const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
36
- return dollars + cents;
37
- }
38
- switch(formatString.match(placeholderRegex)[1]){
39
- case 'amount':
40
- value = formatWithDelimiters(cents, 2);
41
- break;
42
- case 'amount_no_decimals':
43
- value = formatWithDelimiters(cents, 0);
44
- break;
45
- case 'amount_with_comma_separator':
46
- value = formatWithDelimiters(cents, 2, '.', ',');
47
- break;
48
- case 'amount_no_decimals_with_comma_separator':
49
- value = formatWithDelimiters(cents, 0, '.', ',');
50
- break;
51
- case 'amount_with_apostrophe_separator':
52
- value = formatWithDelimiters(cents, 2, "'", '.');
53
- break;
54
- case 'amount_no_decimals_with_space_separator':
55
- value = formatWithDelimiters(cents, 0, ' ');
56
- break;
57
- case 'amount_with_space_separator':
58
- value = formatWithDelimiters(cents, 2, ' ', ',');
59
- break;
60
- case 'amount_with_period_and_space_separator':
61
- value = formatWithDelimiters(cents, 2, ' ', '.');
62
- break;
63
- }
64
- return formatString.replace(placeholderRegex, value);
65
- };
66
6
  const useFormatMoney = (amount, withCurrency)=>{
67
7
  const { moneyFormat, moneyWithCurrencyFormat } = useMoneyFormat();
8
+ const formatMoney = function(cents, format) {
9
+ let value = '';
10
+ const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
11
+ const formatString = format || '${{amount}}';
12
+ /**
13
+ * check default
14
+ * @param opt opt
15
+ * @param def def
16
+ * @returns any
17
+ */ function defaultOption(opt, def) {
18
+ return typeof opt == 'undefined' ? def : opt;
19
+ }
20
+ /**
21
+ * formatWithDelimiters
22
+ * @param number number
23
+ * @param precision precision
24
+ * @param thousands thousands
25
+ * @param decimal decimal
26
+ * @returns any
27
+ */ // eslint-disable-next-line max-params
28
+ function formatWithDelimiters(number, precision, thousands, decimal) {
29
+ precision = defaultOption(precision, 2);
30
+ thousands = defaultOption(thousands, ',');
31
+ decimal = defaultOption(decimal, '.');
32
+ if (isNaN(number) || number == null) {
33
+ return 0;
34
+ }
35
+ // 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
36
+ number = shopifyPriceRounding(number, Number(precision));
37
+ const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
38
+ return dollars + cents;
39
+ }
40
+ switch(formatString.match(placeholderRegex)[1]){
41
+ case 'amount':
42
+ value = formatWithDelimiters(cents, 2);
43
+ break;
44
+ case 'amount_no_decimals':
45
+ value = formatWithDelimiters(cents, 0);
46
+ break;
47
+ case 'amount_with_comma_separator':
48
+ value = formatWithDelimiters(cents, 2, '.', ',');
49
+ break;
50
+ case 'amount_no_decimals_with_comma_separator':
51
+ value = formatWithDelimiters(cents, 0, '.', ',');
52
+ break;
53
+ case 'amount_with_apostrophe_separator':
54
+ value = formatWithDelimiters(cents, 2, "'", '.');
55
+ break;
56
+ case 'amount_no_decimals_with_space_separator':
57
+ value = formatWithDelimiters(cents, 0, ' ');
58
+ break;
59
+ case 'amount_with_space_separator':
60
+ value = formatWithDelimiters(cents, 2, ' ', ',');
61
+ break;
62
+ case 'amount_with_period_and_space_separator':
63
+ value = formatWithDelimiters(cents, 2, ' ', '.');
64
+ break;
65
+ }
66
+ return formatString.replace(placeholderRegex, value);
67
+ };
68
68
  return withCurrency ? formatMoney(`${amount}`, moneyWithCurrencyFormat || moneyFormat) : formatMoney(`${amount}`, moneyFormat);
69
69
  };
70
70
 
71
- export { formatMoney, shopifyPriceRounding, useFormatMoney };
71
+ export { shopifyPriceRounding, useFormatMoney };
package/dist/esm/index.js CHANGED
@@ -61,13 +61,12 @@ export { composePositionLineHeight, composePostionIconList } from './helpers/ico
61
61
  export { isDefined } from './helpers/is-defined.js';
62
62
  export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle } from './helpers/layout.js';
63
63
  export { makeAspectRatio, makeGlobalSizeHeightResponsive, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveByScreen, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined } from './helpers/make-style.js';
64
- export { convertTextAlignToJustify } from './helpers/align.js';
65
64
  export { checkAvailableVariantInStock, getSelectedVariant, parseSelectedOption } from './helpers/product.js';
66
65
  export { generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey } from './helpers/query.js';
67
66
  export { composeCornerCss, composeRadius, composeRadiusResponsive, getCornerCSSFromGlobal, getCustomRadius, getRadiusCSSFromGlobal, getRadiusStyleActiveState } from './helpers/radius.js';
68
67
  export { RenderIf, composeMemo, dataStringify, props, removeUndefinedValuesFromObject, styles, template } from './helpers/render.js';
69
68
  export { composeShadowCss, getStyleShadow, getStyleShadowState, parseValueWithUnit } from './helpers/shadow.js';
70
- export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getGlobalSizeGap, getHeightByShapeGlobalSize, getPaddingGlobalSize, getValueByDevice, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeGlobalSizeIcon, makeStyleWithDefault } from './helpers/size.js';
69
+ export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getGlobalSizeGap, getHeightByShapeGlobalSize, getPaddingGlobalSize, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeGlobalSizeIcon, makeStyleWithDefault } from './helpers/size.js';
71
70
  export { composeFallbackTypographyStyle, composeFontFamilyTypographyV2, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, genTypoClass } from './helpers/typography.js';
72
71
  export { useAddToCart } from './hooks/cart/use-add-to-cart.js';
73
72
  export { useCartData } from './hooks/cart/use-cart-data.js';
@@ -82,7 +81,7 @@ export { useCollectionsQuery } from './hooks/shop/use-collections-query.js';
82
81
  export { useProductQuery } from './hooks/shop/use-product-query.js';
83
82
  export { useProductsQuery, useProductsQueryAll } from './hooks/shop/use-products-query.js';
84
83
  export { useCurrentDevice } from './hooks/use-current-device.js';
85
- export { formatMoney, shopifyPriceRounding, useFormatMoney } from './hooks/useFormatMoney.js';
84
+ export { shopifyPriceRounding, useFormatMoney } from './hooks/useFormatMoney.js';
86
85
  export { useLazyVideo } from './hooks/use-lazy-video.js';
87
86
  export { default as useCartId } from './hooks/useCartId.js';
88
87
  export { default as useCartLine } from './hooks/useCartLine.js';
@@ -99,7 +98,6 @@ export { useProductList, useProductListProducts, useProductListSettings, useProd
99
98
  export { default as useSuspenseFetch } from './hooks/useSuspenseFetch.js';
100
99
  export { default as useSwatchesOptions } from './hooks/useSwatchesOptions.js';
101
100
  export { default as useInitialSwatchesOptions } from './hooks/useInitialSwatchesOptions.js';
102
- export { InteractionTargetEvent, InteractionTriggerEvent } from './types/custom.js';
103
101
  import * as shop from './types/shop.js';
104
102
  export { shop as ShopType };
105
103
  import * as appAPI from './types/appAPI.js';