react-popout
Version:
Wraps window.open in a react component, allowing the contents to be part of your react render tree
57 lines (56 loc) • 1.77 kB
TypeScript
import React, { PropsWithChildren } from 'react';
interface PopoutWindowProps extends PropsWithChildren<any> {
options: object;
url: string;
containerId: string;
containerClassName?: string;
onError: () => void;
window?: Window;
title?: string;
}
interface PopoutWindowState {
popoutWindow: Window | null;
container: HTMLDivElement | null;
openedWindowComponent: React.Component | null;
}
/**
* @class PopoutWindow
*/
export default class PopoutWindow extends React.Component<PopoutWindowProps, PopoutWindowState> {
private interval;
private root;
static defaultProps: {
url: string;
containerId: string;
containerClassName: string;
onError: () => void;
};
/**
* @constructs PopoutWindow
* @param props
*/
constructor(props: PopoutWindowProps);
createOptions(ownerWindow: Window): string;
componentDidMount(): void;
componentWillReceiveProps(newProps: PopoutWindowProps): void;
componentDidUpdate(): void;
componentWillUnmount(): void;
popoutWindowLoaded(popoutWindow: Window): void;
openPopoutWindow(ownerWindow: Window): void;
/**
* API method to close the window.
*/
closeWindow(): void;
/**
* Use if a URL was passed to the popout window. Checks every 500ms if the window has been closed.
* Calls the onClosing() prop if the window is closed.
*
* @param popoutWindow
*/
checkForPopoutWindowClosure(popoutWindow: Window): void;
mainWindowClosed(): void;
popoutWindowUnloading(): void;
renderToContainer(container: HTMLDivElement, popoutWindow: Window, children: React.ReactNode | ((window: Window) => React.ReactNode)): void;
render(): null;
}
export {};