@gem-sdk/core 1.47.0 → 1.48.0-dev.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 (40) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +114 -100
  2. package/dist/cjs/components/ComponentWrapperPreview.js +16 -2
  3. package/dist/cjs/components/InteractionSuffix.js +107 -0
  4. package/dist/cjs/components/Render.liquid.js +21 -6
  5. package/dist/cjs/components/RenderPreview.js +1 -0
  6. package/dist/cjs/components/constant.js +2 -1
  7. package/dist/cjs/contexts/PageContext.js +29 -1
  8. package/dist/cjs/contexts/SectionContext.js +0 -1
  9. package/dist/cjs/helpers/align.js +19 -0
  10. package/dist/cjs/helpers/colors.js +1 -1
  11. package/dist/cjs/helpers/shadow.js +1 -1
  12. package/dist/cjs/helpers/third-party/appConfig.js +14 -0
  13. package/dist/cjs/helpers/third-party/appSetting.js +22 -0
  14. package/dist/cjs/helpers/third-party/constant.js +3 -1
  15. package/dist/cjs/hooks/animation/useApplyAnimation.js +1 -0
  16. package/dist/cjs/hooks/useFormatMoney.js +61 -60
  17. package/dist/cjs/hooks/useInteraction.js +19 -0
  18. package/dist/cjs/index.js +12 -0
  19. package/dist/cjs/types/custom.js +44 -0
  20. package/dist/esm/components/ComponentToolbarPreview.js +114 -100
  21. package/dist/esm/components/ComponentWrapperPreview.js +16 -2
  22. package/dist/esm/components/InteractionSuffix.js +105 -0
  23. package/dist/esm/components/Render.liquid.js +21 -6
  24. package/dist/esm/components/RenderPreview.js +1 -0
  25. package/dist/esm/components/constant.js +2 -1
  26. package/dist/esm/contexts/PageContext.js +29 -1
  27. package/dist/esm/contexts/SectionContext.js +0 -1
  28. package/dist/esm/helpers/align.js +17 -0
  29. package/dist/esm/helpers/colors.js +1 -1
  30. package/dist/esm/helpers/shadow.js +1 -1
  31. package/dist/esm/helpers/third-party/appConfig.js +13 -1
  32. package/dist/esm/helpers/third-party/appSetting.js +22 -0
  33. package/dist/esm/helpers/third-party/constant.js +4 -2
  34. package/dist/esm/hooks/animation/useApplyAnimation.js +1 -0
  35. package/dist/esm/hooks/useFormatMoney.js +61 -61
  36. package/dist/esm/hooks/useInteraction.js +17 -0
  37. package/dist/esm/index.js +3 -1
  38. package/dist/esm/types/custom.js +44 -0
  39. package/dist/types/index.d.ts +168 -3
  40. package/package.json +3 -3
