mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-25 16:11:24 +08:00
Merge pull request #14258 from shuntksh/react-portal
New definition for react-portal 3.0 npm module
This commit is contained in:
25
react-portal/index.d.ts
vendored
Normal file
25
react-portal/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for react-portal 3.0
|
||||
// Project: https://github.com/tajo/react-portal#readme
|
||||
// Definitions by: Shun Takahashi <https://github.com/shuntksh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
interface CallBackProps extends React.Props<any> {
|
||||
closePortal: () => {};
|
||||
}
|
||||
|
||||
interface ReactPortalProps {
|
||||
isOpened?: boolean;
|
||||
openByClickOn?: React.ReactElement<CallBackProps>;
|
||||
closeOnEsc?: boolean;
|
||||
closeOnOutsideClick?: boolean;
|
||||
onOpen?: (node: HTMLDivElement) => {};
|
||||
beforeClose?: (node: HTMLDivElement, resetPortalState: () => void) => {};
|
||||
onClose?: () => {};
|
||||
onUpdate?: () => {};
|
||||
}
|
||||
|
||||
declare const ReactPortal: React.ComponentClass<ReactPortalProps>;
|
||||
export = ReactPortal;
|
||||
34
react-portal/react-portal-tests.tsx
Normal file
34
react-portal/react-portal-tests.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
// Example from https://github.com/tajo/react-portal
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
import * as Portal from "react-portal";
|
||||
|
||||
export default class App extends React.Component<{}, {}> {
|
||||
|
||||
render() {
|
||||
const button1 = <button>Open portal with pseudo modal</button>;
|
||||
|
||||
return (
|
||||
<Portal closeOnEsc closeOnOutsideClick openByClickOn={button1}>
|
||||
<PseudoModal>
|
||||
<h2>Pseudo Modal</h2>
|
||||
<p>This react component is appended to the document body.</p>
|
||||
</PseudoModal>
|
||||
</Portal>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class PseudoModal extends React.Component<{ closePortal?: () => {} }, {}> {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.props.children}
|
||||
<p><button onClick={this.props.closePortal}>Close this</button></p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('react-body'));
|
||||
25
react-portal/tsconfig.json
Normal file
25
react-portal/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-portal-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
react-portal/tslint.json
Normal file
1
react-portal/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user