@gem-sdk/core 1.50.0 → 1.51.0-dev.64
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.
- package/dist/cjs/components/ComponentToolbarPreview.js +115 -104
- package/dist/cjs/components/ComponentWrapperPreview.js +16 -2
- package/dist/cjs/components/InteractionSuffix.js +115 -0
- package/dist/cjs/components/Render.liquid.js +21 -7
- package/dist/cjs/components/RenderPreview.js +1 -0
- package/dist/cjs/components/constant.js +2 -1
- package/dist/cjs/contexts/PageContext.js +29 -1
- package/dist/cjs/contexts/SectionContext.js +0 -1
- package/dist/cjs/graphql/fragments/product-little.generated.js +1 -0
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +8 -0
- package/dist/cjs/graphql-app-api/queries/ShopLibraryPage.generated.js +17 -0
- package/dist/cjs/helpers/align.js +19 -0
- package/dist/cjs/helpers/animations.js +6 -6
- package/dist/cjs/helpers/background.js +1 -1
- package/dist/cjs/helpers/colors.js +1 -1
- package/dist/cjs/helpers/interaction/index.js +66 -0
- package/dist/cjs/helpers/render.js +2 -0
- package/dist/cjs/helpers/shadow.js +1 -1
- package/dist/cjs/helpers/third-party/appConfig.js +28 -0
- package/dist/cjs/helpers/third-party/appSetting.js +66 -0
- package/dist/cjs/helpers/third-party/constant.js +5 -1
- package/dist/cjs/helpers/typography.js +9 -5
- package/dist/cjs/hooks/animation/useApplyAnimation.js +2 -0
- package/dist/cjs/hooks/useFormatMoney.js +61 -60
- package/dist/cjs/hooks/useInteraction.js +19 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/types/animations.js +2 -0
- package/dist/cjs/types/custom.js +51 -0
- package/dist/esm/components/ComponentToolbarPreview.js +115 -104
- package/dist/esm/components/ComponentWrapperPreview.js +16 -2
- package/dist/esm/components/InteractionSuffix.js +113 -0
- package/dist/esm/components/Render.liquid.js +21 -7
- package/dist/esm/components/RenderPreview.js +1 -0
- package/dist/esm/components/constant.js +2 -1
- package/dist/esm/contexts/PageContext.js +29 -1
- package/dist/esm/contexts/SectionContext.js +0 -1
- package/dist/esm/graphql/fragments/product-little.generated.js +1 -0
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +8 -0
- package/dist/esm/graphql-app-api/queries/ShopLibraryPage.generated.js +15 -0
- package/dist/esm/helpers/align.js +17 -0
- package/dist/esm/helpers/animations.js +6 -6
- package/dist/esm/helpers/background.js +1 -1
- package/dist/esm/helpers/colors.js +1 -1
- package/dist/esm/helpers/interaction/index.js +64 -0
- package/dist/esm/helpers/render.js +2 -0
- package/dist/esm/helpers/shadow.js +1 -1
- package/dist/esm/helpers/third-party/appConfig.js +25 -1
- package/dist/esm/helpers/third-party/appSetting.js +66 -0
- package/dist/esm/helpers/third-party/constant.js +6 -2
- package/dist/esm/helpers/typography.js +9 -5
- package/dist/esm/hooks/animation/useApplyAnimation.js +2 -0
- package/dist/esm/hooks/useFormatMoney.js +61 -61
- package/dist/esm/hooks/useInteraction.js +17 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/types/animations.js +2 -0
- package/dist/esm/types/custom.js +51 -0
- package/dist/types/index.d.ts +3408 -747
- package/package.json +3 -3
|
@@ -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
|
},
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
themePageCustomFonts {
|
|
27
27
|
...CustomFontSelect
|
|
28
28
|
}
|
|
29
|
+
interaction {
|
|
30
|
+
id
|
|
31
|
+
value
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
`;
|
|
31
35
|
const PreviewThemePageSelect = `
|
|
@@ -53,6 +57,10 @@ const PreviewThemePageSelect = `
|
|
|
53
57
|
themePageCustomCode {
|
|
54
58
|
...CustomCodeSelect
|
|
55
59
|
}
|
|
60
|
+
interaction {
|
|
61
|
+
id
|
|
62
|
+
value
|
|
63
|
+
}
|
|
56
64
|
}
|
|
57
65
|
`;
|
|
58
66
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* eslint-disable */ const ShopLibraryPageDocument = `
|
|
2
|
+
query ShopLibraryPage($shopLibraryPageId: ID!) {
|
|
3
|
+
shopLibraryPage(id: $shopLibraryPageId) {
|
|
4
|
+
id
|
|
5
|
+
name
|
|
6
|
+
sectionPosition
|
|
7
|
+
shopLibrarySections {
|
|
8
|
+
id
|
|
9
|
+
component
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export { ShopLibraryPageDocument };
|
|
@@ -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 };
|
|
@@ -44,7 +44,7 @@ const animations = ()=>{
|
|
|
44
44
|
});
|
|
45
45
|
return cloneOptions;
|
|
46
46
|
};
|
|
47
|
-
const slide = (target, options)=>{
|
|
47
|
+
const slide = (target, options, reverse)=>{
|
|
48
48
|
const normalizedOptions = normalizeOptions(options);
|
|
49
49
|
const { direction, distance } = normalizedOptions;
|
|
50
50
|
const coordinate = [
|
|
@@ -65,11 +65,11 @@ const animations = ()=>{
|
|
|
65
65
|
transform: `translate${coordinate}(0)`
|
|
66
66
|
}
|
|
67
67
|
];
|
|
68
|
-
return generateAnimationInstance(target, preset, {
|
|
68
|
+
return generateAnimationInstance(target, reverse ? preset.reverse() : preset, {
|
|
69
69
|
...generateOptions(normalizedOptions, 500)
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
|
-
const fade = (target, options)=>{
|
|
72
|
+
const fade = (target, options, reverse)=>{
|
|
73
73
|
const normalizedOptions = normalizeOptions(options);
|
|
74
74
|
const preset = [
|
|
75
75
|
{
|
|
@@ -79,7 +79,7 @@ const animations = ()=>{
|
|
|
79
79
|
opacity: 1
|
|
80
80
|
}
|
|
81
81
|
];
|
|
82
|
-
return generateAnimationInstance(target, preset, {
|
|
82
|
+
return generateAnimationInstance(target, reverse ? preset.reverse() : preset, {
|
|
83
83
|
...generateOptions(normalizedOptions, 500)
|
|
84
84
|
});
|
|
85
85
|
};
|
|
@@ -99,7 +99,7 @@ const animations = ()=>{
|
|
|
99
99
|
easing: EASING[easing ?? 'linear']
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
-
const zoom = (target, options)=>{
|
|
102
|
+
const zoom = (target, options, reverse)=>{
|
|
103
103
|
const normalizedOptions = normalizeOptions(options);
|
|
104
104
|
const { scale, zoomDirection, isFade } = normalizedOptions;
|
|
105
105
|
const [i1, i2] = scale.in;
|
|
@@ -125,7 +125,7 @@ const animations = ()=>{
|
|
|
125
125
|
}
|
|
126
126
|
];
|
|
127
127
|
const zoomPreset = zoomDirection === 'in' ? zoomInPreset : zoomOutPreset;
|
|
128
|
-
return generateAnimationInstance(target, zoomPreset, {
|
|
128
|
+
return generateAnimationInstance(target, reverse ? zoomPreset.reverse() : zoomPreset, {
|
|
129
129
|
...generateOptions(normalizedOptions, 700)
|
|
130
130
|
});
|
|
131
131
|
};
|
|
@@ -119,7 +119,7 @@ const getBgAttachmentByDevice = (background, device)=>{
|
|
|
119
119
|
return background?.[device]?.attachment;
|
|
120
120
|
};
|
|
121
121
|
const composeBackgroundCss = (backgroundColor)=>{
|
|
122
|
-
return `${backgroundColor ? `background-color: ${getSingleColorVariable(backgroundColor)}
|
|
122
|
+
return `${backgroundColor ? `background-color: ${getSingleColorVariable(backgroundColor)};` : undefined}`;
|
|
123
123
|
};
|
|
124
124
|
const makeFixedBgAttachment = (background)=>{
|
|
125
125
|
if (!background) return;
|
|
@@ -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));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import 'react/jsx-runtime';
|
|
2
|
+
import 'zustand';
|
|
3
|
+
import 'react';
|
|
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 '../convert.js';
|
|
16
|
+
|
|
17
|
+
const useInteraction = ()=>{
|
|
18
|
+
const setInteractionIsSelectOnPage = usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
19
|
+
const onListener = ({ event, selector }, callback)=>{
|
|
20
|
+
const element = document.querySelector(selector);
|
|
21
|
+
if (!element) return;
|
|
22
|
+
element.addEventListener(event, (e)=>{
|
|
23
|
+
const event = e;
|
|
24
|
+
const params = event.detail;
|
|
25
|
+
if (callback) callback(params);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const trigger = ({ event, data, selector })=>{
|
|
29
|
+
const element = document.querySelector(selector);
|
|
30
|
+
if (!element) return;
|
|
31
|
+
const eventDispatch = new CustomEvent(event, {
|
|
32
|
+
bubbles: false,
|
|
33
|
+
cancelable: true,
|
|
34
|
+
detail: {
|
|
35
|
+
data
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
element.dispatchEvent(eventDispatch);
|
|
39
|
+
};
|
|
40
|
+
const saveToElementInteractionData = (element, key, value)=>{
|
|
41
|
+
const interactionData = element.getAttribute('gp-data-interaction');
|
|
42
|
+
const interactionDataJson = JSON.parse(interactionData || '{}');
|
|
43
|
+
element.setAttribute('gp-data-interaction', JSON.stringify({
|
|
44
|
+
...interactionDataJson,
|
|
45
|
+
[key]: value
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
const closeSelectOnPage = ()=>{
|
|
49
|
+
setInteractionIsSelectOnPage(false);
|
|
50
|
+
const event = new CustomEvent('editor:interaction:change-select-on-page', {
|
|
51
|
+
bubbles: true,
|
|
52
|
+
detail: false
|
|
53
|
+
});
|
|
54
|
+
window.dispatchEvent(event);
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
onListener,
|
|
58
|
+
trigger,
|
|
59
|
+
saveToElementInteractionData,
|
|
60
|
+
closeSelectOnPage
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { useInteraction };
|
|
@@ -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)=>{
|
|
@@ -76,5 +76,29 @@ const SimpleBundlesKitsConfig = {
|
|
|
76
76
|
appId: 'e553276b-36b2-446d-b80a-aa47fe5f96ac'
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
+
const EasyBundleBuilderSkailamaConfig = {
|
|
80
|
+
EasyBundleBuilderSkailama: {
|
|
81
|
+
appName: 'easy-bundles',
|
|
82
|
+
appId: '05b1325c-6303-4da5-8e2f-b13ab2a50e1a'
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const PreorderNowPreOrderPqConfig = {
|
|
86
|
+
PreorderNowPreOrderPq: {
|
|
87
|
+
appName: 'preorder-now-pre-order-pq',
|
|
88
|
+
appId: '551fab2c-3af6-4a8f-ba21-736a71cb4540'
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const FlyBundlesUpsellsFbtConfig = {
|
|
92
|
+
FlyBundlesUpsellsFbt: {
|
|
93
|
+
appName: 'fly-bundles-upsell',
|
|
94
|
+
appId: '26807bdc-c2ed-4a25-afb2-06e6b1ebf843'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const JunipProductReviewsUgcConfig = {
|
|
98
|
+
JunipProductReviewsUgc: {
|
|
99
|
+
appName: 'junip-product-reviews-ugc',
|
|
100
|
+
appId: 'dc14f5a8-ed15-41b1-ad08-cfba23f9789b'
|
|
101
|
+
}
|
|
102
|
+
};
|
|
79
103
|
|
|
80
|
-
export { BonLoyaltyRewardsReferralsConfig, FastBundleBundlesDiscountsConfig, KiteFreeGiftDiscountConfig, LoopSubscriptionsConfig, PumperBundlesVolumeDiscountConfig, RechargeSubscriptionsConfig, ReviewxpoProductReviewsAppConfig, SelleasyConfig, ShopifyFormsConfig, SimpleBundlesKitsConfig, SkioSubscriptionsYcS20Config, SubifySubscriptionsConfig, UnlimitedBundlesDiscountsConfig };
|
|
104
|
+
export { BonLoyaltyRewardsReferralsConfig, EasyBundleBuilderSkailamaConfig, FastBundleBundlesDiscountsConfig, FlyBundlesUpsellsFbtConfig, JunipProductReviewsUgcConfig, KiteFreeGiftDiscountConfig, LoopSubscriptionsConfig, PreorderNowPreOrderPqConfig, PumperBundlesVolumeDiscountConfig, RechargeSubscriptionsConfig, ReviewxpoProductReviewsAppConfig, SelleasyConfig, ShopifyFormsConfig, SimpleBundlesKitsConfig, SkioSubscriptionsYcS20Config, SubifySubscriptionsConfig, UnlimitedBundlesDiscountsConfig };
|
|
@@ -79,6 +79,13 @@ const overrideSettings = (tag, currentSetting, appSetting)=>{
|
|
|
79
79
|
...currentSetting,
|
|
80
80
|
form_id: appSetting['formId']
|
|
81
81
|
};
|
|
82
|
+
case 'FlyBundlesUpsellsFbt':
|
|
83
|
+
{
|
|
84
|
+
return {
|
|
85
|
+
...currentSetting,
|
|
86
|
+
bundle_id: appSetting?.['customBundleId']
|
|
87
|
+
};
|
|
88
|
+
}
|
|
82
89
|
default:
|
|
83
90
|
return currentSetting;
|
|
84
91
|
}
|
|
@@ -127,7 +134,66 @@ const SimpleBundlesKits = {
|
|
|
127
134
|
'infinite-options-selector': null
|
|
128
135
|
}
|
|
129
136
|
};
|
|
137
|
+
const EasyBundleBuilderSkailama = {
|
|
138
|
+
EasyBundleBuilderSkailama: {
|
|
139
|
+
'app-block-bundlePage': null
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const PreorderNowPreOrderPq = {
|
|
143
|
+
PreorderNowPreOrderPq: {
|
|
144
|
+
'app-block-notifyapp-block-notify': null,
|
|
145
|
+
'app-block-partial': null,
|
|
146
|
+
'app-block-timer': null,
|
|
147
|
+
'app-block': null
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const FlyBundlesUpsellsFbt = {
|
|
151
|
+
FlyBundlesUpsellsFbt: {
|
|
152
|
+
'app-block-volume': null,
|
|
153
|
+
'app-block-upsell-block': null,
|
|
154
|
+
'app-block-fbt': null,
|
|
155
|
+
'app-block-custom': {
|
|
156
|
+
bundle_id: ''
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const JunipProductReviewsUgc = {
|
|
161
|
+
JunipProductReviewsUgc: {
|
|
162
|
+
'junip-review-carousel': {
|
|
163
|
+
reviewsType: 'product_reviews',
|
|
164
|
+
showSummary: true,
|
|
165
|
+
title: 'Reviews',
|
|
166
|
+
paddingTop: 48,
|
|
167
|
+
paddingBottom: 48,
|
|
168
|
+
containerClass: ''
|
|
169
|
+
},
|
|
170
|
+
'junip-ugc-gallery': {
|
|
171
|
+
layout: 'scroll',
|
|
172
|
+
title: '',
|
|
173
|
+
paddingTop: 48,
|
|
174
|
+
paddingBottom: 48,
|
|
175
|
+
containerClass: ''
|
|
176
|
+
},
|
|
177
|
+
'junip-product-review': {
|
|
178
|
+
product: '{{product}}'
|
|
179
|
+
},
|
|
180
|
+
'junip-product-summary': {
|
|
181
|
+
product: '{{product}}'
|
|
182
|
+
},
|
|
183
|
+
'junip-reviews': {
|
|
184
|
+
layout: 'list',
|
|
185
|
+
reviewsType: 'all',
|
|
186
|
+
showSummary: true,
|
|
187
|
+
reviewsCount: 10,
|
|
188
|
+
containerClass: ''
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
130
192
|
const composeSettingsByWidgetType = {
|
|
193
|
+
...JunipProductReviewsUgc,
|
|
194
|
+
...FlyBundlesUpsellsFbt,
|
|
195
|
+
...PreorderNowPreOrderPq,
|
|
196
|
+
...EasyBundleBuilderSkailama,
|
|
131
197
|
...FastBundleBundlesDiscounts,
|
|
132
198
|
...KiteFreeGiftDiscount,
|
|
133
199
|
...UnlimitedBundlesDiscounts,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RechargeSubscriptionsConfig, BonLoyaltyRewardsReferralsConfig, SubifySubscriptionsConfig, SelleasyConfig, LoopSubscriptionsConfig, SkioSubscriptionsYcS20Config, ShopifyFormsConfig, ReviewxpoProductReviewsAppConfig, PumperBundlesVolumeDiscountConfig, UnlimitedBundlesDiscountsConfig, KiteFreeGiftDiscountConfig, FastBundleBundlesDiscountsConfig, SimpleBundlesKitsConfig } from './appConfig.js';
|
|
1
|
+
import { RechargeSubscriptionsConfig, BonLoyaltyRewardsReferralsConfig, SubifySubscriptionsConfig, SelleasyConfig, LoopSubscriptionsConfig, SkioSubscriptionsYcS20Config, ShopifyFormsConfig, ReviewxpoProductReviewsAppConfig, PumperBundlesVolumeDiscountConfig, UnlimitedBundlesDiscountsConfig, KiteFreeGiftDiscountConfig, FastBundleBundlesDiscountsConfig, SimpleBundlesKitsConfig, EasyBundleBuilderSkailamaConfig, PreorderNowPreOrderPqConfig, FlyBundlesUpsellsFbtConfig, JunipProductReviewsUgcConfig } from './appConfig.js';
|
|
2
2
|
|
|
3
3
|
const mapShopifyAppMeta = {
|
|
4
4
|
...RechargeSubscriptionsConfig,
|
|
@@ -13,7 +13,11 @@ const mapShopifyAppMeta = {
|
|
|
13
13
|
...UnlimitedBundlesDiscountsConfig,
|
|
14
14
|
...KiteFreeGiftDiscountConfig,
|
|
15
15
|
...FastBundleBundlesDiscountsConfig,
|
|
16
|
-
...SimpleBundlesKitsConfig
|
|
16
|
+
...SimpleBundlesKitsConfig,
|
|
17
|
+
...EasyBundleBuilderSkailamaConfig,
|
|
18
|
+
...PreorderNowPreOrderPqConfig,
|
|
19
|
+
...FlyBundlesUpsellsFbtConfig,
|
|
20
|
+
...JunipProductReviewsUgcConfig
|
|
17
21
|
};
|
|
18
22
|
const THIRD_PARTY_APP_BLOCK_ID_PREFIX = 'gp_app';
|
|
19
23
|
|
|
@@ -26,7 +26,8 @@ const composeTypographyV2Css = (typography, isImportant)=>{
|
|
|
26
26
|
const composeImportant = isImportant ? '!important' : '';
|
|
27
27
|
return `
|
|
28
28
|
${fontFamily ? `font-family: ${composeFontFamilyTypographyV2({
|
|
29
|
-
fontFamily
|
|
29
|
+
fontFamily,
|
|
30
|
+
type: typography?.type
|
|
30
31
|
})} ${composeImportant}` : ''};
|
|
31
32
|
${fontSize?.desktop ? `font-size: ${fontSize?.desktop} ${composeImportant}` : ''};
|
|
32
33
|
${bold ? `font-weight: bold ${composeImportant}` : fontWeight ? `font-weight: ${fontWeight} ${composeImportant}` : ''};
|
|
@@ -74,7 +75,7 @@ const composeTypographyV2 = (value, attrs)=>{
|
|
|
74
75
|
});
|
|
75
76
|
};
|
|
76
77
|
const composeFontFamilyTypographyV2 = (value)=>{
|
|
77
|
-
const { fontFamily, isCustom, fallbackFontFamily } = value || {};
|
|
78
|
+
const { fontFamily, isCustom, fallbackFontFamily, type } = value || {};
|
|
78
79
|
if (!fontFamily) {
|
|
79
80
|
return isCustom ? fallbackFontFamily : undefined;
|
|
80
81
|
}
|
|
@@ -91,7 +92,7 @@ const composeFontFamilyTypographyV2 = (value)=>{
|
|
|
91
92
|
default:
|
|
92
93
|
return getFontUsedByTypographyV2({
|
|
93
94
|
fontFamily: fontFamily.value,
|
|
94
|
-
fallbackFontFamily:
|
|
95
|
+
fallbackFontFamily: composeFallbackTypographyStyle(type ?? 'heading')
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -116,7 +117,7 @@ const composeTypographyAttr = (attrs)=>{
|
|
|
116
117
|
});
|
|
117
118
|
};
|
|
118
119
|
const composeTypographyClassName = (typo, typography)=>{
|
|
119
|
-
return typo ? typo?.type && !typo.custom ? genTypoClass(typo.type) : '' : typography?.type && genTypoClass(typography?.type);
|
|
120
|
+
return typo ? typo?.type && !isCustomTypo(typo.custom) ? genTypoClass(typo.type) : '' : typography?.type && genTypoClass(typography?.type);
|
|
120
121
|
};
|
|
121
122
|
const composeFallbackTypographyStyle = (tag)=>{
|
|
122
123
|
if (tag.toLocaleLowerCase().includes('heading')) {
|
|
@@ -130,7 +131,7 @@ const composeTypographyStyle = (typo, typography, disableAttr)=>{
|
|
|
130
131
|
const customTypo = {
|
|
131
132
|
...typo.custom,
|
|
132
133
|
fallbackFontFamily: fallbackFontFamily,
|
|
133
|
-
isCustom:
|
|
134
|
+
isCustom: isCustomTypo(typo.custom)
|
|
134
135
|
};
|
|
135
136
|
return {
|
|
136
137
|
...composeTypographyV2(customTypo, typo.attrs),
|
|
@@ -141,5 +142,8 @@ const composeTypographyStyle = (typo, typography, disableAttr)=>{
|
|
|
141
142
|
...!typography?.type ? composeTypography(typography?.custom) : {}
|
|
142
143
|
};
|
|
143
144
|
};
|
|
145
|
+
const isCustomTypo = (customTypo)=>{
|
|
146
|
+
return customTypo && Object.keys(customTypo).length > 1 || customTypo && Object.keys(customTypo).length === 1 && !customTypo.fontSize;
|
|
147
|
+
};
|
|
144
148
|
|
|
145
149
|
export { composeFallbackTypographyStyle, composeFontFamilyTypographyV2, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, genTypoClass };
|
|
@@ -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 })=>{
|
|
@@ -36,6 +37,7 @@ const useApplyAnimation = ({ props })=>{
|
|
|
36
37
|
setting,
|
|
37
38
|
target: item.target
|
|
38
39
|
}));
|
|
40
|
+
console.log('listAnimations', listAnimations);
|
|
39
41
|
cancelAnimation();
|
|
40
42
|
setAnimation(listAnimations);
|
|
41
43
|
}, [
|
|
@@ -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
|
@@ -28,6 +28,7 @@ export { LibraryTemplateDocument } from './graphql-app-api/queries/LibraryTempla
|
|
|
28
28
|
export { ThemePageDocument } from './graphql-app-api/queries/ThemePage.generated.js';
|
|
29
29
|
export { SaleFunnelDiscountsDocument } from './graphql-app-api/queries/SaleFunnelDiscounts.generated.js';
|
|
30
30
|
export { LibrarySaleFunnelDocument } from './graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js';
|
|
31
|
+
export { ShopLibraryPageDocument } from './graphql-app-api/queries/ShopLibraryPage.generated.js';
|
|
31
32
|
export { composeBorderCss, getBorderRadiusStyle, getBorderStyle, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, handleConvertClassColorDynamicBtn } from './helpers/borders.js';
|
|
32
33
|
export { getCarouselContainerHeight, makeContainerWidthOrHeight, makeDotGapToCarouselStyle } from './helpers/carousel.js';
|
|
33
34
|
export { cls } from './helpers/cls.js';
|
|
@@ -61,6 +62,7 @@ export { composePositionLineHeight, composePostionIconList } from './helpers/ico
|
|
|
61
62
|
export { isDefined } from './helpers/is-defined.js';
|
|
62
63
|
export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle } from './helpers/layout.js';
|
|
63
64
|
export { makeAspectRatio, makeGlobalSizeHeightResponsive, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveByScreen, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined } from './helpers/make-style.js';
|
|
65
|
+
export { convertTextAlignToJustify } from './helpers/align.js';
|
|
64
66
|
export { checkAvailableVariantInStock, getSelectedVariant, parseSelectedOption } from './helpers/product.js';
|
|
65
67
|
export { generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey } from './helpers/query.js';
|
|
66
68
|
export { composeCornerCss, composeRadius, composeRadiusResponsive, getCornerCSSFromGlobal, getCustomRadius, getRadiusCSSFromGlobal, getRadiusStyleActiveState } from './helpers/radius.js';
|
|
@@ -81,7 +83,7 @@ export { useCollectionsQuery } from './hooks/shop/use-collections-query.js';
|
|
|
81
83
|
export { useProductQuery } from './hooks/shop/use-product-query.js';
|
|
82
84
|
export { useProductsQuery, useProductsQueryAll } from './hooks/shop/use-products-query.js';
|
|
83
85
|
export { useCurrentDevice } from './hooks/use-current-device.js';
|
|
84
|
-
export { shopifyPriceRounding, useFormatMoney } from './hooks/useFormatMoney.js';
|
|
86
|
+
export { formatMoney, shopifyPriceRounding, useFormatMoney } from './hooks/useFormatMoney.js';
|
|
85
87
|
export { useLazyVideo } from './hooks/use-lazy-video.js';
|
|
86
88
|
export { default as useCartId } from './hooks/useCartId.js';
|
|
87
89
|
export { default as useCartLine } from './hooks/useCartLine.js';
|
|
@@ -98,6 +100,7 @@ export { useProductList, useProductListProducts, useProductListSettings, useProd
|
|
|
98
100
|
export { default as useSuspenseFetch } from './hooks/useSuspenseFetch.js';
|
|
99
101
|
export { default as useSwatchesOptions } from './hooks/useSwatchesOptions.js';
|
|
100
102
|
export { default as useInitialSwatchesOptions } from './hooks/useInitialSwatchesOptions.js';
|
|
103
|
+
export { InteractionTargetEvent, InteractionTriggerEvent } from './types/custom.js';
|
|
101
104
|
import * as shop from './types/shop.js';
|
|
102
105
|
export { shop as ShopType };
|
|
103
106
|
import * as appAPI from './types/appAPI.js';
|
|
@@ -109,3 +112,4 @@ export { fetchMedias, fetchVariants, getProduct } from './helpers/queries/get-pr
|
|
|
109
112
|
export { getProductBySlug } from './helpers/queries/get-product-by-slug.js';
|
|
110
113
|
export { getAppBlocks } from './helpers/third-party/getAppBlocks.js';
|
|
111
114
|
export { addAppBlockId } from './helpers/third-party/addAppBlockId.js';
|
|
115
|
+
export { useInteraction } from './helpers/interaction/index.js';
|