1 | /**
|
2 | * @fileoverview This is the next version of <Portal>, reimplemented as a function component.
|
3 | *
|
4 | * It supports both the newer React context API and the legacy context API. Support for the legacy context API
|
5 | * will be removed in Blueprint v6.0.
|
6 | *
|
7 | * Portal2 is not currently used anywhere in Blueprint. We had to revert the change which updated the standard
|
8 | * <Portal> to use this implementation because of subtle breaks caused by interactions with the (long-deprecated)
|
9 | * react-hot-loader library. To be safe, we've left Portal as a class component for now, and will promote this Portal2
|
10 | * implementation to be the standard Portal in Blueprint v5.0.
|
11 | *
|
12 | * @see https://github.com/palantir/blueprint/issues/5511
|
13 | */
|
14 | import * as React from "react";
|
15 | import { ValidationMap } from "../../common/context";
|
16 | import { Props } from "../../common/props";
|
17 | import type { PortalLegacyContext } from "./portal";
|
18 | export interface Portal2Props extends Props {
|
19 | /** Contents to send through the portal. */
|
20 | children: React.ReactNode;
|
21 | /**
|
22 | * Callback invoked when the children of this `Portal` have been added to the DOM.
|
23 | */
|
24 | onChildrenMount?: () => void;
|
25 | /**
|
26 | * The HTML element that children will be mounted to.
|
27 | *
|
28 | * @default document.body
|
29 | */
|
30 | container?: HTMLElement;
|
31 | }
|
32 | /**
|
33 | * Portal (v2) component.
|
34 | *
|
35 | * This component detaches its contents and re-attaches them to document.body.
|
36 | * Use it when you need to circumvent DOM z-stacking (for dialogs, popovers, etc.).
|
37 | * Any class names passed to this element will be propagated to the new container element on document.body.
|
38 | */
|
39 | export declare function Portal2(props: Portal2Props, legacyContext?: PortalLegacyContext): React.ReactPortal | null;
|
40 | export declare namespace Portal2 {
|
41 | var defaultProps: {
|
42 | container: HTMLElement | undefined;
|
43 | };
|
44 | var displayName: string;
|
45 | var contextTypes: ValidationMap<PortalLegacyContext>;
|
46 | }
|