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.

84 lines (82 loc) 2.77 kB
'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import { DialogRootContext } from './DialogRootContext.js'; import { useDialogRoot } from './useDialogRoot.js'; import { PortalContext } from '../../portal/PortalContext.js'; /** * Groups all parts of the dialog. * Doesn’t render its own HTML element. * * Documentation: [Base UI Dialog](https://base-ui.com/react/components/dialog) */ import { jsx as _jsx } from "react/jsx-runtime"; const DialogRoot = function DialogRoot(props) { const { children, defaultOpen = false, dismissible = true, modal = true, onOpenChange, open } = props; const parentDialogRootContext = React.useContext(DialogRootContext); const dialogRoot = useDialogRoot({ open, defaultOpen, onOpenChange, modal, dismissible, onNestedDialogClose: parentDialogRootContext?.onNestedDialogClose, onNestedDialogOpen: parentDialogRootContext?.onNestedDialogOpen }); const nested = Boolean(parentDialogRootContext); const contextValue = React.useMemo(() => ({ ...dialogRoot, nested, dismissible }), [dialogRoot, nested, dismissible]); return /*#__PURE__*/_jsx(DialogRootContext.Provider, { value: contextValue, children: /*#__PURE__*/_jsx(PortalContext.Provider, { value: dialogRoot.mounted, children: children }) }); }; process.env.NODE_ENV !== "production" ? DialogRoot.propTypes /* remove-proptypes */ = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * @ignore */ children: PropTypes.node, /** * Whether the dialog is initially open. * * To render a controlled dialog, use the `open` prop instead. * @default false */ defaultOpen: PropTypes.bool, /** * Determines whether the dialog should close on outside clicks. * @default true */ dismissible: PropTypes.bool, /** * Whether the dialog should prevent outside clicks and lock page scroll when open. * @default true */ modal: PropTypes.bool, /** * Event handler called when the dialog is opened or closed. */ onOpenChange: PropTypes.func, /** * Whether the dialog is currently open. */ open: PropTypes.bool } : void 0; export { DialogRoot };