Added types for react-click-outside (#22985)

This commit is contained in:
Christian Rackerseder
2018-01-17 10:11:10 -08:00
committed by Wesley Wigham
parent 91ad651732
commit b47a6d3d07
4 changed files with 67 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for react-click-outside 3.0
// Project: https://github.com/kentor/react-click-outside
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as React from "react";
declare function enhanceWithClickOutside<P = {}>(wrappedComponent: React.ComponentClass<P>): React.ComponentClass<P>;
declare namespace enhanceWithClickOutside { }
export = enhanceWithClickOutside;
@@ -0,0 +1,30 @@
import * as React from 'react';
import { render } from 'react-dom';
import * as enhanceWithClickOutside from 'react-click-outside';
interface Props {
text: string;
}
interface State {
isOpened: boolean;
}
class StatefulComponent extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { isOpened: true };
}
handleClickOutside() {
this.setState({ isOpened: false });
}
render() {
return <div>{this.props.text}</div>;
}
}
const ClickOutsideStatefulComponent = enhanceWithClickOutside(StatefulComponent);
render(<ClickOutsideStatefulComponent text="" />, document.getElementById('test'));
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-click-outside-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }