@gem-sdk/pages 1.5.36 → 1.7.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.
|
@@ -21,6 +21,7 @@ const Toolbox = ()=>{
|
|
|
21
21
|
const addItem = core.useBuilderPreviewStore((s)=>s.addItem);
|
|
22
22
|
const moveItem = core.useBuilderPreviewStore((s)=>s.moveItem);
|
|
23
23
|
const removeItem = core.useBuilderPreviewStore((s)=>s.removeItem);
|
|
24
|
+
const setModalActive = core.useModalStore((s)=>s.setModalActive);
|
|
24
25
|
const addSection = core.useSectionStore((s)=>s.addSection);
|
|
25
26
|
const changeSwatches = core.useShopStore((s)=>s.changeSwatches);
|
|
26
27
|
const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
|
|
@@ -31,6 +32,12 @@ const Toolbox = ()=>{
|
|
|
31
32
|
}, [
|
|
32
33
|
matchMutate
|
|
33
34
|
]);
|
|
35
|
+
const onSetActiveModal = react.useCallback((e)=>{
|
|
36
|
+
const detail = e.detail;
|
|
37
|
+
setModalActive(detail?.modalId);
|
|
38
|
+
}, [
|
|
39
|
+
setModalActive
|
|
40
|
+
]);
|
|
34
41
|
// Update shop info
|
|
35
42
|
const onChangeShopInfo = react.useCallback((e)=>{
|
|
36
43
|
const detail = e.detail;
|
|
@@ -181,6 +188,7 @@ const Toolbox = ()=>{
|
|
|
181
188
|
changeLayoutSettings
|
|
182
189
|
]);
|
|
183
190
|
react.useEffect(()=>{
|
|
191
|
+
window.addEventListener('set-active-modal', onSetActiveModal);
|
|
184
192
|
window.addEventListener('update-shop-info', onChangeShopInfo);
|
|
185
193
|
window.addEventListener('revalidate-query', onRevalidateQuery);
|
|
186
194
|
window.addEventListener('init-builder', onInitBuilder);
|
|
@@ -193,6 +201,7 @@ const Toolbox = ()=>{
|
|
|
193
201
|
window.addEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
194
202
|
setInitEventSuccess(true);
|
|
195
203
|
return ()=>{
|
|
204
|
+
window.removeEventListener('set-active-modal', onSetActiveModal);
|
|
196
205
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
197
206
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
198
207
|
window.removeEventListener('init-builder', onInitBuilder);
|
|
@@ -214,11 +223,12 @@ const Toolbox = ()=>{
|
|
|
214
223
|
onChangeSwatchesData,
|
|
215
224
|
onRevalidateQuery,
|
|
216
225
|
onChangeShopInfo,
|
|
217
|
-
onChangeLayoutSettingData
|
|
226
|
+
onChangeLayoutSettingData,
|
|
227
|
+
onSetActiveModal
|
|
218
228
|
]);
|
|
219
229
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
220
230
|
className: core.cls({
|
|
221
|
-
|
|
231
|
+
toolbox: initEventSuccess
|
|
222
232
|
})
|
|
223
233
|
});
|
|
224
234
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useMatchMutate, useShopStore, useBuilderPreviewStore, useSectionStore, cls } from '@gem-sdk/core';
|
|
2
|
+
import { useMatchMutate, useShopStore, useBuilderPreviewStore, useModalStore, useSectionStore, cls } from '@gem-sdk/core';
|
|
3
3
|
import { memo, useState, useCallback, useEffect } from 'react';
|
|
4
4
|
import { createFontUrl } from '../../libs/google-fonts.js';
|
|
5
5
|
import { genCSS } from '../../libs/helpers/gen-css.js';
|
|
@@ -17,6 +17,7 @@ const Toolbox = ()=>{
|
|
|
17
17
|
const addItem = useBuilderPreviewStore((s)=>s.addItem);
|
|
18
18
|
const moveItem = useBuilderPreviewStore((s)=>s.moveItem);
|
|
19
19
|
const removeItem = useBuilderPreviewStore((s)=>s.removeItem);
|
|
20
|
+
const setModalActive = useModalStore((s)=>s.setModalActive);
|
|
20
21
|
const addSection = useSectionStore((s)=>s.addSection);
|
|
21
22
|
const changeSwatches = useShopStore((s)=>s.changeSwatches);
|
|
22
23
|
const changeLayoutSettings = useShopStore((s)=>s.changeLayoutSettings);
|
|
@@ -27,6 +28,12 @@ const Toolbox = ()=>{
|
|
|
27
28
|
}, [
|
|
28
29
|
matchMutate
|
|
29
30
|
]);
|
|
31
|
+
const onSetActiveModal = useCallback((e)=>{
|
|
32
|
+
const detail = e.detail;
|
|
33
|
+
setModalActive(detail?.modalId);
|
|
34
|
+
}, [
|
|
35
|
+
setModalActive
|
|
36
|
+
]);
|
|
30
37
|
// Update shop info
|
|
31
38
|
const onChangeShopInfo = useCallback((e)=>{
|
|
32
39
|
const detail = e.detail;
|
|
@@ -177,6 +184,7 @@ const Toolbox = ()=>{
|
|
|
177
184
|
changeLayoutSettings
|
|
178
185
|
]);
|
|
179
186
|
useEffect(()=>{
|
|
187
|
+
window.addEventListener('set-active-modal', onSetActiveModal);
|
|
180
188
|
window.addEventListener('update-shop-info', onChangeShopInfo);
|
|
181
189
|
window.addEventListener('revalidate-query', onRevalidateQuery);
|
|
182
190
|
window.addEventListener('init-builder', onInitBuilder);
|
|
@@ -189,6 +197,7 @@ const Toolbox = ()=>{
|
|
|
189
197
|
window.addEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
190
198
|
setInitEventSuccess(true);
|
|
191
199
|
return ()=>{
|
|
200
|
+
window.removeEventListener('set-active-modal', onSetActiveModal);
|
|
192
201
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
193
202
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
194
203
|
window.removeEventListener('init-builder', onInitBuilder);
|
|
@@ -210,11 +219,12 @@ const Toolbox = ()=>{
|
|
|
210
219
|
onChangeSwatchesData,
|
|
211
220
|
onRevalidateQuery,
|
|
212
221
|
onChangeShopInfo,
|
|
213
|
-
onChangeLayoutSettingData
|
|
222
|
+
onChangeLayoutSettingData,
|
|
223
|
+
onSetActiveModal
|
|
214
224
|
]);
|
|
215
225
|
return /*#__PURE__*/ jsx("div", {
|
|
216
226
|
className: cls({
|
|
217
|
-
|
|
227
|
+
toolbox: initEventSuccess
|
|
218
228
|
})
|
|
219
229
|
});
|
|
220
230
|
};
|
package/dist/types/index.d.ts
CHANGED