@gem-sdk/core 1.45.0-dev.93 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ComponentToolbarPreview.js +8 -47
- package/dist/cjs/components/ComponentWrapperPreview.js +2 -16
- package/dist/cjs/components/Render.liquid.js +3 -2
- package/dist/cjs/components/RenderPreview.js +0 -1
- package/dist/cjs/components/constant.js +2 -6
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +5 -14
- package/dist/cjs/contexts/BuilderPreviewContext.js +1 -5
- package/dist/cjs/contexts/ModalContext.js +2 -2
- package/dist/cjs/contexts/PageContext.js +1 -29
- package/dist/cjs/contexts/SectionContext.js +0 -1
- package/dist/cjs/graphql/queries/blogs.generated.js +3 -0
- package/dist/cjs/helpers/colors.js +2 -2
- package/dist/cjs/helpers/shadow.js +1 -1
- package/dist/cjs/helpers/size.js +0 -4
- package/dist/cjs/hooks/animation/useAnimationPreview.js +0 -1
- package/dist/cjs/hooks/animation/useApplyAnimation.js +0 -2
- package/dist/cjs/hooks/articles/useArticlesQuery.js +0 -1
- package/dist/cjs/hooks/useFormatMoney.js +60 -61
- package/dist/cjs/index.js +0 -13
- package/dist/esm/components/ComponentToolbarPreview.js +9 -48
- package/dist/esm/components/ComponentWrapperPreview.js +2 -16
- package/dist/esm/components/Render.liquid.js +3 -2
- package/dist/esm/components/RenderPreview.js +0 -1
- package/dist/esm/components/constant.js +2 -6
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +5 -14
- package/dist/esm/contexts/BuilderPreviewContext.js +1 -5
- package/dist/esm/contexts/ModalContext.js +2 -2
- package/dist/esm/contexts/PageContext.js +1 -29
- package/dist/esm/contexts/SectionContext.js +0 -1
- package/dist/esm/graphql/queries/blogs.generated.js +3 -0
- package/dist/esm/helpers/colors.js +2 -2
- package/dist/esm/helpers/shadow.js +1 -1
- package/dist/esm/helpers/size.js +1 -4
- package/dist/esm/hooks/animation/useAnimationPreview.js +0 -1
- package/dist/esm/hooks/animation/useApplyAnimation.js +0 -2
- package/dist/esm/hooks/articles/useArticlesQuery.js +0 -1
- package/dist/esm/hooks/useFormatMoney.js +61 -61
- package/dist/esm/index.js +2 -4
- package/dist/types/index.d.ts +5 -215
- package/package.json +3 -3
- package/dist/cjs/components/InteractionSuffix.js +0 -107
- package/dist/cjs/helpers/align.js +0 -19
- package/dist/cjs/hooks/useInteraction.js +0 -19
- package/dist/cjs/types/custom.js +0 -44
- package/dist/esm/components/InteractionSuffix.js +0 -105
- package/dist/esm/helpers/align.js +0 -17
- package/dist/esm/hooks/useInteraction.js +0 -17
- package/dist/esm/types/custom.js +0 -44
|
@@ -21,7 +21,6 @@ var useToolbarPostPurchase = require('../hooks/useToolbarPostPurchase.js');
|
|
|
21
21
|
var constant = require('./constant.js');
|
|
22
22
|
var AIContentGenerator = require('./ai-generator/AIContentGenerator.js');
|
|
23
23
|
var AIGenContentLoading = require('./ai-generator/AIGenContentLoading.js');
|
|
24
|
-
var InteractionSuffix = require('./InteractionSuffix.js');
|
|
25
24
|
require('../helpers/convert.js');
|
|
26
25
|
|
|
27
26
|
const SECTION_LIMIT = 25;
|
|
@@ -48,7 +47,6 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
48
47
|
const [deleteTooltipPosition, setDeleteTooltipPosition] = react.useState('top');
|
|
49
48
|
const [isDisableDelete, setIsUnableDelete] = react.useState(false);
|
|
50
49
|
const [parentProductUid, setParentProductUid] = react.useState('');
|
|
51
|
-
const [articleUid, setArticleUid] = react.useState('');
|
|
52
50
|
const [tooltipText, setTooltipText] = react.useState({
|
|
53
51
|
width: '',
|
|
54
52
|
text: ''
|
|
@@ -63,18 +61,6 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
63
61
|
'Product Description',
|
|
64
62
|
'Product Price'
|
|
65
63
|
];
|
|
66
|
-
const editArticleElementList = [
|
|
67
|
-
'Article Title',
|
|
68
|
-
'Article Content',
|
|
69
|
-
'Article Image',
|
|
70
|
-
'Article Author',
|
|
71
|
-
'Article Category',
|
|
72
|
-
'Article Date'
|
|
73
|
-
];
|
|
74
|
-
const editAbleElementList = [
|
|
75
|
-
...editProductElementList,
|
|
76
|
-
...editArticleElementList
|
|
77
|
-
];
|
|
78
64
|
const isOverToolbarPosition = (el, parent)=>{
|
|
79
65
|
const parentLength = parents.length;
|
|
80
66
|
const rect = el.getBoundingClientRect();
|
|
@@ -120,29 +106,15 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
120
106
|
}, [
|
|
121
107
|
storefrontUrl
|
|
122
108
|
]);
|
|
123
|
-
const
|
|
124
|
-
return `https://admin.shopify.com/store/${shopName}
|
|
109
|
+
const shopifyEditLink = react.useMemo(()=>{
|
|
110
|
+
return productId ? `https://admin.shopify.com/store/${shopName}/products/${productId}` : '';
|
|
125
111
|
}, [
|
|
112
|
+
productId,
|
|
126
113
|
shopName
|
|
127
114
|
]);
|
|
128
|
-
const linkEditProduct = react.useMemo(()=>{
|
|
129
|
-
return productId ? `${linkShopDefault}/products/${productId}` : '';
|
|
130
|
-
}, [
|
|
131
|
-
linkShopDefault,
|
|
132
|
-
productId
|
|
133
|
-
]);
|
|
134
|
-
const linkEditArticle = react.useMemo(()=>{
|
|
135
|
-
return articleUid ? `${linkShopDefault}/articles/${articleUid}` : '';
|
|
136
|
-
}, [
|
|
137
|
-
articleUid,
|
|
138
|
-
linkShopDefault
|
|
139
|
-
]);
|
|
140
115
|
// Get parents
|
|
141
116
|
const onActiveComponent = react.useCallback((e)=>{
|
|
142
117
|
const detail = e.detail;
|
|
143
|
-
if (detail?.articleId) {
|
|
144
|
-
setArticleUid(detail.articleId);
|
|
145
|
-
}
|
|
146
118
|
if (detail?.componentUid == props.uid) {
|
|
147
119
|
getDeleteTooltipPosition();
|
|
148
120
|
if (isSaleFunnelPage) {
|
|
@@ -234,15 +206,7 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
234
206
|
window.dispatchEvent(event);
|
|
235
207
|
};
|
|
236
208
|
const goToShopifyEditLink = ()=>{
|
|
237
|
-
|
|
238
|
-
window.open(linkEditArticle, '_blank');
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (editProductElementList.includes(toolbarName() ?? '')) {
|
|
242
|
-
window.open(linkEditProduct, '_blank');
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
window.open(linkShopDefault, '_blank');
|
|
209
|
+
window.open(shopifyEditLink, '_blank');
|
|
246
210
|
};
|
|
247
211
|
const onDelete = (e)=>{
|
|
248
212
|
e.preventDefault();
|
|
@@ -330,6 +294,7 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
330
294
|
const isEnableCreateThemeSection = ()=>{
|
|
331
295
|
return editingPageType !== 'STATIC' && editingPageType !== 'POST_PURCHASE';
|
|
332
296
|
};
|
|
297
|
+
// if (!isActive) return null;
|
|
333
298
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
334
299
|
children: [
|
|
335
300
|
!(props.tag == 'Section' && isThemeSectionEditor) && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
@@ -515,7 +480,7 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
515
480
|
})
|
|
516
481
|
})
|
|
517
482
|
}),
|
|
518
|
-
|
|
483
|
+
editProductElementList.includes(toolbarName() ?? '') && /*#__PURE__*/ jsxRuntime.jsx(Tooltip.default, {
|
|
519
484
|
"data-toolbar-title": true,
|
|
520
485
|
enable: true,
|
|
521
486
|
"data-toolbar-disable": false,
|
|
@@ -594,14 +559,10 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
594
559
|
fill: "currentColor"
|
|
595
560
|
})
|
|
596
561
|
})
|
|
597
|
-
}),
|
|
598
|
-
/*#__PURE__*/ jsxRuntime.jsx(InteractionSuffix.InteractionSuffix, {
|
|
599
|
-
tag: props.tag,
|
|
600
|
-
uid: props.uid
|
|
601
562
|
})
|
|
602
563
|
]
|
|
603
564
|
}, props.uid),
|
|
604
|
-
isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(ThemeSectionStatus.
|
|
565
|
+
isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(ThemeSectionStatus.ThemeSectionStatus, {
|
|
605
566
|
...props
|
|
606
567
|
}),
|
|
607
568
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
@@ -664,6 +625,6 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
664
625
|
]
|
|
665
626
|
});
|
|
666
627
|
};
|
|
667
|
-
var ComponentToolbarPreview$1 = /*#__PURE__*/ react.memo(ComponentToolbarPreview);
|
|
628
|
+
var ComponentToolbarPreview$1 = /*#__PURE__*/ react.memo(ComponentToolbarPreview);
|
|
668
629
|
|
|
669
630
|
exports.default = ComponentToolbarPreview$1;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
|
|
8
|
-
var useInteraction = require('../hooks/useInteraction.js');
|
|
9
8
|
var constant = require('./constant.js');
|
|
10
9
|
var RenderCustomCode = require('./RenderCustomCode.js');
|
|
11
10
|
var ComponentToolbarPreview = require('./ComponentToolbarPreview.js');
|
|
@@ -33,19 +32,6 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
33
32
|
}, [
|
|
34
33
|
props.uid
|
|
35
34
|
]);
|
|
36
|
-
const currentProps = props;
|
|
37
|
-
const { getAnimationByUid } = useInteraction.useInteraction();
|
|
38
|
-
const animationByInteraction = getAnimationByUid(props.uid);
|
|
39
|
-
if (animationByInteraction) {
|
|
40
|
-
currentProps.advanced = {
|
|
41
|
-
...currentProps.advanced,
|
|
42
|
-
animation: {
|
|
43
|
-
desktop: animationByInteraction,
|
|
44
|
-
tablet: animationByInteraction,
|
|
45
|
-
mobile: animationByInteraction
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
35
|
const pageType = shop.usePageType();
|
|
50
36
|
if (props.type === 'section') {
|
|
51
37
|
return null;
|
|
@@ -150,7 +136,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
150
136
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
151
137
|
children: [
|
|
152
138
|
/*#__PURE__*/ jsxRuntime.jsx(ComponentAnimation.default, {
|
|
153
|
-
...
|
|
139
|
+
...props
|
|
154
140
|
}),
|
|
155
141
|
/*#__PURE__*/ jsxRuntime.jsx(RenderCustomCode.default, {
|
|
156
142
|
uid: props.uid,
|
|
@@ -179,7 +165,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
179
165
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
180
166
|
children: [
|
|
181
167
|
/*#__PURE__*/ jsxRuntime.jsx(ComponentAnimation.default, {
|
|
182
|
-
...
|
|
168
|
+
...props
|
|
183
169
|
}),
|
|
184
170
|
/*#__PURE__*/ jsxRuntime.jsx(RenderCustomCode.default, {
|
|
185
171
|
uid: props.uid,
|
|
@@ -39,6 +39,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
39
39
|
const item = builder[uid];
|
|
40
40
|
const Component = components[item?.tag];
|
|
41
41
|
if (!Component) {
|
|
42
|
+
console.log('Miss component: ', item);
|
|
42
43
|
return {
|
|
43
44
|
liquid: '',
|
|
44
45
|
extraFiles
|
|
@@ -220,6 +221,7 @@ const appendAnimation = (props, liquid)=>{
|
|
|
220
221
|
const appearTablet = getAnimationType(getSettingsByDevice('tablet'), 'appear');
|
|
221
222
|
const appearMobile = getAnimationType(getSettingsByDevice('mobile'), 'appear');
|
|
222
223
|
const enableAnimation = animation?.desktop?.enabled && (appearDesktop !== 'none' || hoverDesktop !== 'none') || animation?.tablet?.enabled && appearTablet !== 'none' || animation?.mobile?.enabled && appearMobile !== 'none';
|
|
224
|
+
if (!enableAnimation) return liquid;
|
|
223
225
|
const getInitVisibility = (device)=>getSettingsByDevice(device)?.enabled && ![
|
|
224
226
|
'shake',
|
|
225
227
|
'none'
|
|
@@ -234,8 +236,7 @@ const appendAnimation = (props, liquid)=>{
|
|
|
234
236
|
gp-data='${JSON.stringify({
|
|
235
237
|
config: animation,
|
|
236
238
|
tag,
|
|
237
|
-
opacity
|
|
238
|
-
isEnableInit: enableAnimation
|
|
239
|
+
opacity
|
|
239
240
|
})}'
|
|
240
241
|
style="${{
|
|
241
242
|
display: 'contents'
|
|
@@ -45,7 +45,6 @@ const RenderPreview = ({ uid, ...passProps })=>{
|
|
|
45
45
|
setting: item.settings,
|
|
46
46
|
...passProps,
|
|
47
47
|
children: item.childrens.map((id)=>/*#__PURE__*/ jsxRuntime.jsx(RenderPreviewMemo, {
|
|
48
|
-
...passProps,
|
|
49
48
|
uid: id
|
|
50
49
|
}, id))
|
|
51
50
|
}) : /*#__PURE__*/ jsxRuntime.jsx(Component, {
|
|
@@ -37,10 +37,7 @@ const disableWrap = [
|
|
|
37
37
|
'PostPurchaseProductImages',
|
|
38
38
|
'Sticky',
|
|
39
39
|
'Heading',
|
|
40
|
-
'EstimateDate'
|
|
41
|
-
'ProductBadge',
|
|
42
|
-
'Marquee',
|
|
43
|
-
'MarqueeItem'
|
|
40
|
+
'EstimateDate'
|
|
44
41
|
];
|
|
45
42
|
const customRenderChildren = [
|
|
46
43
|
'Accordion',
|
|
@@ -51,8 +48,7 @@ const customRenderChildren = [
|
|
|
51
48
|
];
|
|
52
49
|
const excludeApplyStyle = [
|
|
53
50
|
'IconListV2',
|
|
54
|
-
'IconList'
|
|
55
|
-
'ProductBadge'
|
|
51
|
+
'IconList'
|
|
56
52
|
];
|
|
57
53
|
const postPurchaseRequiredElements = [
|
|
58
54
|
'PostPurchaseProductOffer',
|
|
@@ -2,17 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
case 'DRAFT':
|
|
8
|
-
return 'This Theme Section is Draft. Publish page will also publish Theme Section.';
|
|
9
|
-
case 'NEED_PUBLISHING':
|
|
10
|
-
return 'Need to republish. Go to global edit and publish this section';
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const ThemeSectionStatusWrapper = ({ tag, status, isThemeSection })=>{
|
|
14
|
-
const isRenderThemeSectionStatus = tag === 'Section' && isThemeSection && (status === 'DRAFT' || status === 'NEED_PUBLISHING');
|
|
15
|
-
const statusMessage = getStatusMessage(status);
|
|
5
|
+
const ThemeSectionStatus = ({ ...props })=>{
|
|
6
|
+
const isRenderThemeSectionStatus = props.tag === 'Section' && props?.isThemeSection && props?.needPublishing;
|
|
16
7
|
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
17
8
|
children: isRenderThemeSectionStatus && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
18
9
|
"data-theme-section-status": true,
|
|
@@ -33,13 +24,13 @@ const ThemeSectionStatusWrapper = ({ tag, status, isThemeSection })=>{
|
|
|
33
24
|
})
|
|
34
25
|
})
|
|
35
26
|
}),
|
|
36
|
-
|
|
27
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
37
28
|
"data-theme-section-status-text": true,
|
|
38
|
-
children:
|
|
29
|
+
children: "Need to republish. Go to global edit and publish this section"
|
|
39
30
|
})
|
|
40
31
|
]
|
|
41
32
|
})
|
|
42
33
|
});
|
|
43
34
|
};
|
|
44
35
|
|
|
45
|
-
exports.
|
|
36
|
+
exports.ThemeSectionStatus = ThemeSectionStatus;
|
|
@@ -254,11 +254,7 @@ const createBuilderPreviewProvider = (args, pageName, isThemeSectionEditor)=>zus
|
|
|
254
254
|
}
|
|
255
255
|
},
|
|
256
256
|
getItem: (id)=>{
|
|
257
|
-
|
|
258
|
-
return {
|
|
259
|
-
...item,
|
|
260
|
-
rawChildrens: item?.childrens?.map((v)=>get().state[v])
|
|
261
|
-
};
|
|
257
|
+
return get().state[id];
|
|
262
258
|
},
|
|
263
259
|
removeItem: (id)=>{
|
|
264
260
|
if (id === 'ROOT') {
|
|
@@ -7,8 +7,8 @@ var zustand = require('zustand');
|
|
|
7
7
|
const ModalContext = /*#__PURE__*/ react.createContext(null);
|
|
8
8
|
const createModalProvider = (data)=>zustand.createStore((set)=>({
|
|
9
9
|
activeId: data,
|
|
10
|
-
setModalActive: (id
|
|
11
|
-
|
|
10
|
+
setModalActive: (id)=>{
|
|
11
|
+
window?.parent?.postMessage?.(JSON.stringify({
|
|
12
12
|
type: 'active-element',
|
|
13
13
|
uid: id
|
|
14
14
|
}), '*');
|
|
@@ -31,31 +31,6 @@ const createPageStoreProvider = (data)=>zustand.createStore((set)=>({
|
|
|
31
31
|
set({
|
|
32
32
|
publicStoreFrontData: publicStoreFrontData
|
|
33
33
|
});
|
|
34
|
-
},
|
|
35
|
-
setInteractionIsSelectOnPage: (value)=>{
|
|
36
|
-
set((state)=>({
|
|
37
|
-
interactionData: {
|
|
38
|
-
...state.interactionData,
|
|
39
|
-
isSelectOnPage: value
|
|
40
|
-
}
|
|
41
|
-
}));
|
|
42
|
-
},
|
|
43
|
-
setInteractionItem: (item)=>{
|
|
44
|
-
set((state)=>({
|
|
45
|
-
interactionData: {
|
|
46
|
-
...state.interactionData,
|
|
47
|
-
item,
|
|
48
|
-
isSelectOnPage: state.interactionData?.isSelectOnPage || false
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
51
|
-
},
|
|
52
|
-
setInteractionSelectType: (selectType)=>{
|
|
53
|
-
set((state)=>({
|
|
54
|
-
interactionData: {
|
|
55
|
-
...state.interactionData,
|
|
56
|
-
selectType
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
34
|
}
|
|
60
35
|
}));
|
|
61
36
|
const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffers, publicStoreFrontData, ...passProps })=>{
|
|
@@ -63,10 +38,7 @@ const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffe
|
|
|
63
38
|
dynamicProduct,
|
|
64
39
|
dynamicCollection,
|
|
65
40
|
productOffers,
|
|
66
|
-
publicStoreFrontData
|
|
67
|
-
interactionData: {
|
|
68
|
-
selectType: 'element'
|
|
69
|
-
}
|
|
41
|
+
publicStoreFrontData
|
|
70
42
|
}), [
|
|
71
43
|
dynamicProduct,
|
|
72
44
|
dynamicCollection,
|
|
@@ -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
|
},
|
|
@@ -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]
|
|
122
|
+
`-${constant.stateMapping?.[state]}-${type}`,
|
|
123
123
|
getSingleColorVariable(value)
|
|
124
124
|
];
|
|
125
125
|
}).filter(isDefined.isDefined));
|
|
@@ -156,7 +156,7 @@ const getSingleColorVariable = (color)=>{
|
|
|
156
156
|
};
|
|
157
157
|
function isColor(color) {
|
|
158
158
|
if (!color || typeof color !== 'string') return false;
|
|
159
|
-
return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent')
|
|
159
|
+
return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent');
|
|
160
160
|
}
|
|
161
161
|
const getGlobalColorStyle = (data)=>{
|
|
162
162
|
if (!data) return {};
|
|
@@ -27,7 +27,7 @@ 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]
|
|
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'
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
|
package/dist/cjs/helpers/size.js
CHANGED
|
@@ -181,9 +181,6 @@ function getCustomPaddingSizeCSSByDevice(globalSize, device) {
|
|
|
181
181
|
const getPaddingGlobalSize = (globalSize)=>{
|
|
182
182
|
return Object.assign({}, getCustomPaddingSizeCSSByDevice(globalSize, 'desktop'), getCustomPaddingSizeCSSByDevice(globalSize, 'tablet'), getCustomPaddingSizeCSSByDevice(globalSize, 'mobile'));
|
|
183
183
|
};
|
|
184
|
-
const getValueByDevice = (value, device)=>{
|
|
185
|
-
return value?.[device] === undefined ? value?.desktop === undefined ? value?.tablet : value?.desktop : value?.[device];
|
|
186
|
-
};
|
|
187
184
|
|
|
188
185
|
exports.composeSize = composeSize;
|
|
189
186
|
exports.composeSizeCss = composeSizeCss;
|
|
@@ -192,7 +189,6 @@ exports.getAspectRatioGlobalSize = getAspectRatioGlobalSize;
|
|
|
192
189
|
exports.getGlobalSizeGap = getGlobalSizeGap;
|
|
193
190
|
exports.getHeightByShapeGlobalSize = getHeightByShapeGlobalSize;
|
|
194
191
|
exports.getPaddingGlobalSize = getPaddingGlobalSize;
|
|
195
|
-
exports.getValueByDevice = getValueByDevice;
|
|
196
192
|
exports.getWidthByShapeGlobalSize = getWidthByShapeGlobalSize;
|
|
197
193
|
exports.getWidthHeightGlobalSize = getWidthHeightGlobalSize;
|
|
198
194
|
exports.makeGlobalSize = makeGlobalSize;
|
|
@@ -5,7 +5,6 @@ var react = require('react');
|
|
|
5
5
|
const useAnimationPreview = ({ props, playAnimation, cancelAnimation, setAnimationOnFinish, setToolbarActive })=>{
|
|
6
6
|
const previewAnimation = react.useCallback((e)=>{
|
|
7
7
|
const { uid, isCancel } = e.detail;
|
|
8
|
-
console.log('props.uid !== uid', props.uid !== uid, props.uid, uid);
|
|
9
8
|
if (props.uid !== uid) return;
|
|
10
9
|
cancelAnimation();
|
|
11
10
|
if (isCancel) {
|
|
@@ -8,7 +8,6 @@ var useAnimationTarget = require('./useAnimationTarget.js');
|
|
|
8
8
|
var useAnimationConfig = require('./useAnimationConfig.js');
|
|
9
9
|
var useAnimationActions = require('./useAnimationActions.js');
|
|
10
10
|
var useAnimationPreview = require('./useAnimationPreview.js');
|
|
11
|
-
require('../../types/custom.js');
|
|
12
11
|
var animations = require('../../types/animations.js');
|
|
13
12
|
|
|
14
13
|
const useApplyAnimation = ({ props })=>{
|
|
@@ -41,7 +40,6 @@ const useApplyAnimation = ({ props })=>{
|
|
|
41
40
|
setting,
|
|
42
41
|
target: item.target
|
|
43
42
|
}));
|
|
44
|
-
console.log('listAnimations', listAnimations);
|
|
45
43
|
cancelAnimation();
|
|
46
44
|
setAnimation(listAnimations);
|
|
47
45
|
}, [
|
|
@@ -5,71 +5,70 @@ 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
|
-
};
|
|
68
8
|
const useFormatMoney = (amount, withCurrency)=>{
|
|
69
9
|
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;
|
|
74
73
|
exports.shopifyPriceRounding = shopifyPriceRounding;
|
|
75
74
|
exports.useFormatMoney = useFormatMoney;
|
package/dist/cjs/index.js
CHANGED
|
@@ -60,7 +60,6 @@ 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');
|
|
64
63
|
var product = require('./helpers/product.js');
|
|
65
64
|
var query = require('./helpers/query.js');
|
|
66
65
|
var radius = require('./helpers/radius.js');
|
|
@@ -98,7 +97,6 @@ var useProductList = require('./hooks/useProductList.js');
|
|
|
98
97
|
var useSuspenseFetch = require('./hooks/useSuspenseFetch.js');
|
|
99
98
|
var useSwatchesOptions = require('./hooks/useSwatchesOptions.js');
|
|
100
99
|
var useInitialSwatchesOptions = require('./hooks/useInitialSwatchesOptions.js');
|
|
101
|
-
var custom = require('./types/custom.js');
|
|
102
100
|
var shop$1 = require('./types/shop.js');
|
|
103
101
|
var appAPI = require('./types/appAPI.js');
|
|
104
102
|
var globalStyle = require('./types/global-style.js');
|
|
@@ -243,7 +241,6 @@ exports.makeStyleResponsiveState = makeStyle.makeStyleResponsiveState;
|
|
|
243
241
|
exports.makeStyleState = makeStyle.makeStyleState;
|
|
244
242
|
exports.makeWidth = makeStyle.makeWidth;
|
|
245
243
|
exports.removeNullUndefined = makeStyle.removeNullUndefined;
|
|
246
|
-
exports.convertTextAlignToJustify = align.convertTextAlignToJustify;
|
|
247
244
|
exports.checkAvailableVariantInStock = product.checkAvailableVariantInStock;
|
|
248
245
|
exports.getSelectedVariant = product.getSelectedVariant;
|
|
249
246
|
exports.parseSelectedOption = product.parseSelectedOption;
|
|
@@ -275,7 +272,6 @@ exports.getAspectRatioGlobalSize = size.getAspectRatioGlobalSize;
|
|
|
275
272
|
exports.getGlobalSizeGap = size.getGlobalSizeGap;
|
|
276
273
|
exports.getHeightByShapeGlobalSize = size.getHeightByShapeGlobalSize;
|
|
277
274
|
exports.getPaddingGlobalSize = size.getPaddingGlobalSize;
|
|
278
|
-
exports.getValueByDevice = size.getValueByDevice;
|
|
279
275
|
exports.getWidthByShapeGlobalSize = size.getWidthByShapeGlobalSize;
|
|
280
276
|
exports.getWidthHeightGlobalSize = size.getWidthHeightGlobalSize;
|
|
281
277
|
exports.makeGlobalSize = size.makeGlobalSize;
|
|
@@ -318,7 +314,6 @@ exports.useProductQuery = useProductQuery.useProductQuery;
|
|
|
318
314
|
exports.useProductsQuery = useProductsQuery.useProductsQuery;
|
|
319
315
|
exports.useProductsQueryAll = useProductsQuery.useProductsQueryAll;
|
|
320
316
|
exports.useCurrentDevice = useCurrentDevice.useCurrentDevice;
|
|
321
|
-
exports.formatMoney = useFormatMoney.formatMoney;
|
|
322
317
|
exports.shopifyPriceRounding = useFormatMoney.shopifyPriceRounding;
|
|
323
318
|
exports.useFormatMoney = useFormatMoney.useFormatMoney;
|
|
324
319
|
exports.useLazyVideo = useLazyVideo.useLazyVideo;
|
|
@@ -357,14 +352,6 @@ exports.useProductListStyles = useProductList.useProductListStyles;
|
|
|
357
352
|
exports.useSuspenseFetch = useSuspenseFetch.default;
|
|
358
353
|
exports.useSwatchesOptions = useSwatchesOptions.default;
|
|
359
354
|
exports.useInitialSwatchesOptions = useInitialSwatchesOptions.default;
|
|
360
|
-
Object.defineProperty(exports, 'InteractionTargetEvent', {
|
|
361
|
-
enumerable: true,
|
|
362
|
-
get: function () { return custom.InteractionTargetEvent; }
|
|
363
|
-
});
|
|
364
|
-
Object.defineProperty(exports, 'InteractionTriggerEvent', {
|
|
365
|
-
enumerable: true,
|
|
366
|
-
get: function () { return custom.InteractionTriggerEvent; }
|
|
367
|
-
});
|
|
368
355
|
exports.ShopType = shop$1;
|
|
369
356
|
exports.AppAPIType = appAPI;
|
|
370
357
|
exports.OptionNormalStyle = globalStyle.OptionNormalStyle;
|