@xanui/core 1.1.22 → 1.1.23
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/hooks/usePortal.js +0 -3
- package/hooks/usePortal.js.map +1 -1
- package/hooks/usePortal.mjs +0 -3
- package/hooks/usePortal.mjs.map +1 -1
- package/package.json +1 -1
package/hooks/usePortal.js
CHANGED
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
}, [options.autoMount]);
|
|
13
13
|
const container = () => {
|
|
14
14
|
const rootEle = index.appRootElement();
|
|
15
|
-
if ((options === null || options === void 0 ? void 0 : options.container) && !rootEle.contains(options.container)) {
|
|
16
|
-
throw new Error(`Provided container is not a child of AppRoot. Please ensure that the container is within the AppRoot component.`);
|
|
17
|
-
}
|
|
18
15
|
const container = (options === null || options === void 0 ? void 0 : options.container) || rootEle;
|
|
19
16
|
if (!container)
|
|
20
17
|
throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);
|
package/hooks/usePortal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePortal.js","sources":["../../src/hooks/usePortal.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { ThemeProvider, useTheme } from \"../theme\";\nimport { appRootElement } from \"../AppRoot\";\n\nexport type UsePortalOptions = {\n container?: HTMLElement;\n autoMount?: boolean;\n}\n\nexport function usePortal(children: React.ReactNode, options?: UsePortalOptions) {\n options = options || {};\n if (options.autoMount === undefined) {\n options.autoMount = true;\n }\n const [mounted, setMounted] = React.useState(options.autoMount);\n const theme = useTheme();\n const { el, root } = useMemo(() => {\n const el = document.createElement(\"div\");\n const root = createRoot(el);\n return { el, root };\n }, [options.autoMount]);\n\n const container = () => {\n const rootEle = appRootElement();\n
|
|
1
|
+
{"version":3,"file":"usePortal.js","sources":["../../src/hooks/usePortal.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { ThemeProvider, useTheme } from \"../theme\";\nimport { appRootElement } from \"../AppRoot\";\n\nexport type UsePortalOptions = {\n container?: HTMLElement;\n autoMount?: boolean;\n}\n\nexport function usePortal(children: React.ReactNode, options?: UsePortalOptions) {\n options = options || {};\n if (options.autoMount === undefined) {\n options.autoMount = true;\n }\n const [mounted, setMounted] = React.useState(options.autoMount);\n const theme = useTheme();\n const { el, root } = useMemo(() => {\n const el = document.createElement(\"div\");\n const root = createRoot(el);\n return { el, root };\n }, [options.autoMount]);\n\n const container = () => {\n const rootEle = appRootElement();\n const container = options?.container || rootEle\n if (!container) throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);\n return container;\n }\n\n const mount = () => {\n const cont = container();\n if (!cont.contains(el)) {\n cont.appendChild(el);\n }\n root.render(<ThemeProvider theme={theme.name}>{children}</ThemeProvider>)\n }\n\n const unmount = () => {\n root.render(null)\n el.remove();\n }\n\n\n useEffect(() => {\n if (mounted) {\n mount()\n } else {\n unmount()\n }\n }, [mounted]);\n\n useEffect(() => {\n if (mounted) {\n mount()\n }\n }, [children]);\n\n useEffect(() => {\n return () => {\n unmount()\n };\n }, []);\n\n return {\n isMount: () => mounted,\n mount: () => setMounted(true),\n unmount: () => setMounted(false)\n }\n}\n\n\nexport default usePortal;"],"names":["useTheme","useMemo","createRoot","appRootElement","_jsx","ThemeProvider","useEffect"],"mappings":"yaAUM,SAAU,SAAS,CAAC,QAAyB,EAAE,OAA0B,EAAA;AAC5E,IAAA,OAAO,GAAG,OAAO,IAAI,EAAE;AACvB,IAAA,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;AAClC,QAAA,OAAO,CAAC,SAAS,GAAG,IAAI;IAC3B;AACA,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/D,IAAA,MAAM,KAAK,GAAGA,aAAQ,EAAE;IAC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EAAE,CAAC,OAAO,CAAC,CAAC;IAEbA,eAAS,CAAC,MAAK;QACZ,IAAI,OAAO,EAAE;AACV,YAAA,KAAK,EAAE;QACV;AACH,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEdA,eAAS,CAAC,MAAK;AACZ,QAAA,OAAO,MAAK;AACT,YAAA,OAAO,EAAE;AACZ,QAAA,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC;IAEN,OAAO;AACJ,QAAA,OAAO,EAAE,MAAM,OAAO;AACtB,QAAA,KAAK,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC;AAC7B,QAAA,OAAO,EAAE,MAAM,UAAU,CAAC,KAAK;KACjC;AACJ"}
|
package/hooks/usePortal.mjs
CHANGED
|
@@ -12,9 +12,6 @@ import {jsx}from'react/jsx-runtime';import React__default,{useMemo,useEffect}fro
|
|
|
12
12
|
}, [options.autoMount]);
|
|
13
13
|
const container = () => {
|
|
14
14
|
const rootEle = appRootElement();
|
|
15
|
-
if ((options === null || options === void 0 ? void 0 : options.container) && !rootEle.contains(options.container)) {
|
|
16
|
-
throw new Error(`Provided container is not a child of AppRoot. Please ensure that the container is within the AppRoot component.`);
|
|
17
|
-
}
|
|
18
15
|
const container = (options === null || options === void 0 ? void 0 : options.container) || rootEle;
|
|
19
16
|
if (!container)
|
|
20
17
|
throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);
|
package/hooks/usePortal.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePortal.mjs","sources":["../../src/hooks/usePortal.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { ThemeProvider, useTheme } from \"../theme\";\nimport { appRootElement } from \"../AppRoot\";\n\nexport type UsePortalOptions = {\n container?: HTMLElement;\n autoMount?: boolean;\n}\n\nexport function usePortal(children: React.ReactNode, options?: UsePortalOptions) {\n options = options || {};\n if (options.autoMount === undefined) {\n options.autoMount = true;\n }\n const [mounted, setMounted] = React.useState(options.autoMount);\n const theme = useTheme();\n const { el, root } = useMemo(() => {\n const el = document.createElement(\"div\");\n const root = createRoot(el);\n return { el, root };\n }, [options.autoMount]);\n\n const container = () => {\n const rootEle = appRootElement();\n
|
|
1
|
+
{"version":3,"file":"usePortal.mjs","sources":["../../src/hooks/usePortal.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { ThemeProvider, useTheme } from \"../theme\";\nimport { appRootElement } from \"../AppRoot\";\n\nexport type UsePortalOptions = {\n container?: HTMLElement;\n autoMount?: boolean;\n}\n\nexport function usePortal(children: React.ReactNode, options?: UsePortalOptions) {\n options = options || {};\n if (options.autoMount === undefined) {\n options.autoMount = true;\n }\n const [mounted, setMounted] = React.useState(options.autoMount);\n const theme = useTheme();\n const { el, root } = useMemo(() => {\n const el = document.createElement(\"div\");\n const root = createRoot(el);\n return { el, root };\n }, [options.autoMount]);\n\n const container = () => {\n const rootEle = appRootElement();\n const container = options?.container || rootEle\n if (!container) throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);\n return container;\n }\n\n const mount = () => {\n const cont = container();\n if (!cont.contains(el)) {\n cont.appendChild(el);\n }\n root.render(<ThemeProvider theme={theme.name}>{children}</ThemeProvider>)\n }\n\n const unmount = () => {\n root.render(null)\n el.remove();\n }\n\n\n useEffect(() => {\n if (mounted) {\n mount()\n } else {\n unmount()\n }\n }, [mounted]);\n\n useEffect(() => {\n if (mounted) {\n mount()\n }\n }, [children]);\n\n useEffect(() => {\n return () => {\n unmount()\n };\n }, []);\n\n return {\n isMount: () => mounted,\n mount: () => setMounted(true),\n unmount: () => setMounted(false)\n }\n}\n\n\nexport default usePortal;"],"names":["React","_jsx"],"mappings":"kYAUM,SAAU,SAAS,CAAC,QAAyB,EAAE,OAA0B,EAAA;AAC5E,IAAA,OAAO,GAAG,OAAO,IAAI,EAAE;AACvB,IAAA,IAAI,OA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