@@ -0,0 +1,105 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useMemo } from 'react';
3
+ import 'zustand';
4
+ import 'swr';
5
+ import { usePageStore } from '../contexts/PageContext.js';
6
+ import '@gem-sdk/adapter-shopify';
7
+ import 'swr/mutation';
8
+ import 'swr/infinite';
9
+ import 'vanilla-lazyload';
10
+ import '../hooks/useCartUI.js';
11
+ import 'react-transition-group';
12
+ import '@gem-sdk/core';
13
+ import 'classnames';
14
+ import 'dayjs';
15
+ import '../helpers/convert.js';
16
+
17
+ const InteractionSuffix = ({ tag, uid })=>{
18
+ const currentInteraction = usePageStore((s)=>s.interactionData?.item);
19
+ const isCurrentInteractionTarget = useMemo(()=>{
20
+ return currentInteraction?.targets?.find((t)=>t.uid === uid);
21
+ }, [
22
+ currentInteraction,
23
+ uid
24
+ ]);
25
+ const isCurrentInteractionTrigger = useMemo(()=>{
26
+ return currentInteraction?.self?.uid === uid;
27
+ }, [
28
+ currentInteraction,
29
+ uid
30
+ ]);
31
+ const isDisplay = useMemo(()=>{
32
+ return isCurrentInteractionTarget || isCurrentInteractionTrigger;
33
+ }, [
34
+ isCurrentInteractionTarget,
35
+ isCurrentInteractionTrigger
36
+ ]);
37
+ const positionOffset = useMemo(()=>{
38
+ if (isCurrentInteractionTrigger && isCurrentInteractionTarget) {
39
+ return 80;
40
+ }
41
+ return 40;
42
+ }, [
43
+ isCurrentInteractionTrigger,
44
+ isCurrentInteractionTarget
45
+ ]);
46
+ if (!isDisplay) {
47
+ return undefined;
48
+ }
49
+ return /*#__PURE__*/ jsxs(Fragment, {
50
+ children: [
51
+ /*#__PURE__*/ jsx("div", {
52
+ className: "hidden gp-left-[-40px] gp-left-[-80px] gp-right-[-40px] gp-right-[-80px]"
53
+ }),
54
+ /*#__PURE__*/ jsxs("div", {
55
+ className: `gp-hidden gp-absolute interaction-suffix gp-gap-[8px] ${tag == 'Section' ? `gp-left-[-${positionOffset}px]` : `gp-right-[-${positionOffset}px]`}`,
56
+ children: [
57
+ isCurrentInteractionTrigger && /*#__PURE__*/ jsx("div", {
58
+ className: `gp-h-8 gp-rounded-[8px] gp-w-8 gp-bg-[#212121] gp-flex gp-justify-center gp-items-center `,
59
+ children: /*#__PURE__*/ jsx("svg", {
60
+ width: "16",
61
+ height: "16",
62
+ viewBox: "0 0 16 16",
63
+ fill: "none",
64
+ xmlns: "http://www.w3.org/2000/svg",
65
+ children: /*#__PURE__*/ jsx("path", {
66
+ fillRule: "evenodd",
67
+ clipRule: "evenodd",
68
+ d: "M12.9196 5.80449C13.0989 5.80449 13.1876 6.02216 13.0595 6.14749L4.83569 14.1892C4.69517 14.3267 4.46149 14.2002 4.49967 14.0074L5.50422 8.93537C5.53483 8.7808 5.41656 8.6368 5.25898 8.6368H3.08019C2.92551 8.6368 2.82938 8.46874 2.90779 8.33541L6.72099 1.85154C6.75692 1.79045 6.8225 1.75293 6.89338 1.75293H12.5729C12.7386 1.75293 12.8324 1.94273 12.7319 2.07435L10.1891 5.40272C10.0634 5.56724 10.1807 5.80449 10.3877 5.80449H12.9196Z",
69
+ fill: "#F9F9F9"
70
+ })
71
+ })
72
+ }),
73
+ isCurrentInteractionTarget && /*#__PURE__*/ jsx("div", {
74
+ className: `gp-h-8 min-w-8 gp-rounded-[8px] gp-w-8 gp-bg-[#212121] gp-flex gp-justify-center gp-items-center`,
75
+ children: /*#__PURE__*/ jsxs("svg", {
76
+ width: "16",
77
+ height: "16",
78
+ viewBox: "0 0 16 16",
79
+ fill: "none",
80
+ xmlns: "http://www.w3.org/2000/svg",
81
+ children: [
82
+ /*#__PURE__*/ jsx("path", {
83
+ d: "M8.58987 2.11238C8.62815 2.66333 8.21254 3.141 7.66158 3.17928C6.73192 3.24386 5.84034 3.57396 5.09276 4.13034C4.34519 4.68673 3.77304 5.44602 3.44429 6.31801C3.11554 7.19 3.04401 8.13803 3.23821 9.04947C3.4324 9.96092 3.88415 10.7975 4.53978 11.4597C5.19541 12.122 6.02737 12.5821 6.93682 12.7854C7.84626 12.9888 8.79496 12.9268 9.67021 12.6068C10.5455 12.2869 11.3105 11.7224 11.8743 10.9804C12.4382 10.2385 12.7772 9.35025 12.8512 8.42129C12.895 7.87074 13.3768 7.45996 13.9273 7.50377C14.4779 7.54758 14.8887 8.0294 14.8449 8.57994C14.7406 9.8906 14.2622 11.1438 13.4667 12.1906C12.6711 13.2374 11.5918 14.0338 10.3569 14.4852C9.12204 14.9367 7.78353 15.0241 6.50041 14.7373C5.2173 14.4504 4.0435 13.8012 3.11848 12.8668C2.19345 11.9324 1.55609 10.7522 1.28211 9.46624C1.00813 8.1803 1.10905 6.84274 1.57287 5.61247C2.03669 4.3822 2.84393 3.31093 3.89867 2.52593C4.95342 1.74093 6.21133 1.27521 7.52297 1.18409C8.07393 1.14581 8.5516 1.56142 8.58987 2.11238Z",
84
+ fill: "#F9F9F9"
85
+ }),
86
+ /*#__PURE__*/ jsx("path", {
87
+ fillRule: "evenodd",
88
+ clipRule: "evenodd",
89
+ d: "M11.9757 1.25658C12.184 1.31428 12.3452 1.47958 12.3976 1.68929L12.7872 3.24774L14.3457 3.63736C14.5554 3.68978 14.7207 3.85096 14.7784 4.05928C14.8361 4.2676 14.7773 4.49085 14.6244 4.64371L12.7167 6.55141C12.5677 6.70044 12.3514 6.76035 12.1469 6.70924L10.5688 6.3147L8.42436 8.45912C8.19005 8.69344 7.81015 8.69344 7.57583 8.45912C7.34152 8.22481 7.34152 7.84491 7.57583 7.61059L9.72025 5.46617L9.32572 3.88804C9.2746 3.68357 9.33451 3.46728 9.48354 3.31825L11.3912 1.41054C11.5441 1.25769 11.7674 1.19888 11.9757 1.25658ZM10.8795 5.15545L12.1084 5.46267L13.0266 4.54451L12.1469 4.3246C11.9319 4.27086 11.7641 4.10301 11.7104 3.88804L11.4904 3.0084L10.5723 3.92656L10.8795 5.15545Z",
90
+ fill: "#F9F9F9"
91
+ }),
92
+ /*#__PURE__*/ jsx("path", {
93
+ d: "M7.35783 6.45343C7.87208 6.25201 8.12568 5.67185 7.92426 5.15761C7.72284 4.64336 7.14268 4.38976 6.62844 4.59118C6.05705 4.81498 5.55049 5.17772 5.15453 5.64655C4.75858 6.11538 4.4857 6.67552 4.36055 7.27631C4.23539 7.87709 4.26189 8.49961 4.43764 9.08758C4.6134 9.67555 4.93289 10.2105 5.36727 10.6439C5.80165 11.0774 6.33722 11.3958 6.92556 11.5702C7.51391 11.7445 8.13643 11.7695 8.73683 11.6427C9.33723 11.5158 9.89652 11.2413 10.3641 10.8439C10.8318 10.4465 11.1929 9.93885 11.4151 9.36679C11.615 8.85196 11.3597 8.27254 10.8449 8.07262C10.3301 7.87269 9.75066 8.12797 9.55073 8.6428C9.44887 8.9051 9.28329 9.1378 9.06901 9.3199C8.85474 9.50199 8.59851 9.62774 8.32352 9.68582C8.04853 9.7439 7.76341 9.73249 7.49394 9.65262C7.22445 9.57274 6.97907 9.42691 6.78001 9.22825C6.58093 9.0296 6.43446 8.78439 6.35386 8.51478C6.27327 8.24517 6.26112 7.9597 6.31851 7.6842C6.37591 7.4087 6.50102 7.1519 6.68251 6.93702C6.86399 6.72214 7.0961 6.55595 7.35783 6.45343Z",
94
+ fill: "#F9F9F9"
95
+ })
96
+ ]
97
+ })
98
+ })
99
+ ]
100
+ })
101
+ ]
102
+ });
103
+ };
104
+
105
+ export { InteractionSuffix };
@@ -35,7 +35,6 @@ 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);
39
38
  return {
40
39
  liquid: '',
41
40
  extraFiles
@@ -72,6 +71,10 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
72
71
  parentId: componentsRenderWithParentId.includes(item.tag) ? parentId : null,
73
72
  pageContext,
74
73
  ...passProps,
74
+ builderAttrs: {
75
+ ...passProps.builderAttrs,
76
+ 'data-id': uid
77
+ },
75
78
  rawChildren: item.childrens.map((id)=>{
76
79
  return {
77
80
  ...builder[id],
@@ -107,11 +110,15 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
107
110
  isText: componentTexts.includes(item.tag) ? true : null,
108
111
  parentId: componentsRenderWithParentId.includes(item.tag) ? parentId : null,
109
112
  pageContext,
110
- ...passProps
113
+ ...passProps,
114
+ builderAttrs: {
115
+ ...passProps.builderAttrs,
116
+ 'data-id': uid
117
+ }
111
118
  });
112
119
  });
113
120
  } else {
114
- liquid = template`<div style="${!componentIconList.includes(item.tag) ? style : ''}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
121
+ liquid = template`<div gp-el-wrapper style="${!componentIconList.includes(item.tag) ? style : ''}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
115
122
  ${RenderIf(item?.childrens?.length, ()=>{
116
123
  return Component({
117
124
  builderProps: {
@@ -126,6 +133,10 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
126
133
  },
127
134
  pageContext,
128
135
  ...passProps,
136
+ builderAttrs: {
137
+ ...passProps.builderAttrs,
138
+ 'data-id': uid
139
+ },
129
140
  rawChildren: item.childrens.map((id)=>{
130
141
  return {
131
142
  ...builder[id],
@@ -162,7 +173,11 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
162
173
  pageContext,
163
174
  isText: componentTexts.includes(item.tag) ? true : null,
164
175
  style: componentIconList.includes(item.tag) ? style : null,
165
- ...passProps
176
+ ...passProps,
177
+ builderAttrs: {
178
+ ...passProps.builderAttrs,
179
+ 'data-id': uid
180
+ }
166
181
  });
167
182
  })}
168
183
  </div>`;
@@ -215,7 +230,6 @@ const appendAnimation = (props, liquid)=>{
215
230
  const appearTablet = getAnimationType(getSettingsByDevice('tablet'), 'appear');
216
231
  const appearMobile = getAnimationType(getSettingsByDevice('mobile'), 'appear');
217
232
  const enableAnimation = animation?.desktop?.enabled && (appearDesktop !== 'none' || hoverDesktop !== 'none') || animation?.tablet?.enabled && appearTablet !== 'none' || animation?.mobile?.enabled && appearMobile !== 'none';
218
- if (!enableAnimation) return liquid;
219
233
  const getInitVisibility = (device)=>getSettingsByDevice(device)?.enabled && ![
220
234
  'shake',
221
235
  'none'
@@ -230,7 +244,8 @@ const appendAnimation = (props, liquid)=>{
230
244
  gp-data='${JSON.stringify({
231
245
  config: animation,
232
246
  tag,
233
- opacity
247
+ opacity,
248
+ isEnableInit: enableAnimation
234
249
  })}'
235
250
  style="${{
236
251
  display: 'contents'
@@ -41,6 +41,7 @@ const RenderPreview = ({ uid, ...passProps })=>{
41
41
  setting: item.settings,
42
42
  ...passProps,
43
43
  children: item.childrens.map((id)=>/*#__PURE__*/ jsx(RenderPreviewMemo, {
44
+ bundleItem: passProps?.bundleItem,
44
45
  uid: id
45
46
  }, id))
46
47
  }) : /*#__PURE__*/ jsx(Component, {
@@ -49,7 +49,8 @@ const customRenderChildren = [
49
49
  ];
50
50
  const excludeApplyStyle = [
51
51
  'IconListV2',
52
- 'IconList'
52
+ 'IconList',
53
+ 'ProductBadge'
53
54
  ];
54
55
  const postPurchaseRequiredElements = [
55
56
  'PostPurchaseProductOffer',
@@ -29,6 +29,31 @@ 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
+ }));
32
57
  }
33
58
  }));
34
59
  const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffers, publicStoreFrontData, ...passProps })=>{
@@ -36,7 +61,10 @@ const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffe
36
61
  dynamicProduct,
37
62
  dynamicCollection,
38
63
  productOffers,
39
- publicStoreFrontData
64
+ publicStoreFrontData,
65
+ interactionData: {
66
+ selectType: 'element'
67
+ }
40
68
  }), [
41
69
  dynamicProduct,
42
70
  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
  },
@@ -0,0 +1,17 @@
1
+ const convertTextAlignToJustify = (align)=>{
2
+ const devices = [
3
+ 'desktop',
4
+ 'tablet',
5
+ 'mobile'
6
+ ];
7
+ const result = {};
8
+ devices.forEach((device)=>{
9
+ const deviceType = device === 'desktop' ? '' : `${device}:`;
10
+ result[`${deviceType}gp-justify-start`] = align?.[device] === 'left';
11
+ result[`${deviceType}gp-justify-center`] = align?.[device] === 'center';
12
+ result[`${deviceType}gp-justify-end`] = align?.[device] === 'right';
13
+ });
14
+ return result;
15
+ };
16
+
17
+ export { convertTextAlignToJustify };
@@ -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));
@@ -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)=>{
@@ -40,5 +40,17 @@ const ShopifyFormsConfig = {
40
40
  appId: '8744a304-fcb1-4347-b211-bb6b4759a76a'
41
41
  }
42
42
  };
43
+ const ReviewxpoProductReviewsAppConfig = {
44
+ ReviewxpoProductReviewsApp: {
45
+ appName: 'reviewxpo-product-reviews-app',
46
+ appId: '3e3d94fa-8b53-4134-942c-f7662dc9282f'
47
+ }
48
+ };
49
+ const PumperBundlesVolumeDiscountConfig = {
50
+ PumperBundlesVolumeDiscount: {
51
+ appName: 'Pumper Bundles Volume Discount',
52
+ appId: '0856870d-2aca-4b1e-a662-cf1797f61270'
53
+ }
54
+ };
43
55
 
44
- export { BonLoyaltyRewardsReferralsConfig, LoopSubscriptionsConfig, RechargeSubscriptionsConfig, SelleasyConfig, ShopifyFormsConfig, SkioSubscriptionsYcS20Config, SubifySubscriptionsConfig };
56
+ export { BonLoyaltyRewardsReferralsConfig, LoopSubscriptionsConfig, PumperBundlesVolumeDiscountConfig, RechargeSubscriptionsConfig, ReviewxpoProductReviewsAppConfig, SelleasyConfig, ShopifyFormsConfig, SkioSubscriptionsYcS20Config, SubifySubscriptionsConfig };
@@ -83,7 +83,29 @@ const overrideSettings = (tag, currentSetting, appSetting)=>{
83
83
  return currentSetting;
84
84
  }
85
85
  };
86
+ const ReviewxpoProductReviewsApp = {
87
+ ReviewxpoProductReviewsApp: {
88
+ 'five-star-badge-widget': null,
89
+ 'allreviews-widget': null,
90
+ 'carousel-widget': null,
91
+ 'gallery-widget': null,
92
+ 'badge-widget': null,
93
+ 'testimonial-widget': null,
94
+ 'star-widget': null,
95
+ 'revews-widget': null
96
+ }
97
+ };
98
+ const PumperBundlesVolumeDiscount = {
99
+ PumperBundlesVolumeDiscount: {
100
+ 'app-block': {
101
+ selected_product: '{{product}}',
102
+ using_page_builder: false
103
+ }
104
+ }
105
+ };
86
106
  const composeSettingsByWidgetType = {
107
+ ...PumperBundlesVolumeDiscount,
108
+ ...ReviewxpoProductReviewsApp,
87
109
  ...ShopifyForms,
88
110
  ...SkioSubscriptionsYcS20,
89
111
  ...LoopSubscriptions,
@@ -1,4 +1,4 @@
1
- import { RechargeSubscriptionsConfig, BonLoyaltyRewardsReferralsConfig, SubifySubscriptionsConfig, SelleasyConfig, LoopSubscriptionsConfig, SkioSubscriptionsYcS20Config, ShopifyFormsConfig } from './appConfig.js';
1
+ import { RechargeSubscriptionsConfig, BonLoyaltyRewardsReferralsConfig, SubifySubscriptionsConfig, SelleasyConfig, LoopSubscriptionsConfig, SkioSubscriptionsYcS20Config, ShopifyFormsConfig, ReviewxpoProductReviewsAppConfig, PumperBundlesVolumeDiscountConfig } from './appConfig.js';
2
2
 
3
3
  const mapShopifyAppMeta = {
4
4
  ...RechargeSubscriptionsConfig,
@@ -7,7 +7,9 @@ const mapShopifyAppMeta = {
7
7
  ...SelleasyConfig,
8
8
  ...LoopSubscriptionsConfig,
9
9
  ...SkioSubscriptionsYcS20Config,
10
- ...ShopifyFormsConfig
10
+ ...ShopifyFormsConfig,
11
+ ...ReviewxpoProductReviewsAppConfig,
12
+ ...PumperBundlesVolumeDiscountConfig
11
13
  };
12
14
  const THIRD_PARTY_APP_BLOCK_ID_PREFIX = 'gp_app';
13
15
 
@@ -4,6 +4,7 @@ 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';
7
8
  import { AnimationType } from '../../types/animations.js';
8
9
 
9
10
  const useApplyAnimation = ({ props })=>{
@@ -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
+ };
6
66
  const useFormatMoney = (amount, withCurrency)=>{
7
67
  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 { shopifyPriceRounding, useFormatMoney };
71
+ export { formatMoney, shopifyPriceRounding, useFormatMoney };
@@ -0,0 +1,17 @@
1
+ import { usePageStore } from '../contexts/PageContext.js';
2
+
3
+ const useInteraction = ()=>{
4
+ const interactionData = usePageStore((state)=>state.interactionData);
5
+ const { item } = interactionData || {};
6
+ const getAnimationByUid = (uid)=>{
7
+ const targets = item?.targets;
8
+ const targetByUid = targets?.find((target)=>target.uid === uid);
9
+ const metaDataContainsAnimation = targetByUid?.events?.find((it)=>it.condition?.metaData?.animation);
10
+ return metaDataContainsAnimation?.condition?.metaData?.animation;
11
+ };
12
+ return {
13
+ getAnimationByUid
14
+ };
15
+ };
16
+
17
+ export { useInteraction };
package/dist/esm/index.js CHANGED
@@ -61,6 +61,7 @@ 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';
64
65
  export { checkAvailableVariantInStock, getSelectedVariant, parseSelectedOption } from './helpers/product.js';
65
66
  export { generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey } from './helpers/query.js';
66
67
  export { composeCornerCss, composeRadius, composeRadiusResponsive, getCornerCSSFromGlobal, getCustomRadius, getRadiusCSSFromGlobal, getRadiusStyleActiveState } from './helpers/radius.js';
@@ -81,7 +82,7 @@ export { useCollectionsQuery } from './hooks/shop/use-collections-query.js';
81
82
  export { useProductQuery } from './hooks/shop/use-product-query.js';
82
83
  export { useProductsQuery, useProductsQueryAll } from './hooks/shop/use-products-query.js';
83
84
  export { useCurrentDevice } from './hooks/use-current-device.js';
84
- export { shopifyPriceRounding, useFormatMoney } from './hooks/useFormatMoney.js';
85
+ export { formatMoney, shopifyPriceRounding, useFormatMoney } from './hooks/useFormatMoney.js';
85
86
  export { useLazyVideo } from './hooks/use-lazy-video.js';
86
87
  export { default as useCartId } from './hooks/useCartId.js';
87
88
  export { default as useCartLine } from './hooks/useCartLine.js';
@@ -98,6 +99,7 @@ export { useProductList, useProductListProducts, useProductListSettings, useProd
98
99
  export { default as useSuspenseFetch } from './hooks/useSuspenseFetch.js';
99
100
  export { default as useSwatchesOptions } from './hooks/useSwatchesOptions.js';
100
101
  export { default as useInitialSwatchesOptions } from './hooks/useInitialSwatchesOptions.js';
102
+ export { InteractionTargetEvent, InteractionTriggerEvent } from './types/custom.js';
101
103
  import * as shop from './types/shop.js';
102
104
  export { shop as ShopType };
103
105
  import * as appAPI from './types/appAPI.js';
@@ -0,0 +1,44 @@
1
+ var InteractionTargetEvent;
2
+ (function(InteractionTargetEvent) {
3
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-background-color'] = 0] = 'gp:change-background-color';
4
+ InteractionTargetEvent[InteractionTargetEvent['gp:run-animation'] = 1] = 'gp:run-animation';
5
+ InteractionTargetEvent[InteractionTargetEvent['gp:toggle-element-visibility'] = 2] = 'gp:toggle-element-visibility';
6
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-text'] = 3] = 'gp:change-text';
7
+ InteractionTargetEvent[InteractionTargetEvent['gp:scroll-to'] = 4] = 'gp:scroll-to';
8
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-text-style'] = 5] = 'gp:change-text-style';
9
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-content'] = 6] = 'gp:change-content';
10
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-button-style'] = 7] = 'gp:change-button-style';
11
+ InteractionTargetEvent[InteractionTargetEvent['gp:copy-text'] = 8] = 'gp:copy-text';
12
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-image'] = 9] = 'gp:change-image';
13
+ InteractionTargetEvent[InteractionTargetEvent['gp:toggle-video-play'] = 10] = 'gp:toggle-video-play';
14
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-slider-ratio'] = 11] = 'gp:change-slider-ratio';
15
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-icon-style'] = 12] = 'gp:change-icon-style';
16
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-expanded-item'] = 13] = 'gp:change-expanded-item';
17
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-active-item'] = 14] = 'gp:change-active-item';
18
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-slide'] = 15] = 'gp:change-slide';
19
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-image-step'] = 16] = 'gp:change-image-step';
20
+ InteractionTargetEvent[InteractionTargetEvent['gp:change-text-value'] = 17] = 'gp:change-text-value';
21
+ InteractionTargetEvent[InteractionTargetEvent['gp:toggle-popup-open'] = 18] = 'gp:toggle-popup-open';
22
+ InteractionTargetEvent[InteractionTargetEvent['gp:show-or-hide'] = 19] = 'gp:show-or-hide';
23
+ })(InteractionTargetEvent || (InteractionTargetEvent = {}));
24
+ var InteractionTriggerEvent;
25
+ (function(InteractionTriggerEvent) {
26
+ InteractionTriggerEvent[InteractionTriggerEvent['click'] = 0] = 'click';
27
+ InteractionTriggerEvent[InteractionTriggerEvent["active"] = 1] = "active";
28
+ InteractionTriggerEvent[InteractionTriggerEvent['mouseover'] = 2] = 'mouseover';
29
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:appear'] = 3] = 'gp:appear';
30
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-selected'] = 4] = 'gp:item-selected';
31
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-unselected'] = 5] = 'gp:item-unselected';
32
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-hovered'] = 6] = 'gp:item-hovered';
33
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:item-click'] = 7] = 'gp:item-click';
34
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:after-submit'] = 8] = 'gp:after-submit';
35
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:quantity-change'] = 9] = 'gp:quantity-change';
36
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:after-checked-value'] = 10] = 'gp:after-checked-value';
37
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:after-add-to-cart'] = 11] = 'gp:after-add-to-cart';
38
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:popup-open'] = 12] = 'gp:popup-open';
39
+ InteractionTriggerEvent[InteractionTriggerEvent['gp:popup-close'] = 13] = 'gp:popup-close';
40
+ InteractionTriggerEvent[InteractionTriggerEvent['scroll-up'] = 14] = 'scroll-up';
41
+ InteractionTriggerEvent[InteractionTriggerEvent['scroll-down'] = 15] = 'scroll-down';
42
+ })(InteractionTriggerEvent || (InteractionTriggerEvent = {}));
43
+
44
+ export { InteractionTargetEvent, InteractionTriggerEvent };