mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
Add type definitions for airbnb/react-outside-click-handler (#29471)
* Add type definitions for react-outside-click-handler * Fix tests and fallback to TS 2.9 DT is not supporting typescript 3 yet, so can't properly use defaultProps
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for react-outside-click-handler 1.2
|
||||
// Project: https://github.com/airbnb/react-outside-click-handler
|
||||
// Definitions by: Ivan Zub <https://github.com/zubivan>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export interface DefaultProps {
|
||||
disabled: boolean;
|
||||
useCapture: boolean;
|
||||
display: "block" | "flex" | "inline-block";
|
||||
}
|
||||
|
||||
// TODO: Remove partial once DT support TS 3.0, so skipping mandatory listed in default props won't result in compile error
|
||||
export interface Props extends Partial<DefaultProps> {
|
||||
children: React.ReactNode;
|
||||
onOutsideClick: (e: React.MouseEvent<HTMLElement>) => void;
|
||||
}
|
||||
|
||||
export default class OutsideClickHandler extends React.Component<Props> {
|
||||
static defaultProps: DefaultProps;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import * as React from "react";
|
||||
|
||||
import OutsideClickHandler from "react-outside-click-handler";
|
||||
|
||||
const onClickOutside: (event: React.MouseEvent<any>) => void = () => {};
|
||||
|
||||
<OutsideClickHandler onOutsideClick={onClickOutside}>
|
||||
<span>Child</span>
|
||||
</OutsideClickHandler>;
|
||||
|
||||
<OutsideClickHandler onOutsideClick={onClickOutside} disabled={true}>
|
||||
<span>Child</span>
|
||||
</OutsideClickHandler>;
|
||||
|
||||
<OutsideClickHandler onOutsideClick={onClickOutside} display="block">
|
||||
<span>Child</span>
|
||||
</OutsideClickHandler>;
|
||||
|
||||
<OutsideClickHandler onOutsideClick={onClickOutside} useCapture={true}>
|
||||
<span>Child</span>
|
||||
</OutsideClickHandler>;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"jsx": "react",
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/react-outside-click-handler-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user