mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Updates for react-toggle V2 types (#27552)
* Updates for react-toggle V2 types * Bump minimum TypeScript version * Fix contributor url formatting
This commit is contained in:
Vendored
+15
-11
@@ -1,20 +1,24 @@
|
||||
// Type definitions for react-toggle 2.2
|
||||
// Project: https://github.com/aaronshaf/react-toggle
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Jason Unger <https://github.com/jsonunger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
import { Component, HTMLAttributes, ReactNode } from "react";
|
||||
import { ComponentClass, InputHTMLAttributes, ReactNode } from "react";
|
||||
|
||||
export interface ToggleIcons {
|
||||
checked?: ReactNode;
|
||||
unchecked?: ReactNode;
|
||||
declare namespace Toggle {
|
||||
interface ToggleIcons {
|
||||
checked?: ReactNode;
|
||||
unchecked?: ReactNode;
|
||||
}
|
||||
|
||||
interface ToggleProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||
icons?: boolean | ToggleIcons;
|
||||
defaultChecked?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ToggleProps extends HTMLAttributes<any> {
|
||||
"aria-labelledby"?: string;
|
||||
"aria-label"?: string;
|
||||
icons?: boolean | ToggleIcons;
|
||||
}
|
||||
declare const Toggle: ComponentClass<Toggle.ToggleProps>;
|
||||
|
||||
export default class Toggle extends Component<ToggleProps> {}
|
||||
export = Toggle;
|
||||
|
||||
@@ -8,3 +8,15 @@ class Test extends React.Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestControlled extends React.Component<{}, {checked: boolean}> {
|
||||
state = {
|
||||
checked: false
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Toggle name="toggle" checked={this.state.checked} onChange={(e) => this.setState({ checked: e.target.checked })} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
"jsx": "react",
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-toggle-tests.tsx"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user