UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

40 lines (39 loc) 1.27 kB
"use strict"; 'use client'; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.DialogPortal = DialogPortal; var React = _interopRequireWildcard(require("react")); var _floatingUiReact = require("../../floating-ui-react"); var _DialogRootContext = require("../root/DialogRootContext"); var _DialogPortalContext = require("./DialogPortalContext"); var _jsxRuntime = require("react/jsx-runtime"); /** * A portal element that moves the popup to a different part of the DOM. * By default, the portal element is appended to `<body>`. * * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog) */ function DialogPortal(props) { const { children, keepMounted = false, container } = props; const { mounted } = (0, _DialogRootContext.useDialogRootContext)(); const shouldRender = mounted || keepMounted; if (!shouldRender) { return null; } return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogPortalContext.DialogPortalContext.Provider, { value: keepMounted, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingUiReact.FloatingPortal, { root: container, children: children }) }); }