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";
var portal_default = Portal;

//#endregion
export { Portal, portal_default as default };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=portal.js.map