@gem-sdk/pages 1.8.31 → 1.8.32

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.
@@ -18,9 +18,20 @@ const PopupManager = ()=>{
18
18
  }, [
19
19
  state
20
20
  ]);
21
- const setActiveModal = (modalId)=>{
22
- setModalActive(modalId);
23
- };
21
+ const onSetActiveModal = react.useCallback((e)=>{
22
+ const detail = e.detail;
23
+ setModalActive(detail?.modalId);
24
+ }, [
25
+ setModalActive
26
+ ]);
27
+ react.useEffect(()=>{
28
+ window.addEventListener('set-active-modal', onSetActiveModal);
29
+ return ()=>{
30
+ window.removeEventListener('set-active-modal', onSetActiveModal);
31
+ };
32
+ }, [
33
+ onSetActiveModal
34
+ ]);
24
35
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
25
36
  className: "pointer-events-none fixed inset-y-0 right-0 z-10 flex w-10 flex-col items-center justify-center gap-1 overflow-y-auto overflow-x-hidden text-sm",
26
37
  children: popups?.map((item)=>/*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -30,7 +41,7 @@ const PopupManager = ()=>{
30
41
  }),
31
42
  role: "button",
32
43
  "aria-hidden": "true",
33
- onClick: ()=>setActiveModal(item?.uid),
44
+ onClick: ()=>setModalActive(item?.uid),
34
45
  children: /*#__PURE__*/ jsxRuntime.jsx("span", {
35
46
  className: "text-ellipsis whitespace-nowrap",
36
47
  children: item?.settings?.name ?? 'Popup Name'
@@ -25,6 +25,7 @@ const Toolbox = ()=>{
25
25
  const changeSwatches = core.useShopStore((s)=>s.changeSwatches);
26
26
  const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
27
27
  const [initEventSuccess, setInitEventSuccess] = react.useState(false);
28
+ const clearModal = core.useModalStore((s)=>s.clearModal);
28
29
  // Revalidate all query with key match query/
29
30
  const onRevalidateQuery = react.useCallback(()=>{
30
31
  matchMutate(/query\//);
@@ -78,6 +79,7 @@ const Toolbox = ()=>{
78
79
  }, []);
79
80
  // Init builder data
80
81
  const onInitBuilder = react.useCallback((e)=>{
82
+ clearModal();
81
83
  try {
82
84
  const detail = e.detail;
83
85
  if (detail.data) {
@@ -92,7 +94,8 @@ const Toolbox = ()=>{
92
94
  }
93
95
  }, [
94
96
  initNormalizeState,
95
- initState
97
+ initState,
98
+ clearModal
96
99
  ]);
97
100
  // Add new entity
98
101
  const onAddEntity = react.useCallback((e)=>{
@@ -1,6 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { useBuilderPreviewStore, useModalStore, cls } from '@gem-sdk/core';
3
- import { memo, useMemo } from 'react';
3
+ import { memo, useMemo, useCallback, useEffect } from 'react';
4
4
 
5
5
  const isDialog = (item)=>!!item && item?.tag === 'Dialog' && item.type === 'component';
6
6
  const PopupManager = ()=>{
@@ -14,9 +14,20 @@ const PopupManager = ()=>{
14
14
  }, [
15
15
  state
16
16
  ]);
17
- const setActiveModal = (modalId)=>{
18
- setModalActive(modalId);
19
- };
17
+ const onSetActiveModal = useCallback((e)=>{
18
+ const detail = e.detail;
19
+ setModalActive(detail?.modalId);
20
+ }, [
21
+ setModalActive
22
+ ]);
23
+ useEffect(()=>{
24
+ window.addEventListener('set-active-modal', onSetActiveModal);
25
+ return ()=>{
26
+ window.removeEventListener('set-active-modal', onSetActiveModal);
27
+ };
28
+ }, [
29
+ onSetActiveModal
30
+ ]);
20
31
  return /*#__PURE__*/ jsx("div", {
21
32
  className: "pointer-events-none fixed inset-y-0 right-0 z-10 flex w-10 flex-col items-center justify-center gap-1 overflow-y-auto overflow-x-hidden text-sm",
22
33
  children: popups?.map((item)=>/*#__PURE__*/ jsx("div", {
@@ -26,7 +37,7 @@ const PopupManager = ()=>{
26
37
  }),
27
38
  role: "button",
28
39
  "aria-hidden": "true",
29
- onClick: ()=>setActiveModal(item?.uid),
40
+ onClick: ()=>setModalActive(item?.uid),
30
41
  children: /*#__PURE__*/ jsx("span", {
31
42
  className: "text-ellipsis whitespace-nowrap",
32
43
  children: item?.settings?.name ?? 'Popup Name'
@@ -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, useSectionStore, useModalStore, 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';
@@ -21,6 +21,7 @@ const Toolbox = ()=>{
21
21
  const changeSwatches = useShopStore((s)=>s.changeSwatches);
22
22
  const changeLayoutSettings = useShopStore((s)=>s.changeLayoutSettings);
23
23
  const [initEventSuccess, setInitEventSuccess] = useState(false);
24
+ const clearModal = useModalStore((s)=>s.clearModal);
24
25
  // Revalidate all query with key match query/
25
26
  const onRevalidateQuery = useCallback(()=>{
26
27
  matchMutate(/query\//);
@@ -74,6 +75,7 @@ const Toolbox = ()=>{
74
75
  }, []);
75
76
  // Init builder data
76
77
  const onInitBuilder = useCallback((e)=>{
78
+ clearModal();
77
79
  try {
78
80
  const detail = e.detail;
79
81
  if (detail.data) {
@@ -88,7 +90,8 @@ const Toolbox = ()=>{
88
90
  }
89
91
  }, [
90
92
  initNormalizeState,
91
- initState
93
+ initState,
94
+ clearModal
92
95
  ]);
93
96
  // Add new entity
94
97
  const onAddEntity = useCallback((e)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "1.8.31",
3
+ "version": "1.8.32",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",