@gem-sdk/pages 1.57.0-staging.0 → 1.57.0-staging.11
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/builder/Header.js +0 -1
- package/dist/cjs/components/builder/InteractionSelectOnPageHeader.js +2 -2
- package/dist/cjs/components/builder/Toolbar.js +12 -37
- package/dist/cjs/components/builder/toolbar/const.js +0 -4
- package/dist/cjs/components/builder/toolbar/utils/waitForElementToExist.js +2 -2
- package/dist/esm/components/builder/Header.js +0 -1
- package/dist/esm/components/builder/InteractionSelectOnPageHeader.js +2 -2
- package/dist/esm/components/builder/Toolbar.js +13 -38
- package/dist/esm/components/builder/toolbar/const.js +1 -4
- package/dist/esm/components/builder/toolbar/utils/waitForElementToExist.js +2 -2
- package/package.json +5 -5
|
@@ -25,7 +25,6 @@ const Header = (props)=>{
|
|
|
25
25
|
const isSelectOnPage = core.usePageStore((s)=>s.interactionData?.isSelectOnPage);
|
|
26
26
|
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
27
27
|
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
28
|
-
console.log('isSelectOnPage', isSelectOnPage);
|
|
29
28
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
30
29
|
children: [
|
|
31
30
|
/*#__PURE__*/ jsxRuntime.jsx(SwitchView.default, {}),
|
|
@@ -86,7 +86,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
86
86
|
className: "gp-grow",
|
|
87
87
|
children: title
|
|
88
88
|
}),
|
|
89
|
-
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
89
|
+
settingType === 'TRIGGER' && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
90
90
|
className: "gp-w-[21px]",
|
|
91
91
|
children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
92
92
|
width: "16",
|
|
@@ -104,7 +104,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
104
104
|
})
|
|
105
105
|
]
|
|
106
106
|
}),
|
|
107
|
-
openDropdown && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
107
|
+
openDropdown && settingType === 'TRIGGER' && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
108
108
|
ref: popupRef,
|
|
109
109
|
className: "gp-p-2 gp-flex gp-flex-col gp-absolute gp-top-[calc(100%_+_4px)] gp-w-[280px] gp-bg-[#151515] gp-rounded-xl gp-text-white",
|
|
110
110
|
children: [
|
|
@@ -259,32 +259,6 @@ const Toolbar = ()=>{
|
|
|
259
259
|
setFocusTextEditor(false);
|
|
260
260
|
if (stopWatchReRenderComponent.current) stopWatchReRenderComponent.current();
|
|
261
261
|
}, []);
|
|
262
|
-
const watchComponentReRender = ($el, callback)=>{
|
|
263
|
-
// editor:component:render
|
|
264
|
-
const onComponentReRender = (e)=>{
|
|
265
|
-
const detail = e.detail;
|
|
266
|
-
if (detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
267
|
-
callback();
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
271
|
-
window.addEventListener('editor:component:render', onComponentReRender);
|
|
272
|
-
const componentTag = $el.getAttribute('data-component-tag');
|
|
273
|
-
// hotfix cho sale funnel release, nhưng cần tìm solution cho phần này
|
|
274
|
-
if (componentTag && !_const.COMPONENTS_TAG_NOT_LOAD_IMAGES.includes(componentTag)) {
|
|
275
|
-
const $images = $el.querySelectorAll('img');
|
|
276
|
-
if ($images?.length) {
|
|
277
|
-
$images.forEach(($img)=>{
|
|
278
|
-
$img.addEventListener('load', ()=>{
|
|
279
|
-
callback();
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
stopWatchReRenderComponent.current = ()=>{
|
|
285
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
286
|
-
};
|
|
287
|
-
};
|
|
288
262
|
const setActiveComponentSpacing = react.useCallback(({ $component })=>{
|
|
289
263
|
if (!$component) return;
|
|
290
264
|
const style = getComputedStyle($component);
|
|
@@ -375,16 +349,6 @@ const Toolbar = ()=>{
|
|
|
375
349
|
$component
|
|
376
350
|
});
|
|
377
351
|
removeHoverComponent();
|
|
378
|
-
// Reactive when component re-render
|
|
379
|
-
watchComponentReRender($component, ()=>{
|
|
380
|
-
setActiveComponent({
|
|
381
|
-
componentUid,
|
|
382
|
-
productId,
|
|
383
|
-
articleId,
|
|
384
|
-
timeAwait: 2000,
|
|
385
|
-
forceReActive: true
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
352
|
}, [
|
|
389
353
|
removeActiveComponent,
|
|
390
354
|
removeHoverComponent,
|
|
@@ -685,6 +649,14 @@ const Toolbar = ()=>{
|
|
|
685
649
|
}, [
|
|
686
650
|
isDragging
|
|
687
651
|
]);
|
|
652
|
+
const onComponentReRender = (e)=>{
|
|
653
|
+
const detail = e.detail;
|
|
654
|
+
if (currentComponentActive.current?.componentUid && detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
655
|
+
setActiveComponent({
|
|
656
|
+
...currentComponentActive.current
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
};
|
|
688
660
|
/* Register event */ react.useEffect(()=>{
|
|
689
661
|
document.addEventListener('mousemove', onMouseMove);
|
|
690
662
|
window.addEventListener('editor:active-component', onActiveComponent);
|
|
@@ -694,6 +666,7 @@ const Toolbar = ()=>{
|
|
|
694
666
|
window.addEventListener('editor:toolbar:show-parents', onShowParents);
|
|
695
667
|
window.addEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
696
668
|
window.addEventListener('editor:hover-component', onHoverComponent);
|
|
669
|
+
window.addEventListener('editor:component:render', onComponentReRender);
|
|
697
670
|
return ()=>{
|
|
698
671
|
document.removeEventListener('mousemove', onMouseMove);
|
|
699
672
|
window.removeEventListener('editor:active-component', onActiveComponent);
|
|
@@ -703,6 +676,7 @@ const Toolbar = ()=>{
|
|
|
703
676
|
window.removeEventListener('editor:toolbar:show-parents', onShowParents);
|
|
704
677
|
window.removeEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
705
678
|
window.removeEventListener('editor:hover-component', onHoverComponent);
|
|
679
|
+
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
706
680
|
};
|
|
707
681
|
}, [
|
|
708
682
|
onMouseMove,
|
|
@@ -712,7 +686,8 @@ const Toolbar = ()=>{
|
|
|
712
686
|
onIsEditingTextEditor,
|
|
713
687
|
onShowParents,
|
|
714
688
|
onResizeSpacing,
|
|
715
|
-
onHoverComponent
|
|
689
|
+
onHoverComponent,
|
|
690
|
+
onComponentReRender
|
|
716
691
|
]);
|
|
717
692
|
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
718
693
|
};
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const TOOLBAR_HOVER_HEIGHT = 24;
|
|
4
4
|
const TOOLBAR_ACTIVE_HEIGHT = 32;
|
|
5
|
-
const COMPONENTS_TAG_NOT_LOAD_IMAGES = [
|
|
6
|
-
'PostPurchaseProductImages'
|
|
7
|
-
];
|
|
8
5
|
|
|
9
|
-
exports.COMPONENTS_TAG_NOT_LOAD_IMAGES = COMPONENTS_TAG_NOT_LOAD_IMAGES;
|
|
10
6
|
exports.TOOLBAR_ACTIVE_HEIGHT = TOOLBAR_ACTIVE_HEIGHT;
|
|
11
7
|
exports.TOOLBAR_HOVER_HEIGHT = TOOLBAR_HOVER_HEIGHT;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const waitForElementToExist = (selector, timeout = 200)=>{
|
|
4
4
|
return new Promise((resolve)=>{
|
|
5
|
-
let intervalID;
|
|
6
|
-
let timeoutID;
|
|
5
|
+
let intervalID = null;
|
|
6
|
+
let timeoutID = null;
|
|
7
7
|
const findEl = ()=>{
|
|
8
8
|
const el = document.body.querySelector('#storefront')?.querySelector(selector);
|
|
9
9
|
if (el) {
|
|
@@ -21,7 +21,6 @@ const Header = (props)=>{
|
|
|
21
21
|
const isSelectOnPage = usePageStore((s)=>s.interactionData?.isSelectOnPage);
|
|
22
22
|
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
23
23
|
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
24
|
-
console.log('isSelectOnPage', isSelectOnPage);
|
|
25
24
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
26
25
|
children: [
|
|
27
26
|
/*#__PURE__*/ jsx(Devices, {}),
|
|
@@ -82,7 +82,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
82
82
|
className: "gp-grow",
|
|
83
83
|
children: title
|
|
84
84
|
}),
|
|
85
|
-
/*#__PURE__*/ jsx("div", {
|
|
85
|
+
settingType === 'TRIGGER' && /*#__PURE__*/ jsx("div", {
|
|
86
86
|
className: "gp-w-[21px]",
|
|
87
87
|
children: /*#__PURE__*/ jsx("svg", {
|
|
88
88
|
width: "16",
|
|
@@ -100,7 +100,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
100
100
|
})
|
|
101
101
|
]
|
|
102
102
|
}),
|
|
103
|
-
openDropdown && /*#__PURE__*/ jsxs("div", {
|
|
103
|
+
openDropdown && settingType === 'TRIGGER' && /*#__PURE__*/ jsxs("div", {
|
|
104
104
|
ref: popupRef,
|
|
105
105
|
className: "gp-p-2 gp-flex gp-flex-col gp-absolute gp-top-[calc(100%_+_4px)] gp-w-[280px] gp-bg-[#151515] gp-rounded-xl gp-text-white",
|
|
106
106
|
children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { memo, useRef, useCallback, useEffect } from 'react';
|
|
3
3
|
import { getDOMElementParents } from './toolbar/utils/getDOMElementParents.js';
|
|
4
|
-
import { TOOLBAR_ACTIVE_HEIGHT, TOOLBAR_HOVER_HEIGHT
|
|
4
|
+
import { TOOLBAR_ACTIVE_HEIGHT, TOOLBAR_HOVER_HEIGHT } from './toolbar/const.js';
|
|
5
5
|
import { getChildrenByAttrSelector } from './toolbar/utils/getChildrenByAttrSelector.js';
|
|
6
6
|
import { findOverflowParent } from './toolbar/utils/findOverflowParent.js';
|
|
7
7
|
import { waitForElementToExist } from './toolbar/utils/waitForElementToExist.js';
|
|
@@ -255,32 +255,6 @@ const Toolbar = ()=>{
|
|
|
255
255
|
setFocusTextEditor(false);
|
|
256
256
|
if (stopWatchReRenderComponent.current) stopWatchReRenderComponent.current();
|
|
257
257
|
}, []);
|
|
258
|
-
const watchComponentReRender = ($el, callback)=>{
|
|
259
|
-
// editor:component:render
|
|
260
|
-
const onComponentReRender = (e)=>{
|
|
261
|
-
const detail = e.detail;
|
|
262
|
-
if (detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
263
|
-
callback();
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
267
|
-
window.addEventListener('editor:component:render', onComponentReRender);
|
|
268
|
-
const componentTag = $el.getAttribute('data-component-tag');
|
|
269
|
-
// hotfix cho sale funnel release, nhưng cần tìm solution cho phần này
|
|
270
|
-
if (componentTag && !COMPONENTS_TAG_NOT_LOAD_IMAGES.includes(componentTag)) {
|
|
271
|
-
const $images = $el.querySelectorAll('img');
|
|
272
|
-
if ($images?.length) {
|
|
273
|
-
$images.forEach(($img)=>{
|
|
274
|
-
$img.addEventListener('load', ()=>{
|
|
275
|
-
callback();
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
stopWatchReRenderComponent.current = ()=>{
|
|
281
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
282
|
-
};
|
|
283
|
-
};
|
|
284
258
|
const setActiveComponentSpacing = useCallback(({ $component })=>{
|
|
285
259
|
if (!$component) return;
|
|
286
260
|
const style = getComputedStyle($component);
|
|
@@ -371,16 +345,6 @@ const Toolbar = ()=>{
|
|
|
371
345
|
$component
|
|
372
346
|
});
|
|
373
347
|
removeHoverComponent();
|
|
374
|
-
// Reactive when component re-render
|
|
375
|
-
watchComponentReRender($component, ()=>{
|
|
376
|
-
setActiveComponent({
|
|
377
|
-
componentUid,
|
|
378
|
-
productId,
|
|
379
|
-
articleId,
|
|
380
|
-
timeAwait: 2000,
|
|
381
|
-
forceReActive: true
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
348
|
}, [
|
|
385
349
|
removeActiveComponent,
|
|
386
350
|
removeHoverComponent,
|
|
@@ -681,6 +645,14 @@ const Toolbar = ()=>{
|
|
|
681
645
|
}, [
|
|
682
646
|
isDragging
|
|
683
647
|
]);
|
|
648
|
+
const onComponentReRender = (e)=>{
|
|
649
|
+
const detail = e.detail;
|
|
650
|
+
if (currentComponentActive.current?.componentUid && detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
651
|
+
setActiveComponent({
|
|
652
|
+
...currentComponentActive.current
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
};
|
|
684
656
|
/* Register event */ useEffect(()=>{
|
|
685
657
|
document.addEventListener('mousemove', onMouseMove);
|
|
686
658
|
window.addEventListener('editor:active-component', onActiveComponent);
|
|
@@ -690,6 +662,7 @@ const Toolbar = ()=>{
|
|
|
690
662
|
window.addEventListener('editor:toolbar:show-parents', onShowParents);
|
|
691
663
|
window.addEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
692
664
|
window.addEventListener('editor:hover-component', onHoverComponent);
|
|
665
|
+
window.addEventListener('editor:component:render', onComponentReRender);
|
|
693
666
|
return ()=>{
|
|
694
667
|
document.removeEventListener('mousemove', onMouseMove);
|
|
695
668
|
window.removeEventListener('editor:active-component', onActiveComponent);
|
|
@@ -699,6 +672,7 @@ const Toolbar = ()=>{
|
|
|
699
672
|
window.removeEventListener('editor:toolbar:show-parents', onShowParents);
|
|
700
673
|
window.removeEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
701
674
|
window.removeEventListener('editor:hover-component', onHoverComponent);
|
|
675
|
+
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
702
676
|
};
|
|
703
677
|
}, [
|
|
704
678
|
onMouseMove,
|
|
@@ -708,7 +682,8 @@ const Toolbar = ()=>{
|
|
|
708
682
|
onIsEditingTextEditor,
|
|
709
683
|
onShowParents,
|
|
710
684
|
onResizeSpacing,
|
|
711
|
-
onHoverComponent
|
|
685
|
+
onHoverComponent,
|
|
686
|
+
onComponentReRender
|
|
712
687
|
]);
|
|
713
688
|
return /*#__PURE__*/ jsx(Fragment, {});
|
|
714
689
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
const TOOLBAR_HOVER_HEIGHT = 24;
|
|
2
2
|
const TOOLBAR_ACTIVE_HEIGHT = 32;
|
|
3
|
-
const COMPONENTS_TAG_NOT_LOAD_IMAGES = [
|
|
4
|
-
'PostPurchaseProductImages'
|
|
5
|
-
];
|
|
6
3
|
|
|
7
|
-
export {
|
|
4
|
+
export { TOOLBAR_ACTIVE_HEIGHT, TOOLBAR_HOVER_HEIGHT };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const waitForElementToExist = (selector, timeout = 200)=>{
|
|
2
2
|
return new Promise((resolve)=>{
|
|
3
|
-
let intervalID;
|
|
4
|
-
let timeoutID;
|
|
3
|
+
let intervalID = null;
|
|
4
|
+
let timeoutID = null;
|
|
5
5
|
const findEl = ()=>{
|
|
6
6
|
const el = document.body.querySelector('#storefront')?.querySelector(selector);
|
|
7
7
|
if (el) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "1.57.0-staging.
|
|
3
|
+
"version": "1.57.0-staging.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"next": "latest"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "1.57.0-staging.
|
|
30
|
-
"@gem-sdk/plugin-cookie-bar": "1.57.0-staging.
|
|
31
|
-
"@gem-sdk/plugin-quick-view": "1.57.0-staging.
|
|
32
|
-
"@gem-sdk/plugin-sticky-add-to-cart": "1.57.0-staging.
|
|
29
|
+
"@gem-sdk/core": "1.57.0-staging.2",
|
|
30
|
+
"@gem-sdk/plugin-cookie-bar": "1.57.0-staging.2",
|
|
31
|
+
"@gem-sdk/plugin-quick-view": "1.57.0-staging.2",
|
|
32
|
+
"@gem-sdk/plugin-sticky-add-to-cart": "1.57.0-staging.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"next": ">=13"
|