UNPKG

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