mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-01 11:39:28 +08:00
Merge pull request #25776 from jsonunger/master
Create definitions for react-radio-group
This commit is contained in:
22
types/react-radio-group/index.d.ts
vendored
Normal file
22
types/react-radio-group/index.d.ts
vendored
Normal 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>;
|
||||
25
types/react-radio-group/react-radio-group-tests.tsx
Normal file
25
types/react-radio-group/react-radio-group-tests.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
}
|
||||
25
types/react-radio-group/tsconfig.json
Normal file
25
types/react-radio-group/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/react-radio-group/tslint.json
Normal file
1
types/react-radio-group/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user