@gem-sdk/core 1.50.2 → 1.51.0-staging.60
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/RenderPreview.js +1 -0
- package/dist/cjs/components/constant.js +2 -1
- package/dist/cjs/contexts/SectionContext.js +0 -1
- package/dist/cjs/graphql/fragments/product-little.generated.js +1 -0
- package/dist/cjs/helpers/align.js +19 -0
- package/dist/cjs/helpers/colors.js +1 -1
- package/dist/cjs/helpers/compose-advance-style.js +6 -3
- package/dist/cjs/helpers/shadow.js +15 -3
- package/dist/cjs/helpers/third-party/appConfig.js +35 -0
- package/dist/cjs/helpers/third-party/appSetting.js +73 -0
- package/dist/cjs/helpers/third-party/constant.js +6 -1
- package/dist/cjs/helpers/typography.js +9 -5
- package/dist/cjs/hooks/useFormatMoney.js +61 -60
- package/dist/cjs/index.js +4 -0
- package/dist/esm/components/RenderPreview.js +1 -0
- package/dist/esm/components/constant.js +2 -1
- package/dist/esm/contexts/SectionContext.js +0 -1
- package/dist/esm/graphql/fragments/product-little.generated.js +1 -0
- package/dist/esm/helpers/align.js +17 -0
- package/dist/esm/helpers/colors.js +1 -1
- package/dist/esm/helpers/compose-advance-style.js +7 -4
- package/dist/esm/helpers/shadow.js +15 -4
- package/dist/esm/helpers/third-party/appConfig.js +31 -1
- package/dist/esm/helpers/third-party/appSetting.js +73 -0
- package/dist/esm/helpers/third-party/constant.js +7 -2
- package/dist/esm/helpers/typography.js +9 -5
- package/dist/esm/hooks/useFormatMoney.js +61 -61
- package/dist/esm/index.js +3 -2
- package/dist/types/index.d.ts +1789 -50
- package/package.json +3 -3
|
@@ -45,6 +45,7 @@ const RenderPreview = ({ uid, ...passProps })=>{
|
|
|
45
45
|
setting: item.settings,
|
|
46
46
|
...passProps,
|
|
47
47
|
children: item.childrens.map((id)=>/*#__PURE__*/ jsxRuntime.jsx(RenderPreviewMemo, {
|
|
48
|
+
"bundle-item": passProps?.['bundle-item'],
|
|
48
49
|
uid: id
|
|
49
50
|
}, id))
|
|
50
51
|
}) : /*#__PURE__*/ jsxRuntime.jsx(Component, {
|
|
@@ -10,7 +10,6 @@ const SectionContext = /*#__PURE__*/ react.createContext(null);
|
|
|
10
10
|
const createSectionProvider = (data)=>zustand.createStore((set, get)=>({
|
|
11
11
|
data: data ?? {},
|
|
12
12
|
getSection: (id)=>{
|
|
13
|
-
console.log('get().data', get().data);
|
|
14
13
|
const section = get().data[id];
|
|
15
14
|
return section ?? undefined;
|
|
16
15
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const convertTextAlignToJustify = (align)=>{
|
|
4
|
+
const devices = [
|
|
5
|
+
'desktop',
|
|
6
|
+
'tablet',
|
|
7
|
+
'mobile'
|
|
8
|
+
];
|
|
9
|
+
const result = {};
|
|
10
|
+
devices.forEach((device)=>{
|
|
11
|
+
const deviceType = device === 'desktop' ? '' : `${device}:`;
|
|
12
|
+
result[`${deviceType}gp-justify-start`] = align?.[device] === 'left';
|
|
13
|
+
result[`${deviceType}gp-justify-center`] = align?.[device] === 'center';
|
|
14
|
+
result[`${deviceType}gp-justify-end`] = align?.[device] === 'right';
|
|
15
|
+
});
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.convertTextAlignToJustify = convertTextAlignToJustify;
|
|
@@ -119,7 +119,7 @@ const getGlobalColorStateStyle = (type, data)=>{
|
|
|
119
119
|
return Object.fromEntries(Object.entries(data).map(([state, value])=>{
|
|
120
120
|
if (state === 'active') return [];
|
|
121
121
|
return [
|
|
122
|
-
`-${constant.stateMapping?.[state]}-${type}`,
|
|
122
|
+
`-${constant.stateMapping?.[state] || ''}-${type}`,
|
|
123
123
|
getSingleColorVariable(value)
|
|
124
124
|
];
|
|
125
125
|
}).filter(isDefined.isDefined));
|
|
@@ -101,6 +101,9 @@ function composeAdvanceStyle(data, tag, pageType) {
|
|
|
101
101
|
if (attr === 'rounded') {
|
|
102
102
|
Object.assign(styles, radius.composeRadius(value));
|
|
103
103
|
}
|
|
104
|
+
if (attr === 'boxShadow') {
|
|
105
|
+
Object.assign(styles, shadow.getResonsiveStyleShadow(value, 'box-shadow', hasBoxShadow));
|
|
106
|
+
}
|
|
104
107
|
if (composeAttr === 'desktop') {
|
|
105
108
|
switch(attr){
|
|
106
109
|
case 'padding':
|
|
@@ -215,20 +218,20 @@ function composeAdvanceStyle(data, tag, pageType) {
|
|
|
215
218
|
}));
|
|
216
219
|
}
|
|
217
220
|
}
|
|
218
|
-
if (attr === 'blockPadding' && pageType ===
|
|
221
|
+
if (attr === 'blockPadding' && pageType === 'POST_PURCHASE') {
|
|
219
222
|
const valueMapped = postPurchasePaddingMapping[value];
|
|
220
223
|
styles[`--pb`] = getAttrValue(attr, valueMapped, tag);
|
|
221
224
|
styles[`--pt`] = getAttrValue(attr, valueMapped, tag);
|
|
222
225
|
styles[`--mb`] = '0px';
|
|
223
226
|
styles[`--mt`] = '0px';
|
|
224
227
|
}
|
|
225
|
-
if (attr === 'inlinePadding' && pageType ===
|
|
228
|
+
if (attr === 'inlinePadding' && pageType === 'POST_PURCHASE') {
|
|
226
229
|
const valueMapped = postPurchasePaddingMapping[value];
|
|
227
230
|
styles[`--pl`] = getAttrValue(attr, valueMapped, tag);
|
|
228
231
|
styles[`--pr`] = getAttrValue(attr, valueMapped, tag);
|
|
229
232
|
}
|
|
230
233
|
});
|
|
231
|
-
const advancedPostPurchaseStyles = pageType ===
|
|
234
|
+
const advancedPostPurchaseStyles = pageType === 'POST_PURCHASE' ? composeAdvanceStyleForPostPurchase(data, tag) : {};
|
|
232
235
|
return {
|
|
233
236
|
...styles,
|
|
234
237
|
...advancedPostPurchaseStyles
|
|
@@ -27,10 +27,10 @@ const getStyleShadow = (shadowStyle, isActiveState = false)=>{
|
|
|
27
27
|
if (typeof value.distance == 'undefined') return {};
|
|
28
28
|
const { value: distance, unit: unitDistance } = parseValueWithUnit(`${value?.distance}`);
|
|
29
29
|
return {
|
|
30
|
-
[`-${!isActiveState ? constant.stateMapping?.[state] : ''}-${getShortname.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 + ' ' : ''}${colors.getSingleColorVariable(value?.color)}` : 'none'
|
|
30
|
+
[`-${!isActiveState ? constant.stateMapping?.[state] || '' : ''}-${getShortname.getShortName(styleAppliedFor)}${shadowStyle.screen ? `-${shadowStyle.screen}` : ''}`]: 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 + ' ' : ''}${colors.getSingleColorVariable(value?.color)}` : 'none'
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
|
|
33
|
+
const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow, screen)=>{
|
|
34
34
|
if (!shadow || !styleAppliedFor) return {};
|
|
35
35
|
const style = {};
|
|
36
36
|
for (const [key, value] of Object.entries(shadow)){
|
|
@@ -38,11 +38,22 @@ const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
|
|
|
38
38
|
value: value,
|
|
39
39
|
state: key,
|
|
40
40
|
styleAppliedFor,
|
|
41
|
-
isEnableShadow: isEnableShadow?.[key]
|
|
41
|
+
isEnableShadow: isEnableShadow?.[key],
|
|
42
|
+
screen: screen ?? ''
|
|
42
43
|
}));
|
|
43
44
|
}
|
|
44
45
|
return style;
|
|
45
46
|
};
|
|
47
|
+
const getResonsiveStyleShadow = (value, styleAppliedFor, isEnableShadow)=>{
|
|
48
|
+
if (!value) return undefined;
|
|
49
|
+
if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
|
|
50
|
+
return {
|
|
51
|
+
...getStyleShadowState(value.desktop, styleAppliedFor, isEnableShadow.desktop),
|
|
52
|
+
...value.tablet && (isEnableShadow.tablet ?? isEnableShadow.desktop) ? getStyleShadowState(value.tablet, styleAppliedFor, isEnableShadow.tablet ?? isEnableShadow.desktop, 'tablet') : undefined,
|
|
53
|
+
...value.mobile && (isEnableShadow.mobile ?? isEnableShadow.tablet ?? isEnableShadow.desktop) ? getStyleShadowState(value.mobile, styleAppliedFor, isEnableShadow.mobile ?? isEnableShadow.tablet ?? isEnableShadow.desktop, 'mobile') : undefined
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
46
57
|
const composeShadowCss = ({ hasBoxShadow, boxShadowValue, important })=>{
|
|
47
58
|
if (!hasBoxShadow) return undefined;
|
|
48
59
|
if (!boxShadowValue) return undefined;
|
|
@@ -52,6 +63,7 @@ const composeShadowCss = ({ hasBoxShadow, boxShadowValue, important })=>{
|
|
|
52
63
|
};
|
|
53
64
|
|
|
54
65
|
exports.composeShadowCss = composeShadowCss;
|
|
66
|
+
exports.getResonsiveStyleShadow = getResonsiveStyleShadow;
|
|
55
67
|
exports.getStyleShadow = getStyleShadow;
|
|
56
68
|
exports.getStyleShadowState = getStyleShadowState;
|
|
57
69
|
exports.parseValueWithUnit = parseValueWithUnit;
|
|
@@ -78,11 +78,46 @@ const SimpleBundlesKitsConfig = {
|
|
|
78
78
|
appId: 'e553276b-36b2-446d-b80a-aa47fe5f96ac'
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
+
const EasyBundleBuilderSkailamaConfig = {
|
|
82
|
+
EasyBundleBuilderSkailama: {
|
|
83
|
+
appName: 'easy-bundles',
|
|
84
|
+
appId: '05b1325c-6303-4da5-8e2f-b13ab2a50e1a'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const PreorderNowPreOrderPqConfig = {
|
|
88
|
+
PreorderNowPreOrderPq: {
|
|
89
|
+
appName: 'preorder-now-pre-order-pq',
|
|
90
|
+
appId: '551fab2c-3af6-4a8f-ba21-736a71cb4540'
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const FlyBundlesUpsellsFbtConfig = {
|
|
94
|
+
FlyBundlesUpsellsFbt: {
|
|
95
|
+
appName: 'fly-bundles-upsell',
|
|
96
|
+
appId: '26807bdc-c2ed-4a25-afb2-06e6b1ebf843'
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const JunipProductReviewsUgcConfig = {
|
|
100
|
+
JunipProductReviewsUgc: {
|
|
101
|
+
appName: 'junip-product-reviews-ugc',
|
|
102
|
+
appId: 'dc14f5a8-ed15-41b1-ad08-cfba23f9789b'
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const PreorderNowWodPresaleConfig = {
|
|
106
|
+
PreorderNowWodPresale: {
|
|
107
|
+
appName: 'preorder-now-wod-presale',
|
|
108
|
+
appId: 'fdf17d17-ef12-4a7b-8383-20cc1fc2a4b6'
|
|
109
|
+
}
|
|
110
|
+
};
|
|
81
111
|
|
|
82
112
|
exports.BonLoyaltyRewardsReferralsConfig = BonLoyaltyRewardsReferralsConfig;
|
|
113
|
+
exports.EasyBundleBuilderSkailamaConfig = EasyBundleBuilderSkailamaConfig;
|
|
83
114
|
exports.FastBundleBundlesDiscountsConfig = FastBundleBundlesDiscountsConfig;
|
|
115
|
+
exports.FlyBundlesUpsellsFbtConfig = FlyBundlesUpsellsFbtConfig;
|
|
116
|
+
exports.JunipProductReviewsUgcConfig = JunipProductReviewsUgcConfig;
|
|
84
117
|
exports.KiteFreeGiftDiscountConfig = KiteFreeGiftDiscountConfig;
|
|
85
118
|
exports.LoopSubscriptionsConfig = LoopSubscriptionsConfig;
|
|
119
|
+
exports.PreorderNowPreOrderPqConfig = PreorderNowPreOrderPqConfig;
|
|
120
|
+
exports.PreorderNowWodPresaleConfig = PreorderNowWodPresaleConfig;
|
|
86
121
|
exports.PumperBundlesVolumeDiscountConfig = PumperBundlesVolumeDiscountConfig;
|
|
87
122
|
exports.RechargeSubscriptionsConfig = RechargeSubscriptionsConfig;
|
|
88
123
|
exports.ReviewxpoProductReviewsAppConfig = ReviewxpoProductReviewsAppConfig;
|
|
@@ -81,6 +81,13 @@ const overrideSettings = (tag, currentSetting, appSetting)=>{
|
|
|
81
81
|
...currentSetting,
|
|
82
82
|
form_id: appSetting['formId']
|
|
83
83
|
};
|
|
84
|
+
case 'FlyBundlesUpsellsFbt':
|
|
85
|
+
{
|
|
86
|
+
return {
|
|
87
|
+
...currentSetting,
|
|
88
|
+
bundle_id: appSetting?.['customBundleId']
|
|
89
|
+
};
|
|
90
|
+
}
|
|
84
91
|
default:
|
|
85
92
|
return currentSetting;
|
|
86
93
|
}
|
|
@@ -129,7 +136,73 @@ const SimpleBundlesKits = {
|
|
|
129
136
|
'infinite-options-selector': null
|
|
130
137
|
}
|
|
131
138
|
};
|
|
139
|
+
const EasyBundleBuilderSkailama = {
|
|
140
|
+
EasyBundleBuilderSkailama: {
|
|
141
|
+
'app-block-bundlePage': null
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const PreorderNowPreOrderPq = {
|
|
145
|
+
PreorderNowPreOrderPq: {
|
|
146
|
+
'app-block-notifyapp-block-notify': null,
|
|
147
|
+
'app-block-partial': null,
|
|
148
|
+
'app-block-timer': null,
|
|
149
|
+
'app-block': null
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const FlyBundlesUpsellsFbt = {
|
|
153
|
+
FlyBundlesUpsellsFbt: {
|
|
154
|
+
'app-block-volume': null,
|
|
155
|
+
'app-block-upsell-block': null,
|
|
156
|
+
'app-block-fbt': null,
|
|
157
|
+
'app-block-custom': {
|
|
158
|
+
bundle_id: ''
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const JunipProductReviewsUgc = {
|
|
163
|
+
JunipProductReviewsUgc: {
|
|
164
|
+
'junip-review-carousel': {
|
|
165
|
+
reviewsType: 'product_reviews',
|
|
166
|
+
showSummary: true,
|
|
167
|
+
title: 'Reviews',
|
|
168
|
+
paddingTop: 48,
|
|
169
|
+
paddingBottom: 48,
|
|
170
|
+
containerClass: ''
|
|
171
|
+
},
|
|
172
|
+
'junip-ugc-gallery': {
|
|
173
|
+
layout: 'scroll',
|
|
174
|
+
title: '',
|
|
175
|
+
paddingTop: 48,
|
|
176
|
+
paddingBottom: 48,
|
|
177
|
+
containerClass: ''
|
|
178
|
+
},
|
|
179
|
+
'junip-product-review': {
|
|
180
|
+
product: '{{product}}'
|
|
181
|
+
},
|
|
182
|
+
'junip-product-summary': {
|
|
183
|
+
product: '{{product}}'
|
|
184
|
+
},
|
|
185
|
+
'junip-reviews': {
|
|
186
|
+
layout: 'list',
|
|
187
|
+
reviewsType: 'all',
|
|
188
|
+
showSummary: true,
|
|
189
|
+
reviewsCount: 10,
|
|
190
|
+
containerClass: ''
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const PreorderNowWodPresale = {
|
|
195
|
+
PreorderNowWodPresale: {
|
|
196
|
+
'app-block': null,
|
|
197
|
+
'popups-block': null
|
|
198
|
+
}
|
|
199
|
+
};
|
|
132
200
|
const composeSettingsByWidgetType = {
|
|
201
|
+
...JunipProductReviewsUgc,
|
|
202
|
+
...FlyBundlesUpsellsFbt,
|
|
203
|
+
...PreorderNowWodPresale,
|
|
204
|
+
...PreorderNowPreOrderPq,
|
|
205
|
+
...EasyBundleBuilderSkailama,
|
|
133
206
|
...FastBundleBundlesDiscounts,
|
|
134
207
|
...KiteFreeGiftDiscount,
|
|
135
208
|
...UnlimitedBundlesDiscounts,
|
|
@@ -15,7 +15,12 @@ const mapShopifyAppMeta = {
|
|
|
15
15
|
...appConfig.UnlimitedBundlesDiscountsConfig,
|
|
16
16
|
...appConfig.KiteFreeGiftDiscountConfig,
|
|
17
17
|
...appConfig.FastBundleBundlesDiscountsConfig,
|
|
18
|
-
...appConfig.SimpleBundlesKitsConfig
|
|
18
|
+
...appConfig.SimpleBundlesKitsConfig,
|
|
19
|
+
...appConfig.EasyBundleBuilderSkailamaConfig,
|
|
20
|
+
...appConfig.PreorderNowPreOrderPqConfig,
|
|
21
|
+
...appConfig.FlyBundlesUpsellsFbtConfig,
|
|
22
|
+
...appConfig.JunipProductReviewsUgcConfig,
|
|
23
|
+
...appConfig.PreorderNowWodPresaleConfig
|
|
19
24
|
};
|
|
20
25
|
const THIRD_PARTY_APP_BLOCK_ID_PREFIX = 'gp_app';
|
|
21
26
|
|
|
@@ -28,7 +28,8 @@ const composeTypographyV2Css = (typography, isImportant)=>{
|
|
|
28
28
|
const composeImportant = isImportant ? '!important' : '';
|
|
29
29
|
return `
|
|
30
30
|
${fontFamily ? `font-family: ${composeFontFamilyTypographyV2({
|
|
31
|
-
fontFamily
|
|
31
|
+
fontFamily,
|
|
32
|
+
type: typography?.type
|
|
32
33
|
})} ${composeImportant}` : ''};
|
|
33
34
|
${fontSize?.desktop ? `font-size: ${fontSize?.desktop} ${composeImportant}` : ''};
|
|
34
35
|
${bold ? `font-weight: bold ${composeImportant}` : fontWeight ? `font-weight: ${fontWeight} ${composeImportant}` : ''};
|
|
@@ -76,7 +77,7 @@ const composeTypographyV2 = (value, attrs)=>{
|
|
|
76
77
|
});
|
|
77
78
|
};
|
|
78
79
|
const composeFontFamilyTypographyV2 = (value)=>{
|
|
79
|
-
const { fontFamily, isCustom, fallbackFontFamily } = value || {};
|
|
80
|
+
const { fontFamily, isCustom, fallbackFontFamily, type } = value || {};
|
|
80
81
|
if (!fontFamily) {
|
|
81
82
|
return isCustom ? fallbackFontFamily : undefined;
|
|
82
83
|
}
|
|
@@ -93,7 +94,7 @@ const composeFontFamilyTypographyV2 = (value)=>{
|
|
|
93
94
|
default:
|
|
94
95
|
return getFontUsedByTypographyV2({
|
|
95
96
|
fontFamily: fontFamily.value,
|
|
96
|
-
fallbackFontFamily:
|
|
97
|
+
fallbackFontFamily: composeFallbackTypographyStyle(type ?? 'heading')
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
}
|
|
@@ -118,7 +119,7 @@ const composeTypographyAttr = (attrs)=>{
|
|
|
118
119
|
});
|
|
119
120
|
};
|
|
120
121
|
const composeTypographyClassName = (typo, typography)=>{
|
|
121
|
-
return typo ? typo?.type && !typo.custom ? genTypoClass(typo.type) : '' : typography?.type && genTypoClass(typography?.type);
|
|
122
|
+
return typo ? typo?.type && !isCustomTypo(typo.custom) ? genTypoClass(typo.type) : '' : typography?.type && genTypoClass(typography?.type);
|
|
122
123
|
};
|
|
123
124
|
const composeFallbackTypographyStyle = (tag)=>{
|
|
124
125
|
if (tag.toLocaleLowerCase().includes('heading')) {
|
|
@@ -132,7 +133,7 @@ const composeTypographyStyle = (typo, typography, disableAttr)=>{
|
|
|
132
133
|
const customTypo = {
|
|
133
134
|
...typo.custom,
|
|
134
135
|
fallbackFontFamily: fallbackFontFamily,
|
|
135
|
-
isCustom:
|
|
136
|
+
isCustom: isCustomTypo(typo.custom)
|
|
136
137
|
};
|
|
137
138
|
return {
|
|
138
139
|
...composeTypographyV2(customTypo, typo.attrs),
|
|
@@ -143,6 +144,9 @@ const composeTypographyStyle = (typo, typography, disableAttr)=>{
|
|
|
143
144
|
...!typography?.type ? composeTypography(typography?.custom) : {}
|
|
144
145
|
};
|
|
145
146
|
};
|
|
147
|
+
const isCustomTypo = (customTypo)=>{
|
|
148
|
+
return customTypo && Object.keys(customTypo).length > 1 || customTypo && Object.keys(customTypo).length === 1 && !customTypo.fontSize;
|
|
149
|
+
};
|
|
146
150
|
|
|
147
151
|
exports.composeFallbackTypographyStyle = composeFallbackTypographyStyle;
|
|
148
152
|
exports.composeFontFamilyTypographyV2 = composeFontFamilyTypographyV2;
|
|
@@ -5,70 +5,71 @@ var shop = require('./shop.js');
|
|
|
5
5
|
const shopifyPriceRounding = (amount, precision)=>{
|
|
6
6
|
return parseFloat(`${amount}`).toFixed(Number(precision) + 1).slice(0, -1);
|
|
7
7
|
};
|
|
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
|
+
};
|
|
8
68
|
const useFormatMoney = (amount, withCurrency)=>{
|
|
9
69
|
const { moneyFormat, moneyWithCurrencyFormat } = shop.useMoneyFormat();
|
|
10
|
-
const formatMoney = function(cents, format) {
|
|
11
|
-
let value = '';
|
|
12
|
-
const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
|
|
13
|
-
const formatString = format || '${{amount}}';
|
|
14
|
-
/**
|
|
15
|
-
* check default
|
|
16
|
-
* @param opt opt
|
|
17
|
-
* @param def def
|
|
18
|
-
* @returns any
|
|
19
|
-
*/ function defaultOption(opt, def) {
|
|
20
|
-
return typeof opt == 'undefined' ? def : opt;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* formatWithDelimiters
|
|
24
|
-
* @param number number
|
|
25
|
-
* @param precision precision
|
|
26
|
-
* @param thousands thousands
|
|
27
|
-
* @param decimal decimal
|
|
28
|
-
* @returns any
|
|
29
|
-
*/ // eslint-disable-next-line max-params
|
|
30
|
-
function formatWithDelimiters(number, precision, thousands, decimal) {
|
|
31
|
-
precision = defaultOption(precision, 2);
|
|
32
|
-
thousands = defaultOption(thousands, ',');
|
|
33
|
-
decimal = defaultOption(decimal, '.');
|
|
34
|
-
if (isNaN(number) || number == null) {
|
|
35
|
-
return 0;
|
|
36
|
-
}
|
|
37
|
-
// shopify làm tròn bằng cách cắt đi các số ở đằng sau chứ không sử dụng toFixed để làm tròn như toán học
|
|
38
|
-
number = shopifyPriceRounding(number, Number(precision));
|
|
39
|
-
const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
|
|
40
|
-
return dollars + cents;
|
|
41
|
-
}
|
|
42
|
-
switch(formatString.match(placeholderRegex)[1]){
|
|
43
|
-
case 'amount':
|
|
44
|
-
value = formatWithDelimiters(cents, 2);
|
|
45
|
-
break;
|
|
46
|
-
case 'amount_no_decimals':
|
|
47
|
-
value = formatWithDelimiters(cents, 0);
|
|
48
|
-
break;
|
|
49
|
-
case 'amount_with_comma_separator':
|
|
50
|
-
value = formatWithDelimiters(cents, 2, '.', ',');
|
|
51
|
-
break;
|
|
52
|
-
case 'amount_no_decimals_with_comma_separator':
|
|
53
|
-
value = formatWithDelimiters(cents, 0, '.', ',');
|
|
54
|
-
break;
|
|
55
|
-
case 'amount_with_apostrophe_separator':
|
|
56
|
-
value = formatWithDelimiters(cents, 2, "'", '.');
|
|
57
|
-
break;
|
|
58
|
-
case 'amount_no_decimals_with_space_separator':
|
|
59
|
-
value = formatWithDelimiters(cents, 0, ' ');
|
|
60
|
-
break;
|
|
61
|
-
case 'amount_with_space_separator':
|
|
62
|
-
value = formatWithDelimiters(cents, 2, ' ', ',');
|
|
63
|
-
break;
|
|
64
|
-
case 'amount_with_period_and_space_separator':
|
|
65
|
-
value = formatWithDelimiters(cents, 2, ' ', '.');
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
return formatString.replace(placeholderRegex, value);
|
|
69
|
-
};
|
|
70
70
|
return withCurrency ? formatMoney(`${amount}`, moneyWithCurrencyFormat || moneyFormat) : formatMoney(`${amount}`, moneyFormat);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
exports.formatMoney = formatMoney;
|
|
73
74
|
exports.shopifyPriceRounding = shopifyPriceRounding;
|
|
74
75
|
exports.useFormatMoney = useFormatMoney;
|
package/dist/cjs/index.js
CHANGED
|
@@ -60,6 +60,7 @@ var iconList = require('./helpers/icon-list.js');
|
|
|
60
60
|
var isDefined = require('./helpers/is-defined.js');
|
|
61
61
|
var layout = require('./helpers/layout.js');
|
|
62
62
|
var makeStyle = require('./helpers/make-style.js');
|
|
63
|
+
var align = require('./helpers/align.js');
|
|
63
64
|
var product = require('./helpers/product.js');
|
|
64
65
|
var query = require('./helpers/query.js');
|
|
65
66
|
var radius = require('./helpers/radius.js');
|
|
@@ -243,6 +244,7 @@ exports.makeStyleResponsiveState = makeStyle.makeStyleResponsiveState;
|
|
|
243
244
|
exports.makeStyleState = makeStyle.makeStyleState;
|
|
244
245
|
exports.makeWidth = makeStyle.makeWidth;
|
|
245
246
|
exports.removeNullUndefined = makeStyle.removeNullUndefined;
|
|
247
|
+
exports.convertTextAlignToJustify = align.convertTextAlignToJustify;
|
|
246
248
|
exports.checkAvailableVariantInStock = product.checkAvailableVariantInStock;
|
|
247
249
|
exports.getSelectedVariant = product.getSelectedVariant;
|
|
248
250
|
exports.parseSelectedOption = product.parseSelectedOption;
|
|
@@ -264,6 +266,7 @@ exports.removeUndefinedValuesFromObject = render.removeUndefinedValuesFromObject
|
|
|
264
266
|
exports.styles = render.styles;
|
|
265
267
|
exports.template = render.template;
|
|
266
268
|
exports.composeShadowCss = shadow.composeShadowCss;
|
|
269
|
+
exports.getResonsiveStyleShadow = shadow.getResonsiveStyleShadow;
|
|
267
270
|
exports.getStyleShadow = shadow.getStyleShadow;
|
|
268
271
|
exports.getStyleShadowState = shadow.getStyleShadowState;
|
|
269
272
|
exports.parseValueWithUnit = shadow.parseValueWithUnit;
|
|
@@ -317,6 +320,7 @@ exports.useProductQuery = useProductQuery.useProductQuery;
|
|
|
317
320
|
exports.useProductsQuery = useProductsQuery.useProductsQuery;
|
|
318
321
|
exports.useProductsQueryAll = useProductsQuery.useProductsQueryAll;
|
|
319
322
|
exports.useCurrentDevice = useCurrentDevice.useCurrentDevice;
|
|
323
|
+
exports.formatMoney = useFormatMoney.formatMoney;
|
|
320
324
|
exports.shopifyPriceRounding = useFormatMoney.shopifyPriceRounding;
|
|
321
325
|
exports.useFormatMoney = useFormatMoney.useFormatMoney;
|
|
322
326
|
exports.useLazyVideo = useLazyVideo.useLazyVideo;
|
|
@@ -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
|
+
"bundle-item": passProps?.['bundle-item'],
|
|
44
45
|
uid: id
|
|
45
46
|
}, id))
|
|
46
47
|
}) : /*#__PURE__*/ jsx(Component, {
|
|
@@ -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));
|
|
@@ -3,7 +3,7 @@ import { isColor } from './colors.js';
|
|
|
3
3
|
import { layoutComponent } from './constant.js';
|
|
4
4
|
import { makeStyleKey } from './make-style.js';
|
|
5
5
|
import { composeRadius, getCornerCSSFromGlobal } from './radius.js';
|
|
6
|
-
import { getStyleShadowState, getStyleShadow } from './shadow.js';
|
|
6
|
+
import { getResonsiveStyleShadow, getStyleShadowState, getStyleShadow } from './shadow.js';
|
|
7
7
|
|
|
8
8
|
const composeSpacing = ({ source, spacing, type, suffix = '' })=>{
|
|
9
9
|
const { top, left, bottom, right } = spacing;
|
|
@@ -99,6 +99,9 @@ function composeAdvanceStyle(data, tag, pageType) {
|
|
|
99
99
|
if (attr === 'rounded') {
|
|
100
100
|
Object.assign(styles, composeRadius(value));
|
|
101
101
|
}
|
|
102
|
+
if (attr === 'boxShadow') {
|
|
103
|
+
Object.assign(styles, getResonsiveStyleShadow(value, 'box-shadow', hasBoxShadow));
|
|
104
|
+
}
|
|
102
105
|
if (composeAttr === 'desktop') {
|
|
103
106
|
switch(attr){
|
|
104
107
|
case 'padding':
|
|
@@ -213,20 +216,20 @@ function composeAdvanceStyle(data, tag, pageType) {
|
|
|
213
216
|
}));
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
|
-
if (attr === 'blockPadding' && pageType ===
|
|
219
|
+
if (attr === 'blockPadding' && pageType === 'POST_PURCHASE') {
|
|
217
220
|
const valueMapped = postPurchasePaddingMapping[value];
|
|
218
221
|
styles[`--pb`] = getAttrValue(attr, valueMapped, tag);
|
|
219
222
|
styles[`--pt`] = getAttrValue(attr, valueMapped, tag);
|
|
220
223
|
styles[`--mb`] = '0px';
|
|
221
224
|
styles[`--mt`] = '0px';
|
|
222
225
|
}
|
|
223
|
-
if (attr === 'inlinePadding' && pageType ===
|
|
226
|
+
if (attr === 'inlinePadding' && pageType === 'POST_PURCHASE') {
|
|
224
227
|
const valueMapped = postPurchasePaddingMapping[value];
|
|
225
228
|
styles[`--pl`] = getAttrValue(attr, valueMapped, tag);
|
|
226
229
|
styles[`--pr`] = getAttrValue(attr, valueMapped, tag);
|
|
227
230
|
}
|
|
228
231
|
});
|
|
229
|
-
const advancedPostPurchaseStyles = pageType ===
|
|
232
|
+
const advancedPostPurchaseStyles = pageType === 'POST_PURCHASE' ? composeAdvanceStyleForPostPurchase(data, tag) : {};
|
|
230
233
|
return {
|
|
231
234
|
...styles,
|
|
232
235
|
...advancedPostPurchaseStyles
|