UNPKG

1.53 kBTypeScriptView Raw
1import * as React from "react";
2import { ValidationMap } from "../../common/context";
3import { Props } from "../../common/props";
4export declare type PortalProps = IPortalProps;
5export interface IPortalProps extends Props {
6 /**
7 * Callback invoked when the children of this `Portal` have been added to the DOM.
8 */
9 onChildrenMount?: () => void;
10 /**
11 * The HTML element that children will be mounted to.
12 *
13 * @default document.body
14 */
15 container?: HTMLElement;
16}
17export interface IPortalState {
18 hasMounted: boolean;
19}
20export interface IPortalContext {
21 /** Additional CSS classes to add to all `Portal` elements in this React context. */
22 blueprintPortalClassName?: string;
23}
24/**
25 * This component detaches its contents and re-attaches them to document.body.
26 * Use it when you need to circumvent DOM z-stacking (for dialogs, popovers, etc.).
27 * Any class names passed to this element will be propagated to the new container element on document.body.
28 */
29export declare class Portal extends React.Component<IPortalProps, IPortalState> {
30 static displayName: string;
31 static contextTypes: ValidationMap<IPortalContext>;
32 static defaultProps: IPortalProps;
33 context: IPortalContext;
34 state: IPortalState;
35 private portalElement;
36 render(): React.ReactPortal | null;
37 componentDidMount(): void;
38 componentDidUpdate(prevProps: IPortalProps): void;
39 componentWillUnmount(): void;
40 private createContainerElement;
41 private unstableRenderNoPortal;
42}