@gem-sdk/core 1.22.21 → 1.22.31-new-feature.2
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 +362 -0
- package/dist/cjs/components/ComponentWrapperPreview.js +26 -4
- package/dist/cjs/components/Render.liquid.js +8 -0
- package/dist/cjs/components/RenderCustomCode.js +2 -0
- package/dist/cjs/components/theme-section/CreateThemeSection.js +124 -0
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +95 -0
- package/dist/cjs/contexts/BuilderPreviewContext.js +24 -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/hooks/useProduct.js +9 -1
- package/dist/cjs/index.js +2 -0
- package/dist/esm/components/ComponentToolbarPreview.js +360 -0
- package/dist/esm/components/ComponentWrapperPreview.js +26 -4
- package/dist/esm/components/Render.liquid.js +8 -0
- package/dist/esm/components/RenderCustomCode.js +2 -0
- package/dist/esm/components/theme-section/CreateThemeSection.js +122 -0
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +93 -0
- package/dist/esm/contexts/BuilderPreviewContext.js +24 -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 +5 -2
- package/dist/esm/hooks/useProduct.js +9 -1
- package/dist/esm/index.js +1 -0
- package/dist/types/index.d.ts +16 -3
- package/package.json +3 -3
|
@@ -0,0 +1,95 @@
|
|
|
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: `all ${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
|
+
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
33
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
34
|
+
className: "theme-section-tooltip-wrapper",
|
|
35
|
+
onMouseEnter: onMouseEnter,
|
|
36
|
+
onMouseLeave: onMouseLeave,
|
|
37
|
+
children: [
|
|
38
|
+
children,
|
|
39
|
+
isRender && /*#__PURE__*/ jsxRuntime.jsx(reactTransitionGroup.Transition, {
|
|
40
|
+
in: isShow,
|
|
41
|
+
timeout: TRANSITION_DURATION,
|
|
42
|
+
nodeRef: nodeRef,
|
|
43
|
+
unmountOnExit: true,
|
|
44
|
+
children: (state)=>/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
45
|
+
className: "theme-section-tooltip",
|
|
46
|
+
ref: nodeRef,
|
|
47
|
+
style: {
|
|
48
|
+
...defaultStyles,
|
|
49
|
+
...transitions[state]
|
|
50
|
+
},
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
53
|
+
className: "theme-section-tooltip__image",
|
|
54
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("img", {
|
|
55
|
+
src: "https://ucarecdn.com/6a9f408a-aa8c-434a-890b-81067a14aceb/-/format/auto/-/preview/1920x1920/-/quality/lighter/theme-section-illustration.png",
|
|
56
|
+
alt: ""
|
|
57
|
+
})
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
60
|
+
className: "theme-section-tooltip__body",
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
63
|
+
className: "theme-section-tooltip__body-title",
|
|
64
|
+
children: "Create once, use everywhere with Theme section"
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
67
|
+
className: "theme-section-tooltip__body-desc",
|
|
68
|
+
children: "A global section that can be used on all your GemPages & pages."
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
73
|
+
className: core.cls('theme-section-tooltip__action', {
|
|
74
|
+
'theme-section-tooltip__action-limit': isLimit
|
|
75
|
+
}),
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
78
|
+
onClick: (e)=>onActions(e),
|
|
79
|
+
children: isLimit ? 'Upgrade to create Theme section' : 'Create theme section'
|
|
80
|
+
}),
|
|
81
|
+
isLimit && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
82
|
+
className: "theme-section-tooltip__action-learn-more",
|
|
83
|
+
children: "Learn more about Theme section"
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
exports.ThemeSectionTooltip = ThemeSectionTooltip;
|
|
@@ -28,9 +28,10 @@ const root = {
|
|
|
28
28
|
label: 'Root',
|
|
29
29
|
childrens: []
|
|
30
30
|
};
|
|
31
|
-
const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
|
|
31
|
+
const createBuilderPreviewProvider = (args, isEditThemeSection)=>zustand.createStore((set, get)=>({
|
|
32
32
|
state: args,
|
|
33
33
|
loaded: false,
|
|
34
|
+
isEditThemeSection: !!isEditThemeSection,
|
|
34
35
|
addItem: (args)=>{
|
|
35
36
|
const { position, data } = args;
|
|
36
37
|
const state = get().state;
|
|
@@ -390,14 +391,33 @@ const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
|
|
|
390
391
|
ROOT: cloneDeep.cloneDeep(ROOT)
|
|
391
392
|
}
|
|
392
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;
|
|
393
412
|
}
|
|
394
413
|
}));
|
|
395
|
-
const BuilderPreviewProvider = ({ children, state, lazy, ...passProps })=>{
|
|
414
|
+
const BuilderPreviewProvider = ({ children, state, isEditThemeSection, lazy, ...passProps })=>{
|
|
396
415
|
const Component = lazy ? react.Suspense : react.Fragment;
|
|
397
416
|
const value = react.useMemo(()=>{
|
|
398
|
-
return createBuilderPreviewProvider(state);
|
|
417
|
+
return createBuilderPreviewProvider(state, isEditThemeSection);
|
|
399
418
|
}, [
|
|
400
|
-
state
|
|
419
|
+
state,
|
|
420
|
+
isEditThemeSection
|
|
401
421
|
]);
|
|
402
422
|
return /*#__PURE__*/ jsxRuntime.jsx(Component, {
|
|
403
423
|
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 && react.isValidElement(child));
|
|
11
|
+
return react.Children.count(arrChild) < 1 || !children;
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
exports.default = isEmptyChildren;
|
|
@@ -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);
|
package/dist/cjs/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var GlobalEvent = require('./helpers/GlobalEvent.js');
|
|
|
32
32
|
var isBrowser = require('./helpers/is-browser.js');
|
|
33
33
|
var isSafari = require('./helpers/is-safari.js');
|
|
34
34
|
var isEmptyChildren = require('./helpers/is-empty-children.js');
|
|
35
|
+
var filterToolbarPreview = require('./helpers/filter-toolbar-preview.js');
|
|
35
36
|
var makeStyle = require('./helpers/make-style.js');
|
|
36
37
|
var normalizeBuilderData = require('./helpers/normalize-builder-data.js');
|
|
37
38
|
var prefetchQueries = require('./helpers/prefetch-queries.js');
|
|
@@ -148,6 +149,7 @@ exports.globalEvent = GlobalEvent.default;
|
|
|
148
149
|
exports.isBrowser = isBrowser.default;
|
|
149
150
|
exports.isSafari = isSafari.default;
|
|
150
151
|
exports.isEmptyChildren = isEmptyChildren.isEmptyChildren;
|
|
152
|
+
exports.filterToolbarPreview = filterToolbarPreview.filterToolbarPreview;
|
|
151
153
|
exports.makeAspectRatio = makeStyle.makeAspectRatio;
|
|
152
154
|
exports.makeHeight = makeStyle.makeHeight;
|
|
153
155
|
exports.makeLineClamp = makeStyle.makeLineClamp;
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useCallback, useEffect } 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 { CreateThemeSection } from './theme-section/CreateThemeSection.js';
|
|
11
|
+
import '../helpers/convert.js';
|
|
12
|
+
|
|
13
|
+
const ComponentToolbarPreview = ({ ...props })=>{
|
|
14
|
+
const getParents = useBuilderPreviewStore((s)=>s.getParents);
|
|
15
|
+
const root = useBuilderPreviewStore((s)=>s.getItem('ROOT'));
|
|
16
|
+
const isThemeSection = props.isThemeSection;
|
|
17
|
+
const isEditThemeSection = useBuilderPreviewStore((s)=>s.isEditThemeSection);
|
|
18
|
+
const [activeAddSection, setActiveAddSection] = useState(null);
|
|
19
|
+
const [isShowParent, setIsShowParent] = useState(false);
|
|
20
|
+
const [isShowParentRevert, setIsShowParentRevert] = useState(false);
|
|
21
|
+
const [parents, setParents] = useState([]);
|
|
22
|
+
// Get parents
|
|
23
|
+
const onActiveComponent = useCallback((e)=>{
|
|
24
|
+
const detail = e.detail;
|
|
25
|
+
if (detail?.componentUid == props.uid) {
|
|
26
|
+
const currentParents = getParents(props.uid).filter((parent)=>{
|
|
27
|
+
if (parent.uid === 'ROOT') return false;
|
|
28
|
+
if (parent.tag === 'Section') return false;
|
|
29
|
+
if (parent.editorConfigs?.toolbar?.hide) return false;
|
|
30
|
+
if (parent.editorConfigs?.component?.noSetting) return false;
|
|
31
|
+
return true;
|
|
32
|
+
}).slice(0, 3);
|
|
33
|
+
setParents(currentParents);
|
|
34
|
+
} else {
|
|
35
|
+
setParents([]);
|
|
36
|
+
setIsShowParent(false);
|
|
37
|
+
}
|
|
38
|
+
}, [
|
|
39
|
+
setParents,
|
|
40
|
+
getParents,
|
|
41
|
+
props.uid
|
|
42
|
+
]);
|
|
43
|
+
useEffect(()=>{
|
|
44
|
+
window.addEventListener('editor:active-component', onActiveComponent);
|
|
45
|
+
return ()=>{
|
|
46
|
+
window.removeEventListener('editor:active-component', onActiveComponent);
|
|
47
|
+
};
|
|
48
|
+
}, [
|
|
49
|
+
onActiveComponent
|
|
50
|
+
]);
|
|
51
|
+
// End get parents
|
|
52
|
+
if (props.type === 'section') {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (props.editorConfigs?.toolbar?.hide) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const getIndexSection = ()=>{
|
|
59
|
+
if (props.tag !== 'Section') {
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
if (root?.childrens?.length) {
|
|
63
|
+
return root.childrens.findIndex((sectionUid)=>sectionUid == props.uid);
|
|
64
|
+
}
|
|
65
|
+
return -1;
|
|
66
|
+
};
|
|
67
|
+
const onShowParent = (e)=>{
|
|
68
|
+
if (!parents.length) return;
|
|
69
|
+
const $target = (e?.target) || null;
|
|
70
|
+
const $toolbar = $target.closest('[data-toolbar-active]');
|
|
71
|
+
if (!$target || !$toolbar) return;
|
|
72
|
+
if (isShowParent) {
|
|
73
|
+
setIsShowParentRevert(false);
|
|
74
|
+
setIsShowParent(false);
|
|
75
|
+
} else {
|
|
76
|
+
const rect = $toolbar.getBoundingClientRect();
|
|
77
|
+
if (rect.top < parents.length * 24) {
|
|
78
|
+
setIsShowParentRevert(true);
|
|
79
|
+
} else {
|
|
80
|
+
setIsShowParentRevert(false);
|
|
81
|
+
}
|
|
82
|
+
setIsShowParent(true);
|
|
83
|
+
}
|
|
84
|
+
const event = new CustomEvent('editor:toolbar:show-parents', {
|
|
85
|
+
bubbles: true,
|
|
86
|
+
detail: {
|
|
87
|
+
value: !isShowParent
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
window.dispatchEvent(event);
|
|
91
|
+
};
|
|
92
|
+
const onDelete = (e)=>{
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
const event = new CustomEvent('editor:toolbar:delete-component', {
|
|
96
|
+
bubbles: true,
|
|
97
|
+
detail: {
|
|
98
|
+
componentUid: props.uid,
|
|
99
|
+
isThemeSection: isThemeSection
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
window.dispatchEvent(event);
|
|
103
|
+
return false;
|
|
104
|
+
};
|
|
105
|
+
const onDuplicate = (e)=>{
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
const event = new CustomEvent('editor:toolbar:duplicate-component', {
|
|
109
|
+
bubbles: true,
|
|
110
|
+
detail: {
|
|
111
|
+
componentUid: props.uid
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
window.dispatchEvent(event);
|
|
115
|
+
return false;
|
|
116
|
+
};
|
|
117
|
+
const closeAddSection = ()=>{
|
|
118
|
+
setActiveAddSection(null);
|
|
119
|
+
window.removeEventListener('editor:close-add-section-popup', closeAddSection);
|
|
120
|
+
};
|
|
121
|
+
const onAddSection = (e, position)=>{
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
const $target = e.target;
|
|
125
|
+
if ($target) {
|
|
126
|
+
setActiveAddSection(position);
|
|
127
|
+
const rect = $target.getBoundingClientRect();
|
|
128
|
+
const event = new CustomEvent('editor:toolbar:add-section', {
|
|
129
|
+
bubbles: true,
|
|
130
|
+
detail: {
|
|
131
|
+
componentUid: props.uid,
|
|
132
|
+
position,
|
|
133
|
+
top: rect.top + rect.height / 2
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
window.dispatchEvent(event);
|
|
137
|
+
window.addEventListener('editor:close-add-section-popup', closeAddSection);
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
};
|
|
141
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
142
|
+
children: [
|
|
143
|
+
/*#__PURE__*/ jsxs("div", {
|
|
144
|
+
"data-toolbar": true,
|
|
145
|
+
"data-toolbar-section": props.tag == 'Section',
|
|
146
|
+
"data-toolbar-theme-section": props.tag == 'Section' && !!isThemeSection,
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ jsxs("div", {
|
|
149
|
+
"data-toolbar-show-parent": true,
|
|
150
|
+
onClick: (e)=>onShowParent(e),
|
|
151
|
+
"aria-hidden": "true",
|
|
152
|
+
children: [
|
|
153
|
+
/*#__PURE__*/ jsx("div", {
|
|
154
|
+
"data-toolbar-icon-drag": true,
|
|
155
|
+
children: /*#__PURE__*/ jsxs("svg", {
|
|
156
|
+
width: "16",
|
|
157
|
+
height: "16",
|
|
158
|
+
viewBox: "0 0 16 16",
|
|
159
|
+
fill: "none",
|
|
160
|
+
children: [
|
|
161
|
+
/*#__PURE__*/ jsx("path", {
|
|
162
|
+
d: "M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",
|
|
163
|
+
fill: "currentColor"
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ jsx("path", {
|
|
166
|
+
d: "M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",
|
|
167
|
+
fill: "currentColor"
|
|
168
|
+
}),
|
|
169
|
+
/*#__PURE__*/ jsx("path", {
|
|
170
|
+
d: "M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",
|
|
171
|
+
fill: "currentColor"
|
|
172
|
+
}),
|
|
173
|
+
/*#__PURE__*/ jsx("path", {
|
|
174
|
+
d: "M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",
|
|
175
|
+
fill: "currentColor"
|
|
176
|
+
}),
|
|
177
|
+
/*#__PURE__*/ jsx("path", {
|
|
178
|
+
d: "M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",
|
|
179
|
+
fill: "currentColor"
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ jsx("path", {
|
|
182
|
+
d: "M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",
|
|
183
|
+
fill: "currentColor"
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
})
|
|
187
|
+
}),
|
|
188
|
+
props.tag == 'Section' ? /*#__PURE__*/ jsx("div", {
|
|
189
|
+
"data-toolbar-name": true,
|
|
190
|
+
children: isThemeSection ? props.name : `Section ${getIndexSection() + 1}`
|
|
191
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
192
|
+
"data-toolbar-name": true,
|
|
193
|
+
children: props.label
|
|
194
|
+
}),
|
|
195
|
+
props.tag !== 'Section' && parents.length > 0 && /*#__PURE__*/ jsx("div", {
|
|
196
|
+
"data-toolbar-icon-parent": true,
|
|
197
|
+
"data-toolbar-icon-parent-open": isShowParent,
|
|
198
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
199
|
+
width: "16",
|
|
200
|
+
height: "16",
|
|
201
|
+
viewBox: "0 0 16 16",
|
|
202
|
+
fill: "none",
|
|
203
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
204
|
+
d: "M5.65522 10C5.07265 10 4.7809 9.22865 5.19284 8.77753L7.53762 6.20974C7.79298 5.93009 8.20702 5.93009 8.46238 6.20974L10.8072 8.77754C11.2191 9.22866 10.9274 10 10.3448 10H5.65522Z",
|
|
205
|
+
fill: "currentColor"
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
}),
|
|
211
|
+
isShowParent && parents.map((parent, index)=>/*#__PURE__*/ jsxs("div", {
|
|
212
|
+
"data-toolbar-parent": true,
|
|
213
|
+
"data-parent-uid": parent.uid,
|
|
214
|
+
style: {
|
|
215
|
+
top: !isShowParentRevert ? `${-24 * (index + 1) + index}px` : `${31 + 24 * index - index}px`
|
|
216
|
+
},
|
|
217
|
+
children: [
|
|
218
|
+
/*#__PURE__*/ jsx("div", {
|
|
219
|
+
"data-toolbar-icon-drag": true,
|
|
220
|
+
children: /*#__PURE__*/ jsxs("svg", {
|
|
221
|
+
width: "16",
|
|
222
|
+
height: "16",
|
|
223
|
+
viewBox: "0 0 16 16",
|
|
224
|
+
fill: "none",
|
|
225
|
+
children: [
|
|
226
|
+
/*#__PURE__*/ jsx("path", {
|
|
227
|
+
d: "M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",
|
|
228
|
+
fill: "currentColor"
|
|
229
|
+
}),
|
|
230
|
+
/*#__PURE__*/ jsx("path", {
|
|
231
|
+
d: "M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",
|
|
232
|
+
fill: "currentColor"
|
|
233
|
+
}),
|
|
234
|
+
/*#__PURE__*/ jsx("path", {
|
|
235
|
+
d: "M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",
|
|
236
|
+
fill: "currentColor"
|
|
237
|
+
}),
|
|
238
|
+
/*#__PURE__*/ jsx("path", {
|
|
239
|
+
d: "M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",
|
|
240
|
+
fill: "currentColor"
|
|
241
|
+
}),
|
|
242
|
+
/*#__PURE__*/ jsx("path", {
|
|
243
|
+
d: "M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",
|
|
244
|
+
fill: "currentColor"
|
|
245
|
+
}),
|
|
246
|
+
/*#__PURE__*/ jsx("path", {
|
|
247
|
+
d: "M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",
|
|
248
|
+
fill: "currentColor"
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
})
|
|
252
|
+
}),
|
|
253
|
+
/*#__PURE__*/ jsx("div", {
|
|
254
|
+
"data-toolbar-name": true,
|
|
255
|
+
children: parent.label
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
}, parent.uid)),
|
|
259
|
+
/*#__PURE__*/ jsx(CreateThemeSection, {
|
|
260
|
+
...props
|
|
261
|
+
}),
|
|
262
|
+
/*#__PURE__*/ jsx("div", {
|
|
263
|
+
"data-toolbar-duplicate": true,
|
|
264
|
+
onClick: (e)=>onDuplicate(e),
|
|
265
|
+
"aria-hidden": "true",
|
|
266
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
267
|
+
width: "16",
|
|
268
|
+
height: "16",
|
|
269
|
+
viewBox: "0 0 16 16",
|
|
270
|
+
fill: "none",
|
|
271
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
272
|
+
fillRule: "evenodd",
|
|
273
|
+
clipRule: "evenodd",
|
|
274
|
+
d: "M6.08423 1.21289C5.53194 1.21289 5.08423 1.66061 5.08423 2.21289V3.78711H4.26172C3.43329 3.78711 2.76172 4.45868 2.76172 5.28711V13.2871C2.76172 14.1155 3.43329 14.7871 4.26172 14.7871H10.2617C11.0901 14.7871 11.7617 14.1155 11.7617 13.2871V12.4629H13.0842C13.6365 12.4629 14.0842 12.0152 14.0842 11.4629V2.21289C14.0842 1.66061 13.6365 1.21289 13.0842 1.21289H6.08423ZM10.7617 12.4629H6.08423C5.53194 12.4629 5.08423 12.0152 5.08423 11.4629V4.78711H4.26172C3.98558 4.78711 3.76172 5.01097 3.76172 5.28711V13.2871C3.76172 13.5633 3.98558 13.7871 4.26172 13.7871H10.2617C10.5379 13.7871 10.7617 13.5633 10.7617 13.2871V12.4629Z",
|
|
275
|
+
fill: "currentColor"
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
}),
|
|
279
|
+
/*#__PURE__*/ jsx("div", {
|
|
280
|
+
"data-toolbar-delete": true,
|
|
281
|
+
onClick: (e)=>onDelete(e),
|
|
282
|
+
"aria-hidden": "true",
|
|
283
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
284
|
+
width: "16",
|
|
285
|
+
height: "16",
|
|
286
|
+
viewBox: "0 0 16 16",
|
|
287
|
+
fill: "none",
|
|
288
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
289
|
+
fillRule: "evenodd",
|
|
290
|
+
clipRule: "evenodd",
|
|
291
|
+
d: "M11 2.88965V2.38965C11 1.56122 10.3284 0.889648 9.5 0.889648H6.5C5.67157 0.889648 5 1.56122 5 2.38965V2.88965H2C1.72386 2.88965 1.5 3.11351 1.5 3.38965C1.5 3.66579 1.72386 3.88965 2 3.88965H3.21997V13.1099C3.21997 14.2144 4.1154 15.1099 5.21997 15.1099H11.22C12.3245 15.1099 13.22 14.2144 13.22 13.1099V3.88965H14C14.2761 3.88965 14.5 3.66579 14.5 3.38965C14.5 3.11351 14.2761 2.88965 14 2.88965H11ZM6 2.88965H10V2.38965C10 2.11351 9.77614 1.88965 9.5 1.88965H6.5C6.22386 1.88965 6 2.11351 6 2.38965V2.88965ZM6.24976 6.13965C6.66397 6.13965 6.99976 6.47543 6.99976 6.88965V11.3896C6.99976 11.8039 6.66397 12.1396 6.24976 12.1396C5.83554 12.1396 5.49976 11.8039 5.49976 11.3896V6.88965C5.49976 6.47543 5.83554 6.13965 6.24976 6.13965ZM10.4998 6.88965C10.4998 6.47543 10.164 6.13965 9.74976 6.13965C9.33554 6.13965 8.99976 6.47543 8.99976 6.88965V11.3896C8.99976 11.8039 9.33554 12.1396 9.74976 12.1396C10.164 12.1396 10.4998 11.8039 10.4998 11.3896V6.88965Z",
|
|
292
|
+
fill: "currentColor"
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
}),
|
|
298
|
+
/*#__PURE__*/ jsx("div", {
|
|
299
|
+
"data-outline": true,
|
|
300
|
+
"data-outline-section": props.tag == 'Section',
|
|
301
|
+
"data-outline-theme-section": props.tag == 'Section' && !!isThemeSection
|
|
302
|
+
}),
|
|
303
|
+
props.tag == 'Section' && !!isEditThemeSection && /*#__PURE__*/ jsxs(Fragment, {
|
|
304
|
+
children: [
|
|
305
|
+
/*#__PURE__*/ jsx("div", {
|
|
306
|
+
"data-toolbar-add-top": true,
|
|
307
|
+
"data-toolbar-add-open": activeAddSection == 'above',
|
|
308
|
+
onClick: (e)=>onAddSection(e, 'above'),
|
|
309
|
+
"aria-hidden": "true",
|
|
310
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
311
|
+
width: "16",
|
|
312
|
+
height: "16",
|
|
313
|
+
viewBox: "0 0 16 16",
|
|
314
|
+
fill: "none",
|
|
315
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
316
|
+
d: "M8.5 1.5C8.5 1.22386 8.27614 1 8 1C7.72386 1 7.5 1.22386 7.5 1.5V7.5H1.5C1.22386 7.5 1 7.72386 1 8C1 8.27614 1.22386 8.5 1.5 8.5H7.5V14.5C7.5 14.7761 7.72386 15 8 15C8.27614 15 8.5 14.7761 8.5 14.5V8.5H14.5C14.7761 8.5 15 8.27614 15 8C15 7.72386 14.7761 7.5 14.5 7.5H8.5V1.5Z",
|
|
317
|
+
fill: "currentColor"
|
|
318
|
+
})
|
|
319
|
+
})
|
|
320
|
+
}),
|
|
321
|
+
/*#__PURE__*/ jsx("div", {
|
|
322
|
+
"data-toolbar-add-bottom": true,
|
|
323
|
+
"data-toolbar-add-open": activeAddSection == 'below',
|
|
324
|
+
onClick: (e)=>onAddSection(e, 'below'),
|
|
325
|
+
"aria-hidden": "true",
|
|
326
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
327
|
+
width: "16",
|
|
328
|
+
height: "16",
|
|
329
|
+
viewBox: "0 0 16 16",
|
|
330
|
+
fill: "none",
|
|
331
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
332
|
+
d: "M8.5 1.5C8.5 1.22386 8.27614 1 8 1C7.72386 1 7.5 1.22386 7.5 1.5V7.5H1.5C1.22386 7.5 1 7.72386 1 8C1 8.27614 1.22386 8.5 1.5 8.5H7.5V14.5C7.5 14.7761 7.72386 15 8 15C8.27614 15 8.5 14.7761 8.5 14.5V8.5H14.5C14.7761 8.5 15 8.27614 15 8C15 7.72386 14.7761 7.5 14.5 7.5H8.5V1.5Z",
|
|
333
|
+
fill: "currentColor"
|
|
334
|
+
})
|
|
335
|
+
})
|
|
336
|
+
})
|
|
337
|
+
]
|
|
338
|
+
}),
|
|
339
|
+
/*#__PURE__*/ jsx("div", {
|
|
340
|
+
"data-spacing": true,
|
|
341
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
342
|
+
"data-spacing-margin-bottom": true,
|
|
343
|
+
children: [
|
|
344
|
+
/*#__PURE__*/ jsx("div", {
|
|
345
|
+
"data-spacing-margin-bottom-bg": true,
|
|
346
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
347
|
+
"data-spacing-margin-bottom-value": true
|
|
348
|
+
})
|
|
349
|
+
}),
|
|
350
|
+
/*#__PURE__*/ jsx("div", {
|
|
351
|
+
"data-spacing-margin-bottom-drag": true
|
|
352
|
+
})
|
|
353
|
+
]
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
]
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
export { ComponentToolbarPreview };
|
|
@@ -3,12 +3,16 @@ import { isValidElement } from 'react';
|
|
|
3
3
|
import { composeAdvanceStyle } from '../helpers/compose-advance-style.js';
|
|
4
4
|
import { disableWrap } from './constant.js';
|
|
5
5
|
import RenderCustomCode from './RenderCustomCode.js';
|
|
6
|
+
import { ComponentToolbarPreview } from './ComponentToolbarPreview.js';
|
|
6
7
|
|
|
7
8
|
const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
8
9
|
if (props.type === 'section') {
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
11
12
|
const customProps = {};
|
|
13
|
+
if (props.tag === 'Section' && props.isThemeSection) {
|
|
14
|
+
customProps['data-theme-section'] = true;
|
|
15
|
+
}
|
|
12
16
|
// Build editor configs
|
|
13
17
|
if (props.editorConfigs) {
|
|
14
18
|
const editorConfigs = props.editorConfigs;
|
|
@@ -39,6 +43,13 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
39
43
|
if (editorConfigs.slots?.children) {
|
|
40
44
|
customProps['data-slots-children'] = true;
|
|
41
45
|
}
|
|
46
|
+
if (!editorConfigs.toolbar?.hide) {
|
|
47
|
+
customProps['data-toolbar-wrap'] = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Show toolbar wrapper
|
|
51
|
+
if (!props?.editorConfigs?.toolbar?.hide) {
|
|
52
|
+
customProps['data-toolbar-wrap'] = true;
|
|
42
53
|
}
|
|
43
54
|
const style = composeAdvanceStyle(props.advanced, props.tag);
|
|
44
55
|
const advanced = props.advanced;
|
|
@@ -56,12 +67,18 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
56
67
|
uid: props.uid,
|
|
57
68
|
advanced: advanced
|
|
58
69
|
}),
|
|
59
|
-
/*#__PURE__*/
|
|
70
|
+
/*#__PURE__*/ jsxs(children.type, {
|
|
60
71
|
className: advanced?.cssClass,
|
|
61
72
|
...children.props,
|
|
62
73
|
style,
|
|
63
74
|
builderAttrs,
|
|
64
|
-
advanced
|
|
75
|
+
advanced,
|
|
76
|
+
children: [
|
|
77
|
+
children.props['children'],
|
|
78
|
+
/*#__PURE__*/ jsx(ComponentToolbarPreview, {
|
|
79
|
+
...props
|
|
80
|
+
})
|
|
81
|
+
]
|
|
65
82
|
})
|
|
66
83
|
]
|
|
67
84
|
});
|
|
@@ -73,11 +90,16 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
73
90
|
uid: props.uid,
|
|
74
91
|
advanced: advanced
|
|
75
92
|
}),
|
|
76
|
-
/*#__PURE__*/
|
|
93
|
+
/*#__PURE__*/ jsxs("div", {
|
|
77
94
|
style: style,
|
|
78
95
|
className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
|
|
79
96
|
...builderAttrs,
|
|
80
|
-
children:
|
|
97
|
+
children: [
|
|
98
|
+
children,
|
|
99
|
+
/*#__PURE__*/ jsx(ComponentToolbarPreview, {
|
|
100
|
+
...props
|
|
101
|
+
})
|
|
102
|
+
]
|
|
81
103
|
})
|
|
82
104
|
]
|
|
83
105
|
});
|