UNPKG

@veracity/vui

Version:

Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.

21 lines (19 loc) 855 B
import { useEffect, useState } from "react"; import { Fragment as Fragment$1, jsx } from "react/jsx-runtime"; import { createPortal } from "react-dom"; //#region src/portal/portal.tsx /** Provided children are portaled to document.body or custom container. */ const Portal = (props) => { const { children, containerRef, disablePortal } = props; const [mountNode, setMountNode] = useState(); useEffect(() => { if (!disablePortal) setMountNode(containerRef?.current ?? document.body); }, [disablePortal]); if (disablePortal) return /* @__PURE__ */ jsx(Fragment$1, { children }); return mountNode ? createPortal(children, mountNode) : /* @__PURE__ */ jsx(Fragment$1, { children: mountNode }); }; Portal.displayName = "Portal"; //#endregion export { Portal, Portal as default }; globalThis.__vuiVersion__ = "5.3.1" //# sourceMappingURL=portal.js.map