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.

71 lines (69 loc) 2.51 kB
'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import { AlertDialogRootContext } from './AlertDialogRootContext.js'; import { useDialogRoot } from '../../dialog/root/useDialogRoot.js'; import { PortalContext } from '../../portal/PortalContext.js'; /** * Groups all parts of the alert dialog. * Doesn’t render its own HTML element. * * Documentation: [Base UI Alert Dialog](https://base-ui.com/react/components/alert-dialog) */ import { jsx as _jsx } from "react/jsx-runtime"; const AlertDialogRoot = function AlertDialogRoot(props) { const { children, defaultOpen = false, onOpenChange, open } = props; const parentDialogRootContext = React.useContext(AlertDialogRootContext); const dialogRoot = useDialogRoot({ open, defaultOpen, onOpenChange, modal: true, dismissible: false, onNestedDialogClose: parentDialogRootContext?.onNestedDialogClose, onNestedDialogOpen: parentDialogRootContext?.onNestedDialogOpen }); const nested = Boolean(parentDialogRootContext); const contextValue = React.useMemo(() => ({ ...dialogRoot, nested }), [dialogRoot, nested]); return /*#__PURE__*/_jsx(AlertDialogRootContext.Provider, { value: contextValue, children: /*#__PURE__*/_jsx(PortalContext.Provider, { value: dialogRoot.mounted, children: children }) }); }; process.env.NODE_ENV !== "production" ? AlertDialogRoot.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, /** * 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 { AlertDialogRoot };