@gravity-ui/uikit
Version:
Gravity UI base styling and components
24 lines (23 loc) • 995 B
JavaScript
'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { FloatingPortal } from '@floating-ui/react';
import { usePortalContainer } from "../../hooks/index.js";
import { ThemeProvider } from "../theme/index.js";
import { useThemeContext } from "../theme/useThemeContext.js";
import { block } from "../utils/cn.js";
import "./Portal.css";
const b = block('portal');
export function Portal({ container, children, disablePortal }) {
const defaultContainer = usePortalContainer();
const { scoped } = useThemeContext();
const containerNode = container ?? defaultContainer;
if (disablePortal) {
return _jsx(React.Fragment, { children: children });
}
if (containerNode) {
return (_jsx(FloatingPortal, { root: containerNode, children: scoped ? (_jsx(ThemeProvider, { rootClassName: b('theme-wrapper'), scoped: true, children: children })) : (children) }));
}
return null;
}
//# sourceMappingURL=Portal.js.map