@jiggai/kitchen-plugin-marketing 0.5.4 → 0.5.5

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.
@@ -10,10 +10,25 @@
10
10
  const useMemo = R.useMemo;
11
11
  const useCallback = R.useCallback;
12
12
  const useRef = R.useRef;
13
- const Portal = ({ children }) => {
14
- if (RD?.createPortal) return RD.createPortal(children, document.body);
13
+ function Portal({ children }) {
14
+ const rd = RD || typeof window !== "undefined" && window.ReactDOM;
15
+ const [container] = useState(() => {
16
+ if (typeof document === "undefined") return null;
17
+ const el = document.createElement("div");
18
+ el.setAttribute("data-ck-portal", "marketing");
19
+ return el;
20
+ });
21
+ useEffect(() => {
22
+ if (!container) return;
23
+ document.body.appendChild(container);
24
+ return () => {
25
+ document.body.removeChild(container);
26
+ };
27
+ }, [container]);
28
+ if (rd?.createPortal && container) return rd.createPortal(children, container);
29
+ if (container) return rd?.createPortal ? rd.createPortal(children, container) : children;
15
30
  return children;
16
- };
31
+ }
17
32
  const s = {
18
33
  // layout
19
34
  container: { color: "var(--ck-text-primary)" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiggai/kitchen-plugin-marketing",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Marketing Suite plugin for ClawKitchen",
5
5
  "main": "dist/index.js",
6
6
  "files": [