mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-24 13:59:25 +08:00
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.3
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
export type Value = React.InputHTMLAttributes<HTMLInputElement>['value'];
|
||||
|
||||
export type RadioProps = React.InputHTMLAttributes<HTMLInputElement>;
|
||||
|
||||
export const Radio: React.ComponentClass<RadioProps>;
|
||||
|
||||
export interface RadioGroupProps {
|
||||
name?: string;
|
||||
selectedValue?: Value;
|
||||
onChange?: (value: Value) => void;
|
||||
Component?: string | React.ReactElement<React.HTMLProps<HTMLElement>>;
|
||||
}
|
||||
|
||||
export const RadioGroup: React.ComponentClass<RadioGroupProps>;
|
||||
24
types/react-radio-group/react-radio-group-tests.tsx
Normal file
24
types/react-radio-group/react-radio-group-tests.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as React from 'react';
|
||||
import { Radio, RadioGroup, RadioGroupProps, Value } from "react-radio-group";
|
||||
|
||||
class ReactRadioGroup extends React.Component<RadioGroupProps> {
|
||||
constructor(props: RadioGroupProps) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
handleChange(value: Value) {
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<RadioGroup name="radioGroup" onChange={this.handleChange} selectedValue={2}>
|
||||
<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