forked from rmariuzzo/react-new-window
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes rmariuzzo#2. I noticed the `copyStyles` prop is missing in README.md, so added it in to match the TS typings.
- Loading branch information
Josh Goldberg
committed
Jan 19, 2018
1 parent
d2efc87
commit 68ff625
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
|
||
/** | ||
* Base features common to all window features. | ||
* | ||
* @remarks These will be concatenated into a string for window.open. | ||
*/ | ||
export interface IWindowFeatures { | ||
height: number | ||
width: number | ||
[i: string]: boolean | number | string | ||
} | ||
|
||
/** | ||
* Props for opening a new window. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/open | ||
*/ | ||
declare export interface INewWindowProps { | ||
/** | ||
* The URL to open, if specified any children will be overriden. | ||
*/ | ||
url?: string | ||
|
||
/** | ||
* The name of the window. | ||
*/ | ||
name?: string | ||
|
||
/** | ||
* The title of the new window document. | ||
*/ | ||
title?: string | ||
|
||
/** | ||
* The set of window features. | ||
*/ | ||
features?: IWindowFeatures | ||
|
||
/** | ||
* A function to be triggered before the new window unload. | ||
*/ | ||
onBlock?: IOnBlock | null | ||
|
||
/** | ||
* A function to be triggered when the new window could not be opened. | ||
*/ | ||
onUnload?: IOnUnload | null | ||
|
||
/** | ||
* Indicate how to center the new window. | ||
*/ | ||
center?: 'parent' | 'screen' | ||
|
||
/** | ||
* If specified, copy styles from parent window's document. | ||
*/ | ||
copyStyles?: boolean | ||
} | ||
|
||
declare export default class NewWindow extends React.PureComponent { | ||
private readonly container: HTMLDivElement | ||
private window: Window | null | ||
private windowCheckerInterval: number | null | ||
private released: boolean | ||
|
||
/** | ||
* Release the new window and anything that was bound to it. | ||
*/ | ||
public release(): void | ||
} |