@gem-sdk/core 1.24.4 → 1.25.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 +443 -0
- package/dist/cjs/components/ComponentWrapperPreview.js +37 -4
- package/dist/cjs/components/Render.liquid.js +8 -0
- package/dist/cjs/components/RenderCustomCode.js +2 -0
- package/dist/cjs/components/resize/Resize.js +16 -0
- package/dist/cjs/components/resize/Spacing.js +132 -0
- package/dist/cjs/components/theme-section/CreateThemeSection.js +117 -0
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +36 -0
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +102 -0
- package/dist/cjs/components/toolbar/Tooltip.js +22 -0
- package/dist/cjs/contexts/BuilderPreviewContext.js +36 -4
- package/dist/cjs/contexts/ShopContext.js +10 -0
- package/dist/cjs/helpers/filter-toolbar-preview.js +14 -0
- package/dist/cjs/helpers/is-empty-children.js +4 -1
- package/dist/cjs/helpers/make-style.js +8 -0
- package/dist/cjs/helpers/size.js +54 -0
- package/dist/cjs/helpers/typography.js +10 -9
- package/dist/cjs/hooks/useProduct.js +9 -1
- package/dist/cjs/index.js +7 -0
- package/dist/esm/components/ComponentToolbarPreview.js +441 -0
- package/dist/esm/components/ComponentWrapperPreview.js +38 -5
- package/dist/esm/components/Render.liquid.js +8 -0
- package/dist/esm/components/RenderCustomCode.js +2 -0
- package/dist/esm/components/resize/Resize.js +12 -0
- package/dist/esm/components/resize/Spacing.js +128 -0
- package/dist/esm/components/theme-section/CreateThemeSection.js +115 -0
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +34 -0
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +100 -0
- package/dist/esm/components/toolbar/Tooltip.js +18 -0
- package/dist/esm/contexts/BuilderPreviewContext.js +36 -4
- package/dist/esm/contexts/ShopContext.js +10 -0
- package/dist/esm/helpers/filter-toolbar-preview.js +9 -0
- package/dist/esm/helpers/is-empty-children.js +4 -1
- package/dist/esm/helpers/make-style.js +8 -1
- package/dist/esm/helpers/size.js +51 -1
- package/dist/esm/helpers/typography.js +10 -9
- package/dist/esm/hooks/useProduct.js +9 -1
- package/dist/esm/index.js +3 -2
- package/dist/types/index.d.ts +81 -9
- package/package.json +3 -3
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import 'zustand';
|
|
4
|
+
import { useBuilderPreviewStore } from '../../contexts/BuilderPreviewContext.js';
|
|
5
|
+
import 'swr';
|
|
6
|
+
import '@gem-sdk/adapter-shopify';
|
|
7
|
+
import 'swr/mutation';
|
|
8
|
+
import 'vanilla-lazyload';
|
|
9
|
+
import '../../hooks/useCartUI.js';
|
|
10
|
+
import 'react-transition-group';
|
|
11
|
+
import '@gem-sdk/core';
|
|
12
|
+
import '../../helpers/convert.js';
|
|
13
|
+
|
|
14
|
+
function Spacing(props) {
|
|
15
|
+
const isThemeSectionEditor = useBuilderPreviewStore((s)=>s.isThemeSectionEditor);
|
|
16
|
+
const $bottomDrag = useRef(null);
|
|
17
|
+
const $bottomBg = useRef(null);
|
|
18
|
+
const delayMouseMove = useRef(null);
|
|
19
|
+
const isDragging = useRef(false);
|
|
20
|
+
const startY = useRef(0);
|
|
21
|
+
const marginBottom = useRef(0);
|
|
22
|
+
const getNewValueMargin = (event)=>{
|
|
23
|
+
const top = event.clientY;
|
|
24
|
+
const diffY = Math.ceil(top - startY.current);
|
|
25
|
+
const currentValue = marginBottom.current || 0;
|
|
26
|
+
const newValue = currentValue + diffY >= 0 ? `${currentValue + diffY}px` : `0px`;
|
|
27
|
+
return {
|
|
28
|
+
newValue
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const onMouseMoveDocument = (event)=>{
|
|
32
|
+
if ($bottomDrag.current && $bottomBg.current) {
|
|
33
|
+
// $bottomDrag.current.
|
|
34
|
+
const { newValue } = getNewValueMargin(event);
|
|
35
|
+
$bottomBg.current.style.height = newValue;
|
|
36
|
+
$bottomDrag.current.style.top = newValue;
|
|
37
|
+
const $component = $bottomDrag.current.closest('[data-toolbar-wrap]');
|
|
38
|
+
if ($component) {
|
|
39
|
+
$component.style.marginBottom = newValue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const onMouseUpDocument = ()=>{
|
|
44
|
+
endDrag();
|
|
45
|
+
};
|
|
46
|
+
const startDrag = ()=>{
|
|
47
|
+
if (delayMouseMove.current) clearTimeout(delayMouseMove.current);
|
|
48
|
+
delayMouseMove.current = setTimeout(()=>{
|
|
49
|
+
isDragging.current = true;
|
|
50
|
+
const event = new CustomEvent('editor:toolbar:resize-spacing', {
|
|
51
|
+
bubbles: true,
|
|
52
|
+
detail: {
|
|
53
|
+
value: true
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
window.dispatchEvent(event);
|
|
57
|
+
document.addEventListener('mousemove', onMouseMoveDocument);
|
|
58
|
+
document.addEventListener('mouseup', onMouseUpDocument);
|
|
59
|
+
}, 100);
|
|
60
|
+
};
|
|
61
|
+
const endDrag = ()=>{
|
|
62
|
+
if (delayMouseMove.current) clearTimeout(delayMouseMove.current);
|
|
63
|
+
isDragging.current = false;
|
|
64
|
+
const event = new CustomEvent('editor:toolbar:resize-spacing', {
|
|
65
|
+
bubbles: true,
|
|
66
|
+
detail: {
|
|
67
|
+
value: false
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
window.dispatchEvent(event);
|
|
71
|
+
if ($bottomDrag.current) {
|
|
72
|
+
const style = getComputedStyle($bottomDrag.current);
|
|
73
|
+
const marginBottom = style.top;
|
|
74
|
+
const event = new CustomEvent('editor:toolbar:change-margin-bottom', {
|
|
75
|
+
bubbles: true,
|
|
76
|
+
detail: {
|
|
77
|
+
componentUid: props.uid,
|
|
78
|
+
marginBottom
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
window.dispatchEvent(event);
|
|
82
|
+
}
|
|
83
|
+
const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
|
|
84
|
+
if ($component) {
|
|
85
|
+
$component.style.marginBottom = '';
|
|
86
|
+
}
|
|
87
|
+
document.removeEventListener('mousemove', onMouseMoveDocument);
|
|
88
|
+
document.removeEventListener('mouseup', onMouseUpDocument);
|
|
89
|
+
};
|
|
90
|
+
const onMouseDown = (event)=>{
|
|
91
|
+
if ($bottomDrag.current) {
|
|
92
|
+
const style = getComputedStyle($bottomDrag.current);
|
|
93
|
+
startY.current = event.clientY;
|
|
94
|
+
marginBottom.current = parseFloat(style.top);
|
|
95
|
+
startDrag();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const onMouseUp = ()=>{
|
|
99
|
+
endDrag();
|
|
100
|
+
};
|
|
101
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
102
|
+
children: props.tag !== 'Section' && /*#__PURE__*/ jsx("div", {
|
|
103
|
+
"data-spacing": true,
|
|
104
|
+
"data-spacing-theme-section": isThemeSectionEditor,
|
|
105
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
106
|
+
"data-spacing-margin-bottom": true,
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsx("div", {
|
|
109
|
+
"data-spacing-margin-bottom-bg": true,
|
|
110
|
+
ref: $bottomBg,
|
|
111
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
112
|
+
"data-spacing-margin-bottom-value": true
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsx("div", {
|
|
116
|
+
ref: $bottomDrag,
|
|
117
|
+
"data-spacing-margin-bottom-drag": true,
|
|
118
|
+
onMouseDown: onMouseDown,
|
|
119
|
+
onMouseUp: onMouseUp,
|
|
120
|
+
role: "presentation"
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { Spacing as default };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import { ThemeSectionTooltip } from './ThemeSectionTooltip.js';
|
|
4
|
+
import 'zustand';
|
|
5
|
+
import { useShopStore } from '../../contexts/ShopContext.js';
|
|
6
|
+
import '@gem-sdk/adapter-shopify';
|
|
7
|
+
import 'swr';
|
|
8
|
+
import 'swr/mutation';
|
|
9
|
+
import 'vanilla-lazyload';
|
|
10
|
+
import '../../hooks/useCartUI.js';
|
|
11
|
+
import '../../helpers/convert.js';
|
|
12
|
+
|
|
13
|
+
const SHOW_TOOLTIP_TIMEOUT = 600;
|
|
14
|
+
const NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP = 1;
|
|
15
|
+
const LIMIT_PLANS = [
|
|
16
|
+
'starter',
|
|
17
|
+
'trial',
|
|
18
|
+
'trial2022'
|
|
19
|
+
];
|
|
20
|
+
const CreateThemeSection = ({ ...props })=>{
|
|
21
|
+
const shopPlan = useShopStore((s)=>s.plan);
|
|
22
|
+
const createThemeSectionCount = useShopStore((s)=>s.createThemeSectionCount);
|
|
23
|
+
const isLimit = LIMIT_PLANS.includes(shopPlan ?? '');
|
|
24
|
+
const isRenderTooltip = isLimit || createThemeSectionCount === undefined || createThemeSectionCount < NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP;
|
|
25
|
+
const timeoutRef = useRef();
|
|
26
|
+
const [isShowTooltip, setIsShowTooltip] = useState(false);
|
|
27
|
+
const showTooltip = ()=>{
|
|
28
|
+
if (!isRenderTooltip) return;
|
|
29
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
30
|
+
timeoutRef.current = setTimeout(()=>{
|
|
31
|
+
setIsShowTooltip(true);
|
|
32
|
+
}, SHOW_TOOLTIP_TIMEOUT);
|
|
33
|
+
};
|
|
34
|
+
const hideTooltip = ()=>{
|
|
35
|
+
if (!isRenderTooltip) return;
|
|
36
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
37
|
+
setIsShowTooltip(false);
|
|
38
|
+
};
|
|
39
|
+
const onActions = (e, options)=>{
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
if (options?.disabled) return;
|
|
43
|
+
isLimit ? onUpgrade() : onCreate();
|
|
44
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
45
|
+
setIsShowTooltip(false);
|
|
46
|
+
};
|
|
47
|
+
const onUpgrade = ()=>{
|
|
48
|
+
const eventUpgrade = new CustomEvent('editor:toolbar:upgrade', {
|
|
49
|
+
bubbles: true
|
|
50
|
+
});
|
|
51
|
+
window.dispatchEvent(eventUpgrade);
|
|
52
|
+
};
|
|
53
|
+
const onCreate = ()=>{
|
|
54
|
+
const eventCreate = new CustomEvent('editor:toolbar:create-theme-section', {
|
|
55
|
+
bubbles: true,
|
|
56
|
+
detail: {
|
|
57
|
+
componentUid: props.uid
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
window.dispatchEvent(eventCreate);
|
|
61
|
+
};
|
|
62
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
63
|
+
children: /*#__PURE__*/ jsxs(ThemeSectionTooltip, {
|
|
64
|
+
isLimit: isLimit,
|
|
65
|
+
isShow: isShowTooltip,
|
|
66
|
+
isRender: isRenderTooltip,
|
|
67
|
+
onActions: onActions,
|
|
68
|
+
onMouseEnter: showTooltip,
|
|
69
|
+
onMouseLeave: hideTooltip,
|
|
70
|
+
children: [
|
|
71
|
+
isRenderTooltip && /*#__PURE__*/ jsx("div", {
|
|
72
|
+
"data-toolbar-create-theme-section": true,
|
|
73
|
+
children: "You can create reusable sections"
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ jsx("div", {
|
|
76
|
+
"data-toolbar-active-create-theme-section-wrapper": true,
|
|
77
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
78
|
+
"data-toolbar-active-create-theme-section": true,
|
|
79
|
+
onClick: (e)=>onActions(e, {
|
|
80
|
+
disabled: isLimit
|
|
81
|
+
}),
|
|
82
|
+
"aria-hidden": "true",
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ jsxs("svg", {
|
|
85
|
+
width: "16",
|
|
86
|
+
height: "16",
|
|
87
|
+
viewBox: "0 0 16 16",
|
|
88
|
+
fill: "none",
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsx("path", {
|
|
91
|
+
d: "M1 2C1 1.44772 1.44772 1 2 1H6C6.55228 1 7 1.44772 7 2V6C7 6.55228 6.55228 7 6 7H2C1.44772 7 1 6.55228 1 6V2Z",
|
|
92
|
+
fill: "#F9F9F9"
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ jsx("path", {
|
|
95
|
+
d: "M9 10C9 9.44772 9.44772 9 10 9H14C14.5523 9 15 9.44772 15 10V14C15 14.5523 14.5523 15 14 15H10C9.44772 15 9 14.5523 9 14V10Z",
|
|
96
|
+
fill: "#F9F9F9"
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ jsx("path", {
|
|
99
|
+
d: "M2 9C1.44772 9 1 9.44772 1 10V14C1 14.5523 1.44772 15 2 15H6C6.55228 15 7 14.5523 7 14V10C7 9.44772 6.55228 9 6 9H2Z",
|
|
100
|
+
fill: "#F9F9F9"
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
}),
|
|
104
|
+
/*#__PURE__*/ jsx("p", {
|
|
105
|
+
children: "Create Theme Section"
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export { CreateThemeSection };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
const ThemeSectionStatus = ({ ...props })=>{
|
|
4
|
+
const isRenderThemeSectionStatus = props.tag === 'Section' && props?.isThemeSection && props?.needPublishing;
|
|
5
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
6
|
+
children: isRenderThemeSectionStatus && /*#__PURE__*/ jsxs("div", {
|
|
7
|
+
"data-theme-section-status": true,
|
|
8
|
+
children: [
|
|
9
|
+
/*#__PURE__*/ jsx("div", {
|
|
10
|
+
"data-theme-section-status-icon": true,
|
|
11
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
12
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
13
|
+
width: "16",
|
|
14
|
+
height: "16",
|
|
15
|
+
viewBox: "0 0 16 16",
|
|
16
|
+
fill: "none",
|
|
17
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
18
|
+
fillRule: "evenodd",
|
|
19
|
+
clipRule: "evenodd",
|
|
20
|
+
d: "M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM8.4668 4.61597C8.4668 4.89211 8.24294 5.11597 7.9668 5.11597C7.69065 5.11597 7.4668 4.89211 7.4668 4.61597C7.4668 4.33982 7.69065 4.11597 7.9668 4.11597C8.24294 4.11597 8.4668 4.33982 8.4668 4.61597ZM6.91309 5.48633C6.63694 5.48633 6.41309 5.71019 6.41309 5.98633C6.41309 6.26247 6.63694 6.48633 6.91309 6.48633H7.56006V10.3839C7.56006 10.9362 8.00777 11.3839 8.56006 11.3839H9.57144C9.84758 11.3839 10.0714 11.1601 10.0714 10.8839C10.0714 10.6078 9.84758 10.3839 9.57144 10.3839H8.56006V6.48633C8.56006 5.93404 8.11234 5.48633 7.56006 5.48633H6.91309Z",
|
|
21
|
+
fill: "#9144DA"
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx("span", {
|
|
26
|
+
"data-theme-section-status-text": true,
|
|
27
|
+
children: "Need to republish. Go to global edit and publish this section"
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { ThemeSectionStatus };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { Transition } from 'react-transition-group';
|
|
4
|
+
import { cls } from '@gem-sdk/core';
|
|
5
|
+
|
|
6
|
+
const TRANSITION_DURATION = 350;
|
|
7
|
+
const defaultStyles = {
|
|
8
|
+
transition: `opacity ${TRANSITION_DURATION}ms ease-out`,
|
|
9
|
+
opacity: 0
|
|
10
|
+
};
|
|
11
|
+
const transitions = {
|
|
12
|
+
entering: {
|
|
13
|
+
opacity: 1
|
|
14
|
+
},
|
|
15
|
+
entered: {
|
|
16
|
+
opacity: 1
|
|
17
|
+
},
|
|
18
|
+
exiting: {
|
|
19
|
+
opacity: 0
|
|
20
|
+
},
|
|
21
|
+
exited: {
|
|
22
|
+
opacity: 0
|
|
23
|
+
},
|
|
24
|
+
unmounted: {
|
|
25
|
+
opacity: 0
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const ThemeSectionTooltip = ({ isShow, isLimit, isRender, children, onMouseEnter, onMouseLeave, onActions })=>{
|
|
29
|
+
const nodeRef = useRef(null);
|
|
30
|
+
const actionBtnLabel = isLimit ? 'Upgrade to create Theme Section' : 'Create Theme Section';
|
|
31
|
+
const openHelpCenter = ()=>{
|
|
32
|
+
const url = 'https://help.gempages.net/articles/theme-section';
|
|
33
|
+
window.open(url, '_blank');
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
36
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
37
|
+
className: "theme-section-tooltip-wrapper",
|
|
38
|
+
onMouseEnter: onMouseEnter,
|
|
39
|
+
onMouseLeave: onMouseLeave,
|
|
40
|
+
children: [
|
|
41
|
+
children,
|
|
42
|
+
isRender && /*#__PURE__*/ jsx(Transition, {
|
|
43
|
+
in: isShow,
|
|
44
|
+
timeout: TRANSITION_DURATION,
|
|
45
|
+
nodeRef: nodeRef,
|
|
46
|
+
unmountOnExit: true,
|
|
47
|
+
children: (state)=>/*#__PURE__*/ jsxs("div", {
|
|
48
|
+
className: "theme-section-tooltip",
|
|
49
|
+
ref: nodeRef,
|
|
50
|
+
style: {
|
|
51
|
+
...defaultStyles,
|
|
52
|
+
...transitions[state]
|
|
53
|
+
},
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ jsx("div", {
|
|
56
|
+
className: "theme-section-tooltip__image",
|
|
57
|
+
children: /*#__PURE__*/ jsx("img", {
|
|
58
|
+
src: "https://ucarecdn.com/6a9f408a-aa8c-434a-890b-81067a14aceb/-/format/auto/-/preview/1920x1920/-/quality/lighter/theme-section-illustration.png",
|
|
59
|
+
alt: ""
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ jsxs("div", {
|
|
63
|
+
className: "theme-section-tooltip__body",
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ jsx("div", {
|
|
66
|
+
className: "theme-section-tooltip__body-title",
|
|
67
|
+
children: "Create once, use everywhere with Theme Section"
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ jsx("div", {
|
|
70
|
+
className: "theme-section-tooltip__body-desc",
|
|
71
|
+
children: "A global section that can be used on all your GemPages & Shopify pages."
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ jsxs("div", {
|
|
76
|
+
className: cls('theme-section-tooltip__action', {
|
|
77
|
+
'theme-section-tooltip__action-limit': isLimit
|
|
78
|
+
}),
|
|
79
|
+
children: [
|
|
80
|
+
/*#__PURE__*/ jsx("button", {
|
|
81
|
+
onClick: (e)=>onActions(e),
|
|
82
|
+
children: actionBtnLabel
|
|
83
|
+
}),
|
|
84
|
+
isLimit && /*#__PURE__*/ jsx("div", {
|
|
85
|
+
onClick: openHelpCenter,
|
|
86
|
+
"aria-hidden": true,
|
|
87
|
+
className: "theme-section-tooltip__action-learn-more",
|
|
88
|
+
children: "Learn more about Theme Section"
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { ThemeSectionTooltip };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
function Tooltip({ children, enable, text = 'Tooltip Text', position = 'right', ...props }) {
|
|
4
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
5
|
+
...props,
|
|
6
|
+
"data-toolbar-tooltip-trigger": true,
|
|
7
|
+
children: [
|
|
8
|
+
children,
|
|
9
|
+
enable && /*#__PURE__*/ jsx("div", {
|
|
10
|
+
"data-toolbar-tooltip": true,
|
|
11
|
+
"data-toolbar-tooltip-position": position,
|
|
12
|
+
children: text
|
|
13
|
+
})
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Tooltip as default };
|
|
@@ -26,9 +26,12 @@ const root = {
|
|
|
26
26
|
label: 'Root',
|
|
27
27
|
childrens: []
|
|
28
28
|
};
|
|
29
|
-
const createBuilderPreviewProvider = (args)=>createStore((set, get)=>({
|
|
29
|
+
const createBuilderPreviewProvider = (args, isThemeSectionEditor)=>createStore((set, get)=>({
|
|
30
30
|
state: args,
|
|
31
31
|
loaded: false,
|
|
32
|
+
isThemeSectionEditor: !!isThemeSectionEditor,
|
|
33
|
+
dynamicProduct: null,
|
|
34
|
+
dynamicCollection: null,
|
|
32
35
|
addItem: (args)=>{
|
|
33
36
|
const { position, data } = args;
|
|
34
37
|
const state = get().state;
|
|
@@ -388,14 +391,43 @@ const createBuilderPreviewProvider = (args)=>createStore((set, get)=>({
|
|
|
388
391
|
ROOT: cloneDeep(ROOT)
|
|
389
392
|
}
|
|
390
393
|
});
|
|
394
|
+
},
|
|
395
|
+
getParents: (id, limit)=>{
|
|
396
|
+
const state = get().state;
|
|
397
|
+
const parents = [];
|
|
398
|
+
let index = 0;
|
|
399
|
+
let currentId = id;
|
|
400
|
+
// eslint-disable-next-line no-constant-condition
|
|
401
|
+
while(true){
|
|
402
|
+
if (limit && index >= limit) break;
|
|
403
|
+
const parent = Object.entries(state).find(([, value])=>value.type !== 'section' && value.childrens?.includes(currentId));
|
|
404
|
+
if (!parent) break;
|
|
405
|
+
const [, parentItem] = parent;
|
|
406
|
+
if (!parentItem) break;
|
|
407
|
+
parents.push(parentItem);
|
|
408
|
+
currentId = parentItem.uid;
|
|
409
|
+
index++;
|
|
410
|
+
}
|
|
411
|
+
return parents;
|
|
412
|
+
},
|
|
413
|
+
setDynamicProduct: (data)=>{
|
|
414
|
+
set({
|
|
415
|
+
dynamicProduct: data
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
setDynamicCollection: (data)=>{
|
|
419
|
+
set({
|
|
420
|
+
dynamicCollection: data
|
|
421
|
+
});
|
|
391
422
|
}
|
|
392
423
|
}));
|
|
393
|
-
const BuilderPreviewProvider = ({ children, state, lazy, ...passProps })=>{
|
|
424
|
+
const BuilderPreviewProvider = ({ children, state, isThemeSectionEditor, lazy, ...passProps })=>{
|
|
394
425
|
const Component = lazy ? Suspense : Fragment;
|
|
395
426
|
const value = useMemo(()=>{
|
|
396
|
-
return createBuilderPreviewProvider(state);
|
|
427
|
+
return createBuilderPreviewProvider(state, isThemeSectionEditor);
|
|
397
428
|
}, [
|
|
398
|
-
state
|
|
429
|
+
state,
|
|
430
|
+
isThemeSectionEditor
|
|
399
431
|
]);
|
|
400
432
|
return /*#__PURE__*/ jsx(Component, {
|
|
401
433
|
children: /*#__PURE__*/ jsx(BuilderPreviewContext.Provider, {
|
|
@@ -35,6 +35,16 @@ const createShopStoreProvider = (data)=>createStore((set)=>({
|
|
|
35
35
|
storefrontUrl: url,
|
|
36
36
|
storefrontToken: token
|
|
37
37
|
});
|
|
38
|
+
},
|
|
39
|
+
changeCreateThemeSectionCount: (count)=>{
|
|
40
|
+
set({
|
|
41
|
+
createThemeSectionCount: count
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
changeShopPlan: (plan)=>{
|
|
45
|
+
set({
|
|
46
|
+
plan
|
|
47
|
+
});
|
|
38
48
|
}
|
|
39
49
|
}));
|
|
40
50
|
const ShopProvider = ({ children, addons, storeOption, queryOption, ...passProps })=>{
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Children } from 'react';
|
|
2
|
+
import { ComponentToolbarPreview } from '../components/ComponentToolbarPreview.js';
|
|
3
|
+
|
|
4
|
+
const filterToolbarPreview = (children, keep = false)=>{
|
|
5
|
+
const arrChild = Children.toArray(children);
|
|
6
|
+
return arrChild.filter((child)=>!keep ? child?.type != ComponentToolbarPreview : child?.type == ComponentToolbarPreview);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { filterToolbarPreview as default, filterToolbarPreview };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Children } from 'react';
|
|
2
|
+
import { ComponentToolbarPreview } from '../components/ComponentToolbarPreview.js';
|
|
2
3
|
|
|
3
4
|
const isEmptyChildren = (children)=>{
|
|
4
|
-
|
|
5
|
+
let arrChild = Children.toArray(children);
|
|
6
|
+
arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview);
|
|
7
|
+
return Children.count(arrChild) < 1 || !children;
|
|
5
8
|
};
|
|
6
9
|
|
|
7
10
|
export { isEmptyChildren as default, isEmptyChildren };
|
|
@@ -73,6 +73,13 @@ const makeWidth = (widthValue, fullWidthValue)=>{
|
|
|
73
73
|
mobile: getVal('mobile', widthValue, fullWidthValue)
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
+
const makeGlobalSizeWidthResponsive = (globalSize)=>{
|
|
77
|
+
return {
|
|
78
|
+
'--w': globalSize?.desktop?.width,
|
|
79
|
+
'--w-tablet': globalSize?.tablet?.width,
|
|
80
|
+
'--w-mobile': globalSize?.mobile?.width
|
|
81
|
+
};
|
|
82
|
+
};
|
|
76
83
|
const makeHeight = (heighValue, autoHeight)=>{
|
|
77
84
|
const getVal = (deviceValue, heighValue, autoHeight)=>{
|
|
78
85
|
const heightVal = heighValue?.[deviceValue];
|
|
@@ -125,4 +132,4 @@ const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
|
|
|
125
132
|
};
|
|
126
133
|
};
|
|
127
134
|
|
|
128
|
-
export { makeAspectRatio, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined };
|
|
135
|
+
export { makeAspectRatio, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined };
|
package/dist/esm/helpers/size.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { makeStyleResponsive } from './make-style.js';
|
|
1
2
|
import { devicesMapping } from './constant.js';
|
|
2
3
|
|
|
3
4
|
function getCustomSizeCSSByDevice(size, device) {
|
|
@@ -27,5 +28,54 @@ const composeSizeCss = (spacing)=>{
|
|
|
27
28
|
${sizeVerti ? `padding-top: ${sizeVerti}; padding-bottom: ${sizeVerti};` : undefined}
|
|
28
29
|
`;
|
|
29
30
|
};
|
|
31
|
+
const makeGlobalSize = (globalSize)=>{
|
|
32
|
+
return {
|
|
33
|
+
width: makeStyleWithDefault('w', getWidthHeightGlobalSize('width', globalSize), {
|
|
34
|
+
desktop: '--g-ct-w',
|
|
35
|
+
tablet: '--g-ct-w',
|
|
36
|
+
mobile: '--g-ct-w'
|
|
37
|
+
}),
|
|
38
|
+
height: makeStyleResponsive('h', getWidthHeightGlobalSize('height', globalSize)),
|
|
39
|
+
padding: getPaddingGlobalSize(globalSize)
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const makeStyleWithDefault = (name, value, defaultVal)=>{
|
|
43
|
+
return {
|
|
44
|
+
[`--${name}`]: value?.desktop === 'default' ? `var(${defaultVal?.desktop})` : value?.desktop,
|
|
45
|
+
[`--${name}-tablet`]: value?.tablet === 'default' ? `var(${defaultVal?.tablet})` : value?.tablet,
|
|
46
|
+
[`--${name}-mobile`]: value?.mobile === 'default' ? `var(${defaultVal?.mobile})` : value?.mobile
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const getWidthHeightGlobalSize = (type, globalSize)=>{
|
|
50
|
+
if (!globalSize) return {};
|
|
51
|
+
const data = {
|
|
52
|
+
desktop: globalSize?.desktop?.[type],
|
|
53
|
+
tablet: globalSize?.tablet?.[type],
|
|
54
|
+
mobile: globalSize?.mobile?.[type]
|
|
55
|
+
};
|
|
56
|
+
if (data.desktop === undefined) {
|
|
57
|
+
data.desktop = 'auto';
|
|
58
|
+
}
|
|
59
|
+
if (data.tablet === undefined) {
|
|
60
|
+
data.tablet = data.desktop;
|
|
61
|
+
}
|
|
62
|
+
if (data.mobile === undefined) {
|
|
63
|
+
data.mobile = data.tablet;
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
};
|
|
67
|
+
function getCustomPaddingSizeCSSByDevice(globalSize, device) {
|
|
68
|
+
if (!globalSize || !device) return {};
|
|
69
|
+
const suffix = devicesMapping[device] ?? '';
|
|
70
|
+
return {
|
|
71
|
+
[`--pl${suffix}`]: globalSize?.[device]?.padding?.left,
|
|
72
|
+
[`--pr${suffix}`]: globalSize?.[device]?.padding?.right,
|
|
73
|
+
[`--pt${suffix}`]: globalSize?.[device]?.padding?.top,
|
|
74
|
+
[`--pb${suffix}`]: globalSize?.[device]?.padding?.bottom
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const getPaddingGlobalSize = (globalSize)=>{
|
|
78
|
+
return Object.assign({}, getCustomPaddingSizeCSSByDevice(globalSize, 'desktop'), getCustomPaddingSizeCSSByDevice(globalSize, 'tablet'), getCustomPaddingSizeCSSByDevice(globalSize, 'mobile'));
|
|
79
|
+
};
|
|
30
80
|
|
|
31
|
-
export { composeSize, composeSizeCss, genSizeClass };
|
|
81
|
+
export { composeSize, composeSizeCss, genSizeClass, getPaddingGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeStyleWithDefault };
|
|
@@ -16,20 +16,21 @@ const composeTypographyCss = (typography)=>{
|
|
|
16
16
|
${lineHeight ? `line-height: ${lineHeight};` : ''}
|
|
17
17
|
`;
|
|
18
18
|
};
|
|
19
|
-
const composeTypographyV2Css = (typography)=>{
|
|
19
|
+
const composeTypographyV2Css = (typography, isImportant)=>{
|
|
20
20
|
const typographyCustom = typography?.custom;
|
|
21
21
|
const { fontFamily, fontSize, fontWeight, lineHeight, letterSpacing } = typographyCustom ?? {};
|
|
22
22
|
const typographyAttrs = typography?.attrs;
|
|
23
23
|
const { bold, italic, underline, transform } = typographyAttrs ?? {};
|
|
24
|
+
const composeImportant = isImportant ? '!important' : '';
|
|
24
25
|
return `
|
|
25
|
-
${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily});` : ''}
|
|
26
|
-
${fontSize?.desktop ? `font-size: ${fontSize?.desktop};` : ''}
|
|
27
|
-
${bold ? `font-weight: bold;` : fontWeight ? `font-weight: ${fontWeight};` : ''}
|
|
28
|
-
${letterSpacing ? `letter-spacing: ${letterSpacing};` : ''}
|
|
29
|
-
${lineHeight ? `line-height: ${lineHeight};` : ''}
|
|
30
|
-
${italic ? `font-style: italic;` : ''}
|
|
31
|
-
${underline ? `text-decoration-line: underline;` : ''}
|
|
32
|
-
${transform ? `text-transform: ${transform};` : ''}
|
|
26
|
+
${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily}) ${composeImportant};` : ''}
|
|
27
|
+
${fontSize?.desktop ? `font-size: ${fontSize?.desktop} ${composeImportant};` : ''}
|
|
28
|
+
${bold ? `font-weight: bold;` : fontWeight ? `font-weight: ${fontWeight} ${composeImportant};` : ''}
|
|
29
|
+
${letterSpacing ? `letter-spacing: ${letterSpacing} ${composeImportant};` : ''}
|
|
30
|
+
${lineHeight ? `line-height: ${lineHeight} ${composeImportant};` : ''}
|
|
31
|
+
${italic ? `font-style: italic${composeImportant};` : ''}
|
|
32
|
+
${underline ? `text-decoration-line: underline ${composeImportant};` : ''}
|
|
33
|
+
${transform ? `text-transform: ${transform} ${composeImportant};` : ''}
|
|
33
34
|
`;
|
|
34
35
|
};
|
|
35
36
|
function getCustomCSSByDevice(typography, device) {
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import { useProductStore } from '../contexts/ProductContext.js';
|
|
3
3
|
import { flattenConnection } from '../helpers/flatten-connection.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'zustand';
|
|
4
6
|
import 'swr';
|
|
7
|
+
import '@gem-sdk/adapter-shopify';
|
|
8
|
+
import 'swr/mutation';
|
|
9
|
+
import 'vanilla-lazyload';
|
|
10
|
+
import './useCartUI.js';
|
|
11
|
+
import { checkInStock } from '../helpers/variant.js';
|
|
12
|
+
import 'react-transition-group';
|
|
13
|
+
import '@gem-sdk/core';
|
|
5
14
|
import { getSelectedVariant } from '../helpers/product.js';
|
|
6
15
|
import '../helpers/convert.js';
|
|
7
|
-
import { checkInStock } from '../helpers/variant.js';
|
|
8
16
|
|
|
9
17
|
const useUniqProductID = ()=>{
|
|
10
18
|
return useProductStore((s)=>s.uiqueId);
|
package/dist/esm/index.js
CHANGED
|
@@ -30,7 +30,8 @@ export { default as globalEvent } from './helpers/GlobalEvent.js';
|
|
|
30
30
|
export { default as isBrowser } from './helpers/is-browser.js';
|
|
31
31
|
export { default as isSafari } from './helpers/is-safari.js';
|
|
32
32
|
export { isEmptyChildren } from './helpers/is-empty-children.js';
|
|
33
|
-
export {
|
|
33
|
+
export { filterToolbarPreview } from './helpers/filter-toolbar-preview.js';
|
|
34
|
+
export { makeAspectRatio, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined } from './helpers/make-style.js';
|
|
34
35
|
export { normalizeBuilderData } from './helpers/normalize-builder-data.js';
|
|
35
36
|
export { prefetchQueries } from './helpers/prefetch-queries.js';
|
|
36
37
|
export { composeSpacing, getSpacingVariable } from './helpers/spacing.js';
|
|
@@ -51,7 +52,7 @@ import * as tiktokpixel from './helpers/tracking/tiktokpixel.js';
|
|
|
51
52
|
export { tiktokpixel };
|
|
52
53
|
export { RenderIf, composeMemo, dataStringify, props, styles, template } from './helpers/render.js';
|
|
53
54
|
export { baseAssetURL, isLocalEnv } from './helpers/convert.js';
|
|
54
|
-
export { composeSize, composeSizeCss, genSizeClass } from './helpers/size.js';
|
|
55
|
+
export { composeSize, composeSizeCss, genSizeClass, getPaddingGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeStyleWithDefault } from './helpers/size.js';
|
|
55
56
|
export { composeShadowCss, getStyleShadow, getStyleShadowState, parseValueWithUnit } from './helpers/shadow.js';
|
|
56
57
|
export { composeBackgroundCss, getStyleBackgroundByDevice, makeFixedBgAttachment } from './helpers/background.js';
|
|
57
58
|
export { generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey } from './helpers/query.js';
|