Merge pull request #25776 from jsonunger/master

Create definitions for react-radio-group
This commit is contained in:
Ron Buckton
2018-05-15 09:40:17 -07:00
committed by GitHub
4 changed files with 73 additions and 0 deletions

22
types/react-radio-group/index.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
// Type definitions for react-radio-group 3.0
// Project: https://github.com/chenglou/react-radio-group
// Definitions by: Jason Unger <https://github.com/jsonunger>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from 'react';
export namespace Radio {
type RadioProps = React.InputHTMLAttributes<HTMLInputElement>;
}
export const Radio: React.ComponentClass<Radio.RadioProps>;
export namespace RadioGroup {
interface RadioGroupProps {
name?: string;
selectedValue?: React.InputHTMLAttributes<HTMLInputElement>['value'];
onChange?: (value: React.InputHTMLAttributes<HTMLInputElement>['value']) => void;
Component?: string | React.ReactElement<React.HTMLProps<HTMLElement>>;
}
}
export const RadioGroup: React.ComponentClass<RadioGroup.RadioGroupProps>;

View File

@@ -0,0 +1,25 @@
import * as React from 'react';
import { Radio, RadioGroup } from "react-radio-group";
class ReactRadioGroup extends React.Component<RadioGroup.RadioGroupProps, { selectedValue: React.InputHTMLAttributes<HTMLInputElement>['value'] }> {
state = {
selectedValue: 2,
};
handleChange: RadioGroup.RadioGroupProps['onChange'] = selectedValue => {
console.log(selectedValue);
this.setState({ selectedValue });
}
render() {
return (
<div>
<RadioGroup name="radioGroup" onChange={this.handleChange} selectedValue={this.state.selectedValue}>
<Radio id="Option A" value="a" />
<Radio id="Option B" value={2} />
<Radio id="Option C" value={["hello"]} disabled />
</RadioGroup>
</div>
);
}
}

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"react-radio-group-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }