1 | import * as React from 'react';
|
2 | import { StandardProps } from '..';
|
3 | import { PaperProps } from '../Paper';
|
4 | import { ModalProps } from '../Modal';
|
5 | import { TransitionHandlerProps, TransitionProps } from '../transitions/transition';
|
6 |
|
7 | export interface PopoverOrigin {
|
8 | vertical: 'top' | 'center' | 'bottom' | number;
|
9 | horizontal: 'left' | 'center' | 'right' | number;
|
10 | }
|
11 |
|
12 | export interface PopoverPosition {
|
13 | top: number;
|
14 | left: number;
|
15 | }
|
16 |
|
17 | export type PopoverReference = 'anchorEl' | 'anchorPosition' | 'none';
|
18 |
|
19 | export interface PopoverProps
|
20 | extends StandardProps<ModalProps & Partial<TransitionHandlerProps>, PopoverClassKey, 'children'> {
|
21 | |
22 |
|
23 |
|
24 |
|
25 | action?: React.Ref<PopoverActions>;
|
26 | |
27 |
|
28 |
|
29 |
|
30 | anchorEl?: null | Element | ((element: Element) => Element);
|
31 | /**
|
32 | * This is the point on the anchor where the popover's
|
33 | * `anchorEl` will attach to. This is not used when the
|
34 | * anchorReference is 'anchorPosition'.
|
35 | *
|
36 | * Options:
|
37 | * vertical: [top, center, bottom];
|
38 | * horizontal: [left, center, right].
|
39 | */
|
40 | anchorOrigin?: PopoverOrigin;
|
41 | /**
|
42 | * This is the position that may be used
|
43 | * to set the position of the popover.
|
44 | * The coordinates are relative to
|
45 | * the application's client area.
|
46 | */
|
47 | anchorPosition?: PopoverPosition;
|
48 | /**
|
49 | * This determines which anchor prop to refer to to set
|
50 | * the position of the popover.
|
51 | */
|
52 | anchorReference?: PopoverReference;
|
53 | /**
|
54 | * The content of the component.
|
55 | */
|
56 | children?: React.ReactNode;
|
57 | /**
|
58 | * A HTML element, component instance, or function that returns either.
|
59 | * The `container` will passed to the Modal component.
|
60 | *
|
61 | * By default, it uses the body of the anchorEl's top-level document object,
|
62 | * so it's simply `document.body` most of the time.
|
63 | */
|
64 | container?: ModalProps['container'];
|
65 | /**
|
66 | * The elevation of the popover.
|
67 | */
|
68 | elevation?: number;
|
69 | /**
|
70 | * This function is called in order to retrieve the content anchor element.
|
71 | * It's the opposite of the `anchorEl` prop.
|
72 | * The content anchor element should be an element inside the popover.
|
73 | * It's used to correctly scroll and set the position of the popover.
|
74 | * The positioning strategy tries to make the content anchor element just above the
|
75 | * anchor element.
|
76 | */
|
77 | getContentAnchorEl?: null | ((element: Element) => Element);
|
78 | /**
|
79 | * Specifies how close to the edge of the window the popover can appear.
|
80 | */
|
81 | marginThreshold?: number;
|
82 | onClose?: ModalProps['onClose'];
|
83 | /**
|
84 | * Callback fired before the component is entering.
|
85 | * @deprecated Use the `TransitionProps` prop instead.
|
86 | */
|
87 | onEnter?: TransitionHandlerProps['onEnter'];
|
88 | /**
|
89 | * Callback fired when the component has entered.
|
90 | * @deprecated Use the `TransitionProps` prop instead.
|
91 | */
|
92 | onEntered?: TransitionHandlerProps['onEntered'];
|
93 | /**
|
94 | * Callback fired when the component is entering.
|
95 | * @deprecated Use the `TransitionProps` prop instead.
|
96 | */
|
97 | onEntering?: TransitionHandlerProps['onEntering'];
|
98 | /**
|
99 | * Callback fired before the component is exiting.
|
100 | * @deprecated Use the `TransitionProps` prop instead.
|
101 | */
|
102 | onExit?: TransitionHandlerProps['onExit'];
|
103 | /**
|
104 | * Callback fired when the component has exited.
|
105 | * @deprecated Use the `TransitionProps` prop instead.
|
106 | */
|
107 | onExited?: TransitionHandlerProps['onExited'];
|
108 | /**
|
109 | * Callback fired when the component is exiting.
|
110 | * @deprecated Use the `TransitionProps` prop instead.
|
111 | */
|
112 | onExiting?: TransitionHandlerProps['onExiting'];
|
113 | /**
|
114 | * If `true`, the popover is visible.
|
115 | */
|
116 | open: boolean;
|
117 | /**
|
118 | * Props applied to the [`Paper`](/api/paper/) element.
|
119 | */
|
120 | PaperProps?: Partial<PaperProps>;
|
121 | /**
|
122 | * This is the point on the popover which
|
123 | * will attach to the anchor's origin.
|
124 | *
|
125 | * Options:
|
126 | * vertical: [top, center, bottom, x(px)];
|
127 | * horizontal: [left, center, right, x(px)].
|
128 | */
|
129 | transformOrigin?: PopoverOrigin;
|
130 | /**
|
131 | * The component used for the transition.
|
132 | * [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
|
133 | */
|
134 | TransitionComponent?: React.ComponentType<
|
135 | TransitionProps & { children?: React.ReactElement<any, any> }
|
136 | >;
|
137 | /**
|
138 | * Set to 'auto' to automatically calculate transition time based on height.
|
139 | */
|
140 | transitionDuration?: TransitionProps['timeout'] | 'auto';
|
141 | /**
|
142 | * Props applied to the [`Transition`](http:
|
143 | */
|
144 | TransitionProps?: TransitionProps;
|
145 | }
|
146 |
|
147 | export type PopoverClassKey = 'root' | 'paper';
|
148 |
|
149 | export interface PopoverActions {
|
150 | updatePosition(): void;
|
151 | }
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 | export default function Popover(props: PopoverProps): JSX.Element;
|
166 |
|
\ | No newline at end of file |