UNPKG

3.14 kBTypeScriptView Raw
1import * as React from 'react';
2import PopperJs, { ReferenceObject } from 'popper.js';
3import { Omit } from '..';
4import { PortalProps } from '../Portal';
5
6export type PopperPlacementType =
7 | 'bottom-end'
8 | 'bottom-start'
9 | 'bottom'
10 | 'left-end'
11 | 'left-start'
12 | 'left'
13 | 'right-end'
14 | 'right-start'
15 | 'right'
16 | 'top-end'
17 | 'top-start'
18 | 'top';
19
20export interface PopperProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
21 ref?: React.Ref<HTMLDivElement>;
22 /**
23 * A HTML element, [referenceObject](https://popper.js.org/docs/v1/#referenceObject),
24 * or a function that returns either.
25 * It's used to set the position of the popper.
26 * The return value will passed as the reference object of the Popper instance.
27 */
28 anchorEl?: null | ReferenceObject | (() => ReferenceObject);
29 /**
30 * Popper render function or node.
31 */
32 children:
33 | React.ReactNode
34 | ((props: {
35 placement: PopperPlacementType;
36 TransitionProps?: {
37 in: boolean;
38 onEnter: () => {};
39 onExited: () => {};
40 };
41 }) => React.ReactNode);
42 /**
43 * A HTML element, component instance, or function that returns either.
44 * The `container` will have the portal children appended to it.
45 *
46 * By default, it uses the body of the top-level document object,
47 * so it's simply `document.body` most of the time.
48 */
49 container?: PortalProps['container'];
50 /**
51 * Disable the portal behavior.
52 * The children stay within it's parent DOM hierarchy.
53 */
54 disablePortal?: PortalProps['disablePortal'];
55 /**
56 * Always keep the children in the DOM.
57 * This prop can be useful in SEO situation or
58 * when you want to maximize the responsiveness of the Popper.
59 */
60 keepMounted?: boolean;
61 /**
62 * Popper.js is based on a "plugin-like" architecture,
63 * most of its features are fully encapsulated "modifiers".
64 *
65 * A modifier is a function that is called each time Popper.js needs to
66 * compute the position of the popper.
67 * For this reason, modifiers should be very performant to avoid bottlenecks.
68 * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v1/#modifiers).
69 */
70 modifiers?: object;
71 /**
72 * If `true`, the popper is visible.
73 */
74 open: boolean;
75 /**
76 * Popper placement.
77 */
78 placement?: PopperPlacementType;
79 /**
80 * Options provided to the [`popper.js`](https://popper.js.org/docs/v1/) instance.
81 */
82 popperOptions?: object;
83 /**
84 * A ref that points to the used popper instance.
85 */
86 popperRef?: React.Ref<PopperJs>;
87 /**
88 * Help supporting a react-transition-group/Transition component.
89 */
90 transition?: boolean;
91}
92
93/**
94 * Poppers rely on the 3rd party library [Popper.js](https://popper.js.org/docs/v1/) for positioning.
95 * Demos:
96 *
97 * - [Autocomplete](https://mui.com/components/autocomplete/)
98 * - [Menus](https://mui.com/components/menus/)
99 * - [Popper](https://mui.com/components/popper/)
100 *
101 * API:
102 *
103 * - [Popper API](https://mui.com/api/popper/)
104 */
105export default function Popper(props: PopperProps): JSX.Element;
106
\No newline at end of file