import { SlotComponentProps } from '@mui/utils/types'; import * as React from 'react'; import { BackdropProps } from '../Backdrop'; import { Modal, ModalProps } from '../Modal'; import { Paper } from '../Paper'; import { TransitionProps } from '../transitions/transition'; import { CreateSlotsAndSlotProps, SlotCommonProps, SlotProps } from '../types/slot'; import { PopoverClasses } from './Popover.classes'; export interface PopoverSlots { /** * The component used for the root slot. * @default Modal */ root: React.ElementType; /** * The component used for the paper slot. * @default Paper */ paper: React.ElementType; /** * The component used for the transition slot. * @default Grow */ transition: React.ElementType; /** * The component used for the backdrop slot. * @default Backdrop */ backdrop: React.ElementType; /** * The component used for the arrow slot. * @default 'span' */ arrow: React.ElementType; } export interface PopoverRootSlotPropsOverrides { } export interface PopoverPaperSlotPropsOverrides { } export interface PopoverTransitionSlotPropsOverrides { } export interface PopoverBackdropSlotPropsOverrides { } export interface PopoverArrowSlotPropsOverrides { } export type PopoverSlotsAndSlotProps = CreateSlotsAndSlotProps; /** * Props forwarded to the paper slot. * By default, the avaible props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component. */ paper: SlotProps; /** * Props forwarded to the transition slot. * By default, the avaible props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component. */ transition: SlotComponentProps; /** * Props forwarded to the backdrop slot. * By default, the avaible props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component. */ backdrop: SlotProps, PopoverBackdropSlotPropsOverrides, PopoverOwnerState>; /** * Props forwarded to the arrow slot. * By default, the avaible props are based on the span element. */ arrow: SlotProps<'span', PopoverArrowSlotPropsOverrides, PopoverOwnerState>; }>; export interface PopoverOrigin { vertical: 'top' | 'center' | 'bottom' | number; horizontal: 'left' | 'center' | 'right' | number; } export interface PopoverPosition { top: number; left: number; } export type PopoverReference = 'anchorEl' | 'anchorPosition' | 'none'; interface PopoverVirtualElement { getBoundingClientRect: () => DOMRect; nodeType: Node['ELEMENT_NODE']; } export type PopoverPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end'; export interface PopoverProps extends Omit, 'children'>, PopoverSlotsAndSlotProps, SlotCommonProps { /** * A ref for imperative actions. * It currently only supports updatePosition() action. */ action?: React.Ref; /** * If `true`, adds an arrow to the popover. * @default false */ showArrow?: boolean; /** * Popover placement. * @default 'bottom' */ placement?: PopoverPlacement; /** * An HTML element, [PopoverVirtualElement](https://mui.com/material-ui/react-popover/#virtual-element), * or a function that returns either. * It's used to set the position of the popover. */ anchorEl?: null | Element | PopoverVirtualElement | (() => Element | PopoverVirtualElement | null); /** * This is the point on the anchor where the popover's * `anchorEl` will attach to. This is not used when the * anchorReference is 'anchorPosition'. * Note: This prop is ignored when `placement` is provided. * * Options: * vertical: [top, center, bottom]; * horizontal: [left, center, right]. * @default { * vertical: 'top', * horizontal: 'left', * } */ anchorOrigin?: PopoverOrigin; /** * This is the position that may be used to set the position of the popover. * The coordinates are relative to the application's client area. */ anchorPosition?: PopoverPosition; /** * This determines which anchor prop to refer to when setting * the position of the popover. * @default 'anchorEl' */ anchorReference?: PopoverReference; /** * The content of the component. */ children?: React.ReactNode; /** * Override or extend the styles applied to the component. */ classes?: Partial; /** * An HTML element, component instance, or function that returns either. * The `container` will passed to the Modal component. * * By default, it uses the body of the anchorEl's top-level document object, * so it's simply `document.body` most of the time. */ container?: ModalProps['container']; /** * The elevation of the popover. * @default 2 */ elevation?: number; /** * Specifies how close to the edge of the window the popover can appear. * If null, the popover will not be constrained by the window. * @default 16 */ marginThreshold?: number | null; onClose?: ModalProps['onClose']; /** * If `true`, the component is shown. */ open: boolean; /** * This is the point on the popover which * will attach to the anchor's origin. * Note: This prop is ignored when `placement` is provided. * * Options: * vertical: [top, center, bottom, x(px)]; * horizontal: [left, center, right, x(px)]. * @default { * vertical: 'top', * horizontal: 'left', * } */ transformOrigin?: PopoverOrigin; /** * Set to 'auto' to automatically calculate transition time based on height. * @default 'auto' */ transitionDuration?: TransitionProps['timeout'] | 'auto'; } export interface PopoverOwnerState extends Omit { placement: PopoverPlacement; } export interface PopoverActions { updatePosition(): void; } type PopoverRootProps = NonNullable['root']; type PopoverPaperProps = NonNullable['paper']; export declare const PopoverRoot: React.FC; export declare const PopoverPaper: React.FC; export {};