@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,132 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
require('zustand');
|
|
8
|
+
var BuilderPreviewContext = require('../../contexts/BuilderPreviewContext.js');
|
|
9
|
+
require('swr');
|
|
10
|
+
require('@gem-sdk/adapter-shopify');
|
|
11
|
+
require('swr/mutation');
|
|
12
|
+
require('vanilla-lazyload');
|
|
13
|
+
require('../../hooks/useCartUI.js');
|
|
14
|
+
require('react-transition-group');
|
|
15
|
+
require('@gem-sdk/core');
|
|
16
|
+
require('../../helpers/convert.js');
|
|
17
|
+
|
|
18
|
+
function Spacing(props) {
|
|
19
|
+
const isThemeSectionEditor = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.isThemeSectionEditor);
|
|
20
|
+
const $bottomDrag = react.useRef(null);
|
|
21
|
+
const $bottomBg = react.useRef(null);
|
|
22
|
+
const delayMouseMove = react.useRef(null);
|
|
23
|
+
const isDragging = react.useRef(false);
|
|
24
|
+
const startY = react.useRef(0);
|
|
25
|
+
const marginBottom = react.useRef(0);
|
|
26
|
+
const getNewValueMargin = (event)=>{
|
|
27
|
+
const top = event.clientY;
|
|
28
|
+
const diffY = Math.ceil(top - startY.current);
|
|
29
|
+
const currentValue = marginBottom.current || 0;
|
|
30
|
+
const newValue = currentValue + diffY >= 0 ? `${currentValue + diffY}px` : `0px`;
|
|
31
|
+
return {
|
|
32
|
+
newValue
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const onMouseMoveDocument = (event)=>{
|
|
36
|
+
if ($bottomDrag.current && $bottomBg.current) {
|
|
37
|
+
// $bottomDrag.current.
|
|
38
|
+
const { newValue } = getNewValueMargin(event);
|
|
39
|
+
$bottomBg.current.style.height = newValue;
|
|
40
|
+
$bottomDrag.current.style.top = newValue;
|
|
41
|
+
const $component = $bottomDrag.current.closest('[data-toolbar-wrap]');
|
|
42
|
+
if ($component) {
|
|
43
|
+
$component.style.marginBottom = newValue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const onMouseUpDocument = ()=>{
|
|
48
|
+
endDrag();
|
|
49
|
+
};
|
|
50
|
+
const startDrag = ()=>{
|
|
51
|
+
if (delayMouseMove.current) clearTimeout(delayMouseMove.current);
|
|
52
|
+
delayMouseMove.current = setTimeout(()=>{
|
|
53
|
+
isDragging.current = true;
|
|
54
|
+
const event = new CustomEvent('editor:toolbar:resize-spacing', {
|
|
55
|
+
bubbles: true,
|
|
56
|
+
detail: {
|
|
57
|
+
value: true
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
window.dispatchEvent(event);
|
|
61
|
+
document.addEventListener('mousemove', onMouseMoveDocument);
|
|
62
|
+
document.addEventListener('mouseup', onMouseUpDocument);
|
|
63
|
+
}, 100);
|
|
64
|
+
};
|
|
65
|
+
const endDrag = ()=>{
|
|
66
|
+
if (delayMouseMove.current) clearTimeout(delayMouseMove.current);
|
|
67
|
+
isDragging.current = false;
|
|
68
|
+
const event = new CustomEvent('editor:toolbar:resize-spacing', {
|
|
69
|
+
bubbles: true,
|
|
70
|
+
detail: {
|
|
71
|
+
value: false
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
window.dispatchEvent(event);
|
|
75
|
+
if ($bottomDrag.current) {
|
|
76
|
+
const style = getComputedStyle($bottomDrag.current);
|
|
77
|
+
const marginBottom = style.top;
|
|
78
|
+
const event = new CustomEvent('editor:toolbar:change-margin-bottom', {
|
|
79
|
+
bubbles: true,
|
|
80
|
+
detail: {
|
|
81
|
+
componentUid: props.uid,
|
|
82
|
+
marginBottom
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
window.dispatchEvent(event);
|
|
86
|
+
}
|
|
87
|
+
const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
|
|
88
|
+
if ($component) {
|
|
89
|
+
$component.style.marginBottom = '';
|
|
90
|
+
}
|
|
91
|
+
document.removeEventListener('mousemove', onMouseMoveDocument);
|
|
92
|
+
document.removeEventListener('mouseup', onMouseUpDocument);
|
|
93
|
+
};
|
|
94
|
+
const onMouseDown = (event)=>{
|
|
95
|
+
if ($bottomDrag.current) {
|
|
96
|
+
const style = getComputedStyle($bottomDrag.current);
|
|
97
|
+
startY.current = event.clientY;
|
|
98
|
+
marginBottom.current = parseFloat(style.top);
|
|
99
|
+
startDrag();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const onMouseUp = ()=>{
|
|
103
|
+
endDrag();
|
|
104
|
+
};
|
|
105
|
+
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
106
|
+
children: props.tag !== 'Section' && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
107
|
+
"data-spacing": true,
|
|
108
|
+
"data-spacing-theme-section": isThemeSectionEditor,
|
|
109
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
110
|
+
"data-spacing-margin-bottom": true,
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
113
|
+
"data-spacing-margin-bottom-bg": true,
|
|
114
|
+
ref: $bottomBg,
|
|
115
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
116
|
+
"data-spacing-margin-bottom-value": true
|
|
117
|
+
})
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
120
|
+
ref: $bottomDrag,
|
|
121
|
+
"data-spacing-margin-bottom-drag": true,
|
|
122
|
+
onMouseDown: onMouseDown,
|
|
123
|
+
onMouseUp: onMouseUp,
|
|
124
|
+
role: "presentation"
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
exports.default = Spacing;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var ThemeSectionTooltip = require('./ThemeSectionTooltip.js');
|
|
6
|
+
require('zustand');
|
|
7
|
+
var ShopContext = require('../../contexts/ShopContext.js');
|
|
8
|
+
require('@gem-sdk/adapter-shopify');
|
|
9
|
+
require('swr');
|
|
10
|
+
require('swr/mutation');
|
|
11
|
+
require('vanilla-lazyload');
|
|
12
|
+
require('../../hooks/useCartUI.js');
|
|
13
|
+
require('../../helpers/convert.js');
|
|
14
|
+
|
|
15
|
+
const SHOW_TOOLTIP_TIMEOUT = 600;
|
|
16
|
+
const NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP = 1;
|
|
17
|
+
const LIMIT_PLANS = [
|
|
18
|
+
'starter',
|
|
19
|
+
'trial',
|
|
20
|
+
'trial2022'
|
|
21
|
+
];
|
|
22
|
+
const CreateThemeSection = ({ ...props })=>{
|
|
23
|
+
const shopPlan = ShopContext.useShopStore((s)=>s.plan);
|
|
24
|
+
const createThemeSectionCount = ShopContext.useShopStore((s)=>s.createThemeSectionCount);
|
|
25
|
+
const isLimit = LIMIT_PLANS.includes(shopPlan ?? '');
|
|
26
|
+
const isRenderTooltip = isLimit || createThemeSectionCount === undefined || createThemeSectionCount < NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP;
|
|
27
|
+
const timeoutRef = react.useRef();
|
|
28
|
+
const [isShowTooltip, setIsShowTooltip] = react.useState(false);
|
|
29
|
+
const showTooltip = ()=>{
|
|
30
|
+
if (!isRenderTooltip) return;
|
|
31
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
32
|
+
timeoutRef.current = setTimeout(()=>{
|
|
33
|
+
setIsShowTooltip(true);
|
|
34
|
+
}, SHOW_TOOLTIP_TIMEOUT);
|
|
35
|
+
};
|
|
36
|
+
const hideTooltip = ()=>{
|
|
37
|
+
if (!isRenderTooltip) return;
|
|
38
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
39
|
+
setIsShowTooltip(false);
|
|
40
|
+
};
|
|
41
|
+
const onActions = (e, options)=>{
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
if (options?.disabled) return;
|
|
45
|
+
isLimit ? onUpgrade() : onCreate();
|
|
46
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
47
|
+
setIsShowTooltip(false);
|
|
48
|
+
};
|
|
49
|
+
const onUpgrade = ()=>{
|
|
50
|
+
const eventUpgrade = new CustomEvent('editor:toolbar:upgrade', {
|
|
51
|
+
bubbles: true
|
|
52
|
+
});
|
|
53
|
+
window.dispatchEvent(eventUpgrade);
|
|
54
|
+
};
|
|
55
|
+
const onCreate = ()=>{
|
|
56
|
+
const eventCreate = new CustomEvent('editor:toolbar:create-theme-section', {
|
|
57
|
+
bubbles: true,
|
|
58
|
+
detail: {
|
|
59
|
+
componentUid: props.uid
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
window.dispatchEvent(eventCreate);
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
65
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(ThemeSectionTooltip.ThemeSectionTooltip, {
|
|
66
|
+
isLimit: isLimit,
|
|
67
|
+
isShow: isShowTooltip,
|
|
68
|
+
isRender: isRenderTooltip,
|
|
69
|
+
onActions: onActions,
|
|
70
|
+
onMouseEnter: showTooltip,
|
|
71
|
+
onMouseLeave: hideTooltip,
|
|
72
|
+
children: [
|
|
73
|
+
isRenderTooltip && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
74
|
+
"data-toolbar-create-theme-section": true,
|
|
75
|
+
children: "You can create reusable sections"
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
78
|
+
"data-toolbar-active-create-theme-section-wrapper": true,
|
|
79
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
80
|
+
"data-toolbar-active-create-theme-section": true,
|
|
81
|
+
onClick: (e)=>onActions(e, {
|
|
82
|
+
disabled: isLimit
|
|
83
|
+
}),
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
87
|
+
width: "16",
|
|
88
|
+
height: "16",
|
|
89
|
+
viewBox: "0 0 16 16",
|
|
90
|
+
fill: "none",
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
93
|
+
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",
|
|
94
|
+
fill: "#F9F9F9"
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
97
|
+
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",
|
|
98
|
+
fill: "#F9F9F9"
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
101
|
+
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",
|
|
102
|
+
fill: "#F9F9F9"
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
}),
|
|
106
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
107
|
+
children: "Create Theme Section"
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
exports.CreateThemeSection = CreateThemeSection;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
const ThemeSectionStatus = ({ ...props })=>{
|
|
6
|
+
const isRenderThemeSectionStatus = props.tag === 'Section' && props?.isThemeSection && props?.needPublishing;
|
|
7
|
+
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
8
|
+
children: isRenderThemeSectionStatus && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
9
|
+
"data-theme-section-status": true,
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
12
|
+
"data-theme-section-status-icon": true,
|
|
13
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
width: "16",
|
|
16
|
+
height: "16",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
fill: "none",
|
|
19
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
20
|
+
fillRule: "evenodd",
|
|
21
|
+
clipRule: "evenodd",
|
|
22
|
+
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",
|
|
23
|
+
fill: "#9144DA"
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
28
|
+
"data-theme-section-status-text": true,
|
|
29
|
+
children: "Need to republish. Go to global edit and publish this section"
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.ThemeSectionStatus = ThemeSectionStatus;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var reactTransitionGroup = require('react-transition-group');
|
|
6
|
+
var core = require('@gem-sdk/core');
|
|
7
|
+
|
|
8
|
+
const TRANSITION_DURATION = 350;
|
|
9
|
+
const defaultStyles = {
|
|
10
|
+
transition: `opacity ${TRANSITION_DURATION}ms ease-out`,
|
|
11
|
+
opacity: 0
|
|
12
|
+
};
|
|
13
|
+
const transitions = {
|
|
14
|
+
entering: {
|
|
15
|
+
opacity: 1
|
|
16
|
+
},
|
|
17
|
+
entered: {
|
|
18
|
+
opacity: 1
|
|
19
|
+
},
|
|
20
|
+
exiting: {
|
|
21
|
+
opacity: 0
|
|
22
|
+
},
|
|
23
|
+
exited: {
|
|
24
|
+
opacity: 0
|
|
25
|
+
},
|
|
26
|
+
unmounted: {
|
|
27
|
+
opacity: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const ThemeSectionTooltip = ({ isShow, isLimit, isRender, children, onMouseEnter, onMouseLeave, onActions })=>{
|
|
31
|
+
const nodeRef = react.useRef(null);
|
|
32
|
+
const actionBtnLabel = isLimit ? 'Upgrade to create Theme Section' : 'Create Theme Section';
|
|
33
|
+
const openHelpCenter = ()=>{
|
|
34
|
+
const url = 'https://help.gempages.net/articles/theme-section';
|
|
35
|
+
window.open(url, '_blank');
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
38
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
39
|
+
className: "theme-section-tooltip-wrapper",
|
|
40
|
+
onMouseEnter: onMouseEnter,
|
|
41
|
+
onMouseLeave: onMouseLeave,
|
|
42
|
+
children: [
|
|
43
|
+
children,
|
|
44
|
+
isRender && /*#__PURE__*/ jsxRuntime.jsx(reactTransitionGroup.Transition, {
|
|
45
|
+
in: isShow,
|
|
46
|
+
timeout: TRANSITION_DURATION,
|
|
47
|
+
nodeRef: nodeRef,
|
|
48
|
+
unmountOnExit: true,
|
|
49
|
+
children: (state)=>/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
50
|
+
className: "theme-section-tooltip",
|
|
51
|
+
ref: nodeRef,
|
|
52
|
+
style: {
|
|
53
|
+
...defaultStyles,
|
|
54
|
+
...transitions[state]
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
58
|
+
className: "theme-section-tooltip__image",
|
|
59
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("img", {
|
|
60
|
+
src: "https://ucarecdn.com/6a9f408a-aa8c-434a-890b-81067a14aceb/-/format/auto/-/preview/1920x1920/-/quality/lighter/theme-section-illustration.png",
|
|
61
|
+
alt: ""
|
|
62
|
+
})
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
65
|
+
className: "theme-section-tooltip__body",
|
|
66
|
+
children: [
|
|
67
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
68
|
+
className: "theme-section-tooltip__body-title",
|
|
69
|
+
children: "Create once, use everywhere with Theme Section"
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
72
|
+
className: "theme-section-tooltip__body-desc",
|
|
73
|
+
children: "A global section that can be used on all your GemPages & Shopify pages."
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
78
|
+
className: core.cls('theme-section-tooltip__action', {
|
|
79
|
+
'theme-section-tooltip__action-limit': isLimit
|
|
80
|
+
}),
|
|
81
|
+
children: [
|
|
82
|
+
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
83
|
+
onClick: (e)=>onActions(e),
|
|
84
|
+
children: actionBtnLabel
|
|
85
|
+
}),
|
|
86
|
+
isLimit && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
87
|
+
onClick: openHelpCenter,
|
|
88
|
+
"aria-hidden": true,
|
|
89
|
+
className: "theme-section-tooltip__action-learn-more",
|
|
90
|
+
children: "Learn more about Theme Section"
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.ThemeSectionTooltip = ThemeSectionTooltip;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
function Tooltip({ children, enable, text = 'Tooltip Text', position = 'right', ...props }) {
|
|
8
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
9
|
+
...props,
|
|
10
|
+
"data-toolbar-tooltip-trigger": true,
|
|
11
|
+
children: [
|
|
12
|
+
children,
|
|
13
|
+
enable && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
14
|
+
"data-toolbar-tooltip": true,
|
|
15
|
+
"data-toolbar-tooltip-position": position,
|
|
16
|
+
children: text
|
|
17
|
+
})
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.default = Tooltip;
|
|
@@ -28,9 +28,12 @@ const root = {
|
|
|
28
28
|
label: 'Root',
|
|
29
29
|
childrens: []
|
|
30
30
|
};
|
|
31
|
-
const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
|
|
31
|
+
const createBuilderPreviewProvider = (args, isThemeSectionEditor)=>zustand.createStore((set, get)=>({
|
|
32
32
|
state: args,
|
|
33
33
|
loaded: false,
|
|
34
|
+
isThemeSectionEditor: !!isThemeSectionEditor,
|
|
35
|
+
dynamicProduct: null,
|
|
36
|
+
dynamicCollection: null,
|
|
34
37
|
addItem: (args)=>{
|
|
35
38
|
const { position, data } = args;
|
|
36
39
|
const state = get().state;
|
|
@@ -390,14 +393,43 @@ const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
|
|
|
390
393
|
ROOT: cloneDeep.cloneDeep(ROOT)
|
|
391
394
|
}
|
|
392
395
|
});
|
|
396
|
+
},
|
|
397
|
+
getParents: (id, limit)=>{
|
|
398
|
+
const state = get().state;
|
|
399
|
+
const parents = [];
|
|
400
|
+
let index = 0;
|
|
401
|
+
let currentId = id;
|
|
402
|
+
// eslint-disable-next-line no-constant-condition
|
|
403
|
+
while(true){
|
|
404
|
+
if (limit && index >= limit) break;
|
|
405
|
+
const parent = Object.entries(state).find(([, value])=>value.type !== 'section' && value.childrens?.includes(currentId));
|
|
406
|
+
if (!parent) break;
|
|
407
|
+
const [, parentItem] = parent;
|
|
408
|
+
if (!parentItem) break;
|
|
409
|
+
parents.push(parentItem);
|
|
410
|
+
currentId = parentItem.uid;
|
|
411
|
+
index++;
|
|
412
|
+
}
|
|
413
|
+
return parents;
|
|
414
|
+
},
|
|
415
|
+
setDynamicProduct: (data)=>{
|
|
416
|
+
set({
|
|
417
|
+
dynamicProduct: data
|
|
418
|
+
});
|
|
419
|
+
},
|
|
420
|
+
setDynamicCollection: (data)=>{
|
|
421
|
+
set({
|
|
422
|
+
dynamicCollection: data
|
|
423
|
+
});
|
|
393
424
|
}
|
|
394
425
|
}));
|
|
395
|
-
const BuilderPreviewProvider = ({ children, state, lazy, ...passProps })=>{
|
|
426
|
+
const BuilderPreviewProvider = ({ children, state, isThemeSectionEditor, lazy, ...passProps })=>{
|
|
396
427
|
const Component = lazy ? react.Suspense : react.Fragment;
|
|
397
428
|
const value = react.useMemo(()=>{
|
|
398
|
-
return createBuilderPreviewProvider(state);
|
|
429
|
+
return createBuilderPreviewProvider(state, isThemeSectionEditor);
|
|
399
430
|
}, [
|
|
400
|
-
state
|
|
431
|
+
state,
|
|
432
|
+
isThemeSectionEditor
|
|
401
433
|
]);
|
|
402
434
|
return /*#__PURE__*/ jsxRuntime.jsx(Component, {
|
|
403
435
|
children: /*#__PURE__*/ jsxRuntime.jsx(BuilderPreviewContext.Provider, {
|
|
@@ -37,6 +37,16 @@ const createShopStoreProvider = (data)=>zustand.createStore((set)=>({
|
|
|
37
37
|
storefrontUrl: url,
|
|
38
38
|
storefrontToken: token
|
|
39
39
|
});
|
|
40
|
+
},
|
|
41
|
+
changeCreateThemeSectionCount: (count)=>{
|
|
42
|
+
set({
|
|
43
|
+
createThemeSectionCount: count
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
changeShopPlan: (plan)=>{
|
|
47
|
+
set({
|
|
48
|
+
plan
|
|
49
|
+
});
|
|
40
50
|
}
|
|
41
51
|
}));
|
|
42
52
|
const ShopProvider = ({ children, addons, storeOption, queryOption, ...passProps })=>{
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var ComponentToolbarPreview = require('../components/ComponentToolbarPreview.js');
|
|
7
|
+
|
|
8
|
+
const filterToolbarPreview = (children, keep = false)=>{
|
|
9
|
+
const arrChild = react.Children.toArray(children);
|
|
10
|
+
return arrChild.filter((child)=>!keep ? child?.type != ComponentToolbarPreview.ComponentToolbarPreview : child?.type == ComponentToolbarPreview.ComponentToolbarPreview);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.default = filterToolbarPreview;
|
|
14
|
+
exports.filterToolbarPreview = filterToolbarPreview;
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
|
+
var ComponentToolbarPreview = require('../components/ComponentToolbarPreview.js');
|
|
6
7
|
|
|
7
8
|
const isEmptyChildren = (children)=>{
|
|
8
|
-
|
|
9
|
+
let arrChild = react.Children.toArray(children);
|
|
10
|
+
arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview.ComponentToolbarPreview);
|
|
11
|
+
return react.Children.count(arrChild) < 1 || !children;
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
exports.default = isEmptyChildren;
|
|
@@ -75,6 +75,13 @@ const makeWidth = (widthValue, fullWidthValue)=>{
|
|
|
75
75
|
mobile: getVal('mobile', widthValue, fullWidthValue)
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
|
+
const makeGlobalSizeWidthResponsive = (globalSize)=>{
|
|
79
|
+
return {
|
|
80
|
+
'--w': globalSize?.desktop?.width,
|
|
81
|
+
'--w-tablet': globalSize?.tablet?.width,
|
|
82
|
+
'--w-mobile': globalSize?.mobile?.width
|
|
83
|
+
};
|
|
84
|
+
};
|
|
78
85
|
const makeHeight = (heighValue, autoHeight)=>{
|
|
79
86
|
const getVal = (deviceValue, heighValue, autoHeight)=>{
|
|
80
87
|
const heightVal = heighValue?.[deviceValue];
|
|
@@ -128,6 +135,7 @@ const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
|
|
|
128
135
|
};
|
|
129
136
|
|
|
130
137
|
exports.makeAspectRatio = makeAspectRatio;
|
|
138
|
+
exports.makeGlobalSizeWidthResponsive = makeGlobalSizeWidthResponsive;
|
|
131
139
|
exports.makeHeight = makeHeight;
|
|
132
140
|
exports.makeLineClamp = makeLineClamp;
|
|
133
141
|
exports.makeStyle = makeStyle;
|
package/dist/cjs/helpers/size.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var makeStyle = require('./make-style.js');
|
|
3
4
|
var constant = require('./constant.js');
|
|
4
5
|
|
|
5
6
|
function getCustomSizeCSSByDevice(size, device) {
|
|
@@ -29,7 +30,60 @@ const composeSizeCss = (spacing)=>{
|
|
|
29
30
|
${sizeVerti ? `padding-top: ${sizeVerti}; padding-bottom: ${sizeVerti};` : undefined}
|
|
30
31
|
`;
|
|
31
32
|
};
|
|
33
|
+
const makeGlobalSize = (globalSize)=>{
|
|
34
|
+
return {
|
|
35
|
+
width: makeStyleWithDefault('w', getWidthHeightGlobalSize('width', globalSize), {
|
|
36
|
+
desktop: '--g-ct-w',
|
|
37
|
+
tablet: '--g-ct-w',
|
|
38
|
+
mobile: '--g-ct-w'
|
|
39
|
+
}),
|
|
40
|
+
height: makeStyle.makeStyleResponsive('h', getWidthHeightGlobalSize('height', globalSize)),
|
|
41
|
+
padding: getPaddingGlobalSize(globalSize)
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const makeStyleWithDefault = (name, value, defaultVal)=>{
|
|
45
|
+
return {
|
|
46
|
+
[`--${name}`]: value?.desktop === 'default' ? `var(${defaultVal?.desktop})` : value?.desktop,
|
|
47
|
+
[`--${name}-tablet`]: value?.tablet === 'default' ? `var(${defaultVal?.tablet})` : value?.tablet,
|
|
48
|
+
[`--${name}-mobile`]: value?.mobile === 'default' ? `var(${defaultVal?.mobile})` : value?.mobile
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const getWidthHeightGlobalSize = (type, globalSize)=>{
|
|
52
|
+
if (!globalSize) return {};
|
|
53
|
+
const data = {
|
|
54
|
+
desktop: globalSize?.desktop?.[type],
|
|
55
|
+
tablet: globalSize?.tablet?.[type],
|
|
56
|
+
mobile: globalSize?.mobile?.[type]
|
|
57
|
+
};
|
|
58
|
+
if (data.desktop === undefined) {
|
|
59
|
+
data.desktop = 'auto';
|
|
60
|
+
}
|
|
61
|
+
if (data.tablet === undefined) {
|
|
62
|
+
data.tablet = data.desktop;
|
|
63
|
+
}
|
|
64
|
+
if (data.mobile === undefined) {
|
|
65
|
+
data.mobile = data.tablet;
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
68
|
+
};
|
|
69
|
+
function getCustomPaddingSizeCSSByDevice(globalSize, device) {
|
|
70
|
+
if (!globalSize || !device) return {};
|
|
71
|
+
const suffix = constant.devicesMapping[device] ?? '';
|
|
72
|
+
return {
|
|
73
|
+
[`--pl${suffix}`]: globalSize?.[device]?.padding?.left,
|
|
74
|
+
[`--pr${suffix}`]: globalSize?.[device]?.padding?.right,
|
|
75
|
+
[`--pt${suffix}`]: globalSize?.[device]?.padding?.top,
|
|
76
|
+
[`--pb${suffix}`]: globalSize?.[device]?.padding?.bottom
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const getPaddingGlobalSize = (globalSize)=>{
|
|
80
|
+
return Object.assign({}, getCustomPaddingSizeCSSByDevice(globalSize, 'desktop'), getCustomPaddingSizeCSSByDevice(globalSize, 'tablet'), getCustomPaddingSizeCSSByDevice(globalSize, 'mobile'));
|
|
81
|
+
};
|
|
32
82
|
|
|
33
83
|
exports.composeSize = composeSize;
|
|
34
84
|
exports.composeSizeCss = composeSizeCss;
|
|
35
85
|
exports.genSizeClass = genSizeClass;
|
|
86
|
+
exports.getPaddingGlobalSize = getPaddingGlobalSize;
|
|
87
|
+
exports.getWidthHeightGlobalSize = getWidthHeightGlobalSize;
|
|
88
|
+
exports.makeGlobalSize = makeGlobalSize;
|
|
89
|
+
exports.makeStyleWithDefault = makeStyleWithDefault;
|
|
@@ -18,20 +18,21 @@ const composeTypographyCss = (typography)=>{
|
|
|
18
18
|
${lineHeight ? `line-height: ${lineHeight};` : ''}
|
|
19
19
|
`;
|
|
20
20
|
};
|
|
21
|
-
const composeTypographyV2Css = (typography)=>{
|
|
21
|
+
const composeTypographyV2Css = (typography, isImportant)=>{
|
|
22
22
|
const typographyCustom = typography?.custom;
|
|
23
23
|
const { fontFamily, fontSize, fontWeight, lineHeight, letterSpacing } = typographyCustom ?? {};
|
|
24
24
|
const typographyAttrs = typography?.attrs;
|
|
25
25
|
const { bold, italic, underline, transform } = typographyAttrs ?? {};
|
|
26
|
+
const composeImportant = isImportant ? '!important' : '';
|
|
26
27
|
return `
|
|
27
|
-
${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily});` : ''}
|
|
28
|
-
${fontSize?.desktop ? `font-size: ${fontSize?.desktop};` : ''}
|
|
29
|
-
${bold ? `font-weight: bold;` : fontWeight ? `font-weight: ${fontWeight};` : ''}
|
|
30
|
-
${letterSpacing ? `letter-spacing: ${letterSpacing};` : ''}
|
|
31
|
-
${lineHeight ? `line-height: ${lineHeight};` : ''}
|
|
32
|
-
${italic ? `font-style: italic;` : ''}
|
|
33
|
-
${underline ? `text-decoration-line: underline;` : ''}
|
|
34
|
-
${transform ? `text-transform: ${transform};` : ''}
|
|
28
|
+
${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily}) ${composeImportant};` : ''}
|
|
29
|
+
${fontSize?.desktop ? `font-size: ${fontSize?.desktop} ${composeImportant};` : ''}
|
|
30
|
+
${bold ? `font-weight: bold;` : fontWeight ? `font-weight: ${fontWeight} ${composeImportant};` : ''}
|
|
31
|
+
${letterSpacing ? `letter-spacing: ${letterSpacing} ${composeImportant};` : ''}
|
|
32
|
+
${lineHeight ? `line-height: ${lineHeight} ${composeImportant};` : ''}
|
|
33
|
+
${italic ? `font-style: italic${composeImportant};` : ''}
|
|
34
|
+
${underline ? `text-decoration-line: underline ${composeImportant};` : ''}
|
|
35
|
+
${transform ? `text-transform: ${transform} ${composeImportant};` : ''}
|
|
35
36
|
`;
|
|
36
37
|
};
|
|
37
38
|
function getCustomCSSByDevice(typography, device) {
|
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
var ProductContext = require('../contexts/ProductContext.js');
|
|
5
5
|
var flattenConnection = require('../helpers/flatten-connection.js');
|
|
6
|
+
require('react/jsx-runtime');
|
|
7
|
+
require('zustand');
|
|
6
8
|
require('swr');
|
|
9
|
+
require('@gem-sdk/adapter-shopify');
|
|
10
|
+
require('swr/mutation');
|
|
11
|
+
require('vanilla-lazyload');
|
|
12
|
+
require('./useCartUI.js');
|
|
13
|
+
var variant = require('../helpers/variant.js');
|
|
14
|
+
require('react-transition-group');
|
|
15
|
+
require('@gem-sdk/core');
|
|
7
16
|
var product = require('../helpers/product.js');
|
|
8
17
|
require('../helpers/convert.js');
|
|
9
|
-
var variant = require('../helpers/variant.js');
|
|
10
18
|
|
|
11
19
|
const useUniqProductID = ()=>{
|
|
12
20
|
return ProductContext.useProductStore((s)=>s.uiqueId);
|