@gem-sdk/core 1.23.0-staging.26 → 1.23.0-staging.29
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.
|
@@ -17,6 +17,32 @@ var Resize = require('./resize/Resize.js');
|
|
|
17
17
|
require('../helpers/convert.js');
|
|
18
18
|
|
|
19
19
|
const SECTION_LIMIT = 25;
|
|
20
|
+
const notVisible = (el)=>{
|
|
21
|
+
const overflow = getComputedStyle(el).overflow;
|
|
22
|
+
return overflow !== 'visible';
|
|
23
|
+
};
|
|
24
|
+
const isSection = (el)=>{
|
|
25
|
+
const tag = el.getAttribute('data-component-tag');
|
|
26
|
+
return tag === 'Section';
|
|
27
|
+
};
|
|
28
|
+
const isOverToolbarPosition = (el, parent)=>{
|
|
29
|
+
const rect = el.getBoundingClientRect();
|
|
30
|
+
const rectP = parent.getBoundingClientRect();
|
|
31
|
+
// 32px = toolbar active height
|
|
32
|
+
return rect.top - rectP.top < 32 + 1;
|
|
33
|
+
};
|
|
34
|
+
const findOverflowParent = (element, initEl)=>{
|
|
35
|
+
const thisEl = element;
|
|
36
|
+
const origEl = initEl || thisEl;
|
|
37
|
+
if (!thisEl) return;
|
|
38
|
+
if (isSection(thisEl)) return;
|
|
39
|
+
if (notVisible(thisEl) && isOverToolbarPosition(initEl, thisEl)) return thisEl;
|
|
40
|
+
if (thisEl.parentElement) {
|
|
41
|
+
return findOverflowParent(thisEl.parentElement, origEl);
|
|
42
|
+
} else {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
20
46
|
const ComponentToolbarPreview = ({ ...props })=>{
|
|
21
47
|
const isThemeSection = props.isThemeSection;
|
|
22
48
|
const editingPageType = ShopContext.useShopStore((s)=>s.pageType);
|
|
@@ -84,11 +110,16 @@ const ComponentToolbarPreview = ({ ...props })=>{
|
|
|
84
110
|
setIsShowParentRevert(false);
|
|
85
111
|
setIsShowParent(false);
|
|
86
112
|
} else {
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
113
|
+
const $parentOverflow = findOverflowParent($toolbar, $toolbar);
|
|
114
|
+
if ($parentOverflow) {
|
|
89
115
|
setIsShowParentRevert(true);
|
|
90
116
|
} else {
|
|
91
|
-
|
|
117
|
+
const rect = $toolbar.getBoundingClientRect();
|
|
118
|
+
if (rect.top < parents.length * 24) {
|
|
119
|
+
setIsShowParentRevert(true);
|
|
120
|
+
} else {
|
|
121
|
+
setIsShowParentRevert(false);
|
|
122
|
+
}
|
|
92
123
|
}
|
|
93
124
|
setIsShowParent(true);
|
|
94
125
|
}
|
|
@@ -7,7 +7,7 @@ var ComponentToolbarPreview = require('../components/ComponentToolbarPreview.js'
|
|
|
7
7
|
|
|
8
8
|
const isEmptyChildren = (children)=>{
|
|
9
9
|
let arrChild = react.Children.toArray(children);
|
|
10
|
-
arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview.ComponentToolbarPreview
|
|
10
|
+
arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview.ComponentToolbarPreview);
|
|
11
11
|
return react.Children.count(arrChild) < 1 || !children;
|
|
12
12
|
};
|
|
13
13
|
|
|
@@ -15,6 +15,32 @@ import Resize from './resize/Resize.js';
|
|
|
15
15
|
import '../helpers/convert.js';
|
|
16
16
|
|
|
17
17
|
const SECTION_LIMIT = 25;
|
|
18
|
+
const notVisible = (el)=>{
|
|
19
|
+
const overflow = getComputedStyle(el).overflow;
|
|
20
|
+
return overflow !== 'visible';
|
|
21
|
+
};
|
|
22
|
+
const isSection = (el)=>{
|
|
23
|
+
const tag = el.getAttribute('data-component-tag');
|
|
24
|
+
return tag === 'Section';
|
|
25
|
+
};
|
|
26
|
+
const isOverToolbarPosition = (el, parent)=>{
|
|
27
|
+
const rect = el.getBoundingClientRect();
|
|
28
|
+
const rectP = parent.getBoundingClientRect();
|
|
29
|
+
// 32px = toolbar active height
|
|
30
|
+
return rect.top - rectP.top < 32 + 1;
|
|
31
|
+
};
|
|
32
|
+
const findOverflowParent = (element, initEl)=>{
|
|
33
|
+
const thisEl = element;
|
|
34
|
+
const origEl = initEl || thisEl;
|
|
35
|
+
if (!thisEl) return;
|
|
36
|
+
if (isSection(thisEl)) return;
|
|
37
|
+
if (notVisible(thisEl) && isOverToolbarPosition(initEl, thisEl)) return thisEl;
|
|
38
|
+
if (thisEl.parentElement) {
|
|
39
|
+
return findOverflowParent(thisEl.parentElement, origEl);
|
|
40
|
+
} else {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
18
44
|
const ComponentToolbarPreview = ({ ...props })=>{
|
|
19
45
|
const isThemeSection = props.isThemeSection;
|
|
20
46
|
const editingPageType = useShopStore((s)=>s.pageType);
|
|
@@ -82,11 +108,16 @@ const ComponentToolbarPreview = ({ ...props })=>{
|
|
|
82
108
|
setIsShowParentRevert(false);
|
|
83
109
|
setIsShowParent(false);
|
|
84
110
|
} else {
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
111
|
+
const $parentOverflow = findOverflowParent($toolbar, $toolbar);
|
|
112
|
+
if ($parentOverflow) {
|
|
87
113
|
setIsShowParentRevert(true);
|
|
88
114
|
} else {
|
|
89
|
-
|
|
115
|
+
const rect = $toolbar.getBoundingClientRect();
|
|
116
|
+
if (rect.top < parents.length * 24) {
|
|
117
|
+
setIsShowParentRevert(true);
|
|
118
|
+
} else {
|
|
119
|
+
setIsShowParentRevert(false);
|
|
120
|
+
}
|
|
90
121
|
}
|
|
91
122
|
setIsShowParent(true);
|
|
92
123
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Children
|
|
1
|
+
import { Children } from 'react';
|
|
2
2
|
import { ComponentToolbarPreview } from '../components/ComponentToolbarPreview.js';
|
|
3
3
|
|
|
4
4
|
const isEmptyChildren = (children)=>{
|
|
5
5
|
let arrChild = Children.toArray(children);
|
|
6
|
-
arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview
|
|
6
|
+
arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview);
|
|
7
7
|
return Children.count(arrChild) < 1 || !children;
|
|
8
8
|
};
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "1.23.0-staging.
|
|
3
|
+
"version": "1.23.0-staging.29",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@gem-sdk/adapter-shopify": "1.23.0-staging.26",
|
|
28
|
-
"@gem-sdk/styles": "1.23.0-staging.
|
|
28
|
+
"@gem-sdk/styles": "1.23.0-staging.29"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"react-error-boundary": "4.0.10",
|