UNPKG

1.85 kBTypeScriptView Raw
1import * as React from 'react';
2import { PortalRef } from './Portal';
3import ScrollLocker from './Dom/scrollLocker';
4/** @private Test usage only */
5export declare function getOpenCount(): number;
6export type GetContainer = string | HTMLElement | (() => HTMLElement);
7export interface PortalWrapperProps {
8 visible?: boolean;
9 getContainer?: GetContainer;
10 wrapperClassName?: string;
11 forceRender?: boolean;
12 children: (info: {
13 getOpenCount: () => number;
14 getContainer: () => HTMLElement;
15 switchScrollingEffect: () => void;
16 scrollLocker: ScrollLocker;
17 ref?: (c: any) => void;
18 }) => React.ReactNode;
19}
20declare class PortalWrapper extends React.Component<PortalWrapperProps> {
21 container?: HTMLElement;
22 componentRef: React.RefObject<PortalRef>;
23 rafId?: number;
24 scrollLocker: ScrollLocker;
25 constructor(props: PortalWrapperProps);
26 renderComponent?: (info: {
27 afterClose: Function;
28 onClose: Function;
29 visible: boolean;
30 }) => void;
31 componentDidMount(): void;
32 componentDidUpdate(prevProps: PortalWrapperProps): void;
33 updateScrollLocker: (prevProps?: Partial<PortalWrapperProps>) => void;
34 updateOpenCount: (prevProps?: Partial<PortalWrapperProps>) => void;
35 componentWillUnmount(): void;
36 attachToParent: (force?: boolean) => boolean;
37 getContainer: () => HTMLElement;
38 setWrapperClassName: () => void;
39 removeCurrentContainer: () => void;
40 /**
41 * Enhance ./switchScrollingEffect
42 * 1. Simulate document body scroll bar with
43 * 2. Record body has overflow style and recover when all of PortalWrapper invisible
44 * 3. Disable body scroll when PortalWrapper has open
45 *
46 * @memberof PortalWrapper
47 */
48 switchScrollingEffect: () => void;
49 render(): any;
50}
51export default PortalWrapper;