UNPKG

2.72 kBTypeScriptView Raw
1import * as React from "react";
2import PopperJs from "popper.js";
3import { PortalProps } from "../Portal";
4import { PseudoBoxProps } from "../PseudoBox";
5import { BoxProps } from "../Box";
6
7type RenderProps = {
8 placement?: PopperJs.Placement;
9 transitionProps?: object;
10};
11
12type PopperChildren =
13 | {
14 children: React.ReactNode;
15 }
16 | { children: (props: RenderProps) => React.ReactNode };
17
18export interface IPopper {
19 /**
20 * The reference element, or a function that returns the reference element,
21 * that will be used to set the placment of the popover.
22 *
23 * The reference element should be an HTML Element instance or a referenceObject:
24 * https://popper.js.org/popper-documentation.html#referenceObject.
25 */
26 anchorEl?: null | PopperJs.ReferenceObject | (() => PopperJs.ReferenceObject);
27 /**
28 * The container where the Popper should render.
29 * By default, the portal renders it's children as a child of `document.body>`
30 */
31 container?: PortalProps["container"];
32 /**
33 * If `true`, the Popper will display in a portal.
34 * [Learn more about portals](https://reactjs.org/docs/portals.html)
35 *
36 * @default true
37 */
38 usePortal?: boolean;
39 /**
40 * If `true`, the component will unmount when it closes
41 *
42 * @default true
43 */
44 unmountOnExit?: boolean;
45 /**
46 * This is used to configure how Popper.js computes the positioning of the popper.
47 *
48 * To ensure the modifiers you pass are performant, [learn how to create a modifier](https://github.com/FezVrasta/popper.js/blob/master/docs/_includes/popper-documentation.md#modifiers--object).
49 */
50 modifiers?: PopperJs.Modifiers;
51 /**
52 * If `true`, the popper will be opened in controlled mode
53 */
54 isOpen?: boolean;
55 /**
56 * The placement of the popper
57 */
58 placement?: PopperJs.Placement;
59 /**
60 * Options provided to the [`popper.js`](https://github.com/FezVrasta/popper.js) instance.
61 */
62 popperOptions?: object;
63 /**
64 * A ref that points to the used popper instance.
65 */
66 popperRef?: React.RefObject<PopperJs>;
67 /**
68 * 🚨 Experiemental: Don't use this prop for now.
69 * @ignore
70 */
71 willUseTransition?: boolean;
72 /**
73 * If `true` and the `PopoverArrow` isn't render, we'll remove the margin applied
74 * to the `PopoverContent`
75 */
76 hasArrow?: boolean;
77 /**
78 * The size of the arrow in pixels
79 * @default "1rem"
80 */
81 arrowSize?: string;
82 /**
83 * The color to apply to the `box-shadow` of the arrow.
84 * @default "rgba(0, 0, 0, 0.1)"
85 */
86 arrowShadowColor?: string;
87}
88
89export type PopperProps = IPopper & PseudoBoxProps & PopperChildren;
90
91declare const Popper: React.FC<PopperProps>;
92export default Popper;
93
94export const PopperArrow: React.FC<BoxProps>;
95
\No newline at end of file