fix onChange definition toggle button group

This commit is contained in:
Duong Tran
2018-08-27 11:54:01 +10:00
parent 476d4012bd
commit 085789a0e1
2 changed files with 42 additions and 31 deletions
+28 -29
View File
@@ -3,37 +3,36 @@ import { ButtonGroup } from 'react-bootstrap';
import { Omit } from "../index";
declare namespace ToggleButtonGroup {
interface BaseProps {
/**
* You'll usually want to use string|number|string[]|number[] here,
* but you can technically use any|any[].
*/
defaultValue?: any;
/**
* You'll usually want to use string|number|string[]|number[] here,
* but you can technically use any|any[].
*/
value?: any;
}
interface BaseProps {
/**
* You'll usually want to use string|number|string[]|number[] here,
* but you can technically use any|any[].
*/
defaultValue?: any;
/**
* You'll usually want to use string|number|string[]|number[] here,
* but you can technically use any|any[].
*/
value?: any;
}
interface RadioProps {
/** Required if `type` is set to "radio" */
name: string;
type: "radio";
onChange?(value: any): void;
}
interface RadioProps {
/** Required if `type` is set to "radio" */
name: string;
type: "radio";
onChange?(value: any): void;
}
interface CheckboxProps {
name?: string;
type: "checkbox";
onChange?(values: any[]): void;
}
export type ToggleButtonGroupProps = BaseProps
& (RadioProps | CheckboxProps)
& Omit<React.HTMLProps<ToggleButtonGroup>, "defaultValue" | "type" | "value">
& Omit<React.HTMLProps<ToggleButtonGroup>, "defaultValue" | "type" | "value" | "onChange">;
interface CheckboxProps {
name?: string;
type: "checkbox";
onChange?(values: any[]): void;
}
export type ToggleButtonGroupProps = BaseProps
& (RadioProps | CheckboxProps)
& Omit<ButtonGroup.ButtonGroupProps, "onChange">
& Omit<React.HTMLProps<ToggleButtonGroup>, "defaultValue" | "type" | "value" | "onChange">;
}
declare class ToggleButtonGroup extends React.Component<ToggleButtonGroup.ToggleButtonGroupProps & ButtonGroup.ButtonGroupProps> { }
declare class ToggleButtonGroup extends React.Component<ToggleButtonGroup.ToggleButtonGroupProps> { }
export = ToggleButtonGroup;
@@ -210,8 +210,20 @@ export class ReactBootstrapIndividualComponentsTest extends React.Component {
<Tabs />
<Thumbnail />
<ToggleButton value="foo" bsSize="small" />
<ToggleButtonGroup type="checkbox" bsSize="small" />
<ToggleButtonGroup type="radio" name="foo" />
<ToggleButtonGroup
type="checkbox"
bsSize="small"
defaultValue={[1]}
value={[1, 2]}
onChange={(value: number[]) => { }}
/>
<ToggleButtonGroup
type="radio"
name="foo"
defaultValue={1}
value={1}
onChange={(value: number) => { }}
/>
<Tooltip />
<Well />
</div>