1 | import * as React from 'react';
|
2 | import { SxProps } from '@mui/system';
|
3 | import { BackdropProps, InternalStandardProps as StandardProps } from '..';
|
4 | import Paper, { PaperProps } from '../Paper';
|
5 | import Modal, { ModalOwnerState, ModalProps } from '../Modal';
|
6 | import { Theme } from '../styles';
|
7 | import { TransitionProps } from '../transitions/transition';
|
8 | import { PopoverClasses } from './popoverClasses';
|
9 | import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
|
10 |
|
11 | export interface PopoverSlots {
|
12 | root: React.ElementType;
|
13 | paper: React.ElementType;
|
14 | }
|
15 |
|
16 | export type PopoverSlotsAndSlotProps = CreateSlotsAndSlotProps<
|
17 | PopoverSlots,
|
18 | {
|
19 | root: SlotProps<typeof Modal, {}, ModalOwnerState>;
|
20 | paper: SlotProps<typeof Paper, {}, {}>;
|
21 | }
|
22 | >;
|
23 |
|
24 | export interface PopoverOrigin {
|
25 | vertical: 'top' | 'center' | 'bottom' | number;
|
26 | horizontal: 'left' | 'center' | 'right' | number;
|
27 | }
|
28 |
|
29 | export interface PopoverPosition {
|
30 | top: number;
|
31 | left: number;
|
32 | }
|
33 |
|
34 | export type PopoverReference = 'anchorEl' | 'anchorPosition' | 'none';
|
35 |
|
36 | interface PopoverVirtualElement {
|
37 | getBoundingClientRect: () => DOMRect;
|
38 | nodeType: Node['ELEMENT_NODE'];
|
39 | }
|
40 |
|
41 | export interface PopoverProps
|
42 | extends StandardProps<
|
43 | Omit<ModalProps, 'slots' | 'slotProps' | 'BackdropProps' | 'BackdropComponent'>,
|
44 | 'children'
|
45 | >,
|
46 | PopoverSlotsAndSlotProps {
|
47 | |
48 |
|
49 |
|
50 |
|
51 | action?: React.Ref<PopoverActions>;
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 | anchorEl?:
|
58 | | null
|
59 | | Element
|
60 | | (() => Element)
|
61 | | PopoverVirtualElement
|
62 | | (() => PopoverVirtualElement);
|
63 | /**
|
64 | * This is the point on the anchor where the popover's
|
65 | * `anchorEl` will attach to. This is not used when the
|
66 | * anchorReference is 'anchorPosition'.
|
67 | *
|
68 | * Options:
|
69 | * vertical: [top, center, bottom];
|
70 | * horizontal: [left, center, right].
|
71 | * @default {
|
72 | * vertical: 'top',
|
73 | * horizontal: 'left',
|
74 | * }
|
75 | */
|
76 | anchorOrigin?: PopoverOrigin;
|
77 | /**
|
78 | * This is the position that may be used to set the position of the popover.
|
79 | * The coordinates are relative to the application's client area.
|
80 | */
|
81 | anchorPosition?: PopoverPosition;
|
82 | /**
|
83 | * This determines which anchor prop to refer to when setting
|
84 | * the position of the popover.
|
85 | * @default 'anchorEl'
|
86 | */
|
87 | anchorReference?: PopoverReference;
|
88 | /**
|
89 | * A backdrop component. This prop enables custom backdrop rendering.
|
90 | * @deprecated Use `slotProps.root.slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
|
91 | * Use the `slotProps.root.slots.backdrop` prop to make your application ready for the next version of Material UI.
|
92 | * @default styled(Backdrop, {
|
93 | * name: 'MuiModal',
|
94 | * slot: 'Backdrop',
|
95 | * overridesResolver: (props, styles) => {
|
96 | * return styles.backdrop;
|
97 | * },
|
98 | * })({
|
99 | * zIndex: -1,
|
100 | * })
|
101 | */
|
102 | BackdropComponent?: React.ElementType<BackdropProps>;
|
103 | /**
|
104 | * Props applied to the [`Backdrop`](/material-ui/api/backdrop/) element.
|
105 | * @deprecated Use `slotProps.root.slotProps.backdrop` instead.
|
106 | */
|
107 | BackdropProps?: Partial<BackdropProps>;
|
108 | /**
|
109 | * The content of the component.
|
110 | */
|
111 | children?: React.ReactNode;
|
112 | /**
|
113 | * Override or extend the styles applied to the component.
|
114 | */
|
115 | classes?: Partial<PopoverClasses>;
|
116 | /**
|
117 | * An HTML element, component instance, or function that returns either.
|
118 | * The `container` will passed to the Modal component.
|
119 | *
|
120 | * By default, it uses the body of the anchorEl's top-level document object,
|
121 | * so it's simply `document.body` most of the time.
|
122 | */
|
123 | container?: ModalProps['container'];
|
124 | /**
|
125 | * The elevation of the popover.
|
126 | * @default 8
|
127 | */
|
128 | elevation?: number;
|
129 | /**
|
130 | * Specifies how close to the edge of the window the popover can appear.
|
131 | * If null, the popover will not be constrained by the window.
|
132 | * @default 16
|
133 | */
|
134 | marginThreshold?: number | null;
|
135 | onClose?: ModalProps['onClose'];
|
136 | /**
|
137 | * If `true`, the component is shown.
|
138 | */
|
139 | open: boolean;
|
140 | /**
|
141 | * Props applied to the [`Paper`](https:
|
142 | *
|
143 | * This prop is an alias for `slotProps.paper` and will be overriden by it if both are used.
|
144 | * @deprecated Use `slotProps.paper` instead.
|
145 | *
|
146 | * @default {}
|
147 | */
|
148 | PaperProps?: Partial<PaperProps<React.ElementType>>;
|
149 | |
150 |
|
151 |
|
152 | sx?: SxProps<Theme>;
|
153 | |
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 | transformOrigin?: PopoverOrigin;
|
166 | |
167 |
|
168 |
|
169 |
|
170 |
|
171 | TransitionComponent?: React.JSXElementConstructor<
|
172 | TransitionProps & { children: React.ReactElement<unknown, any> }
|
173 | >;
|
174 | |
175 |
|
176 |
|
177 |
|
178 | transitionDuration?: TransitionProps['timeout'] | 'auto';
|
179 | |
180 |
|
181 |
|
182 |
|
183 |
|
184 | TransitionProps?: TransitionProps;
|
185 | }
|
186 |
|
187 | export interface PopoverActions {
|
188 | updatePosition(): void;
|
189 | }
|
190 |
|
191 | export function getOffsetTop(rect: DOMRect, vertical: number | 'center' | 'bottom' | 'top'): number;
|
192 |
|
193 | export function getOffsetLeft(
|
194 | rect: DOMRect,
|
195 | horizontal: number | 'center' | 'right' | 'left',
|
196 | ): number;
|
197 |
|
198 | type PopoverRootProps = NonNullable<PopoverProps['slotProps']>['root'];
|
199 | type PopoverPaperProps = NonNullable<PopoverProps['slotProps']>['paper'];
|
200 |
|
201 | export declare const PopoverRoot: React.FC<PopoverRootProps>;
|
202 | export declare const PopoverPaper: React.FC<PopoverPaperProps>;
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 | export default function Popover(props: PopoverProps): React.JSX.Element;
|
217 |
|
\ | No newline at end of file |