fix(types): checkbox and checkbox-group props types (#2882)

pull/2900/head
John60676 2020-09-23 10:34:55 +08:00 committed by GitHub
parent f942d5b1a6
commit 0367f3e57e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 53 deletions

View File

@ -4,7 +4,7 @@
import { AntdComponent, AntdProps } from '../component'; import { AntdComponent, AntdProps } from '../component';
export declare class CheckboxGroup extends AntdComponent { export declare class CheckboxGroup extends AntdComponent {
$props: AntdProps & { $props: Omit<AntdProps, 'onChange'> & {
/** /**
* Default selected value * Default selected value
* @type string[] * @type string[]
@ -30,13 +30,13 @@ export declare class CheckboxGroup extends AntdComponent {
* Used for setting the currently selected value. * Used for setting the currently selected value.
* @type string[] * @type string[]
*/ */
value: string[]; value?: string[];
name?: string; name?: string;
/** /**
* The callback function that is triggered when the state changes. * The callback function that is triggered when the state changes.
* @param e * @param {string[]} checkedValue
*/ */
onChange?: (checkedValue?: any) => void; onChange?: (checkedValue?: string[]) => void;
}; };
} }

View File

@ -5,23 +5,18 @@
import { CheckboxGroup } from './checkbox-group'; import { CheckboxGroup } from './checkbox-group';
import { AntdComponent, AntdProps } from '../component'; import { AntdComponent, AntdProps } from '../component';
export declare class Checkbox extends AntdComponent { export interface CheckboxChangeEvent {
static Group: typeof CheckboxGroup; target: CheckboxProps & { checked: boolean };
stopPropagation: () => void;
preventDefault: () => void;
nativeEvent: MouseEvent;
}
$props: AntdProps & { export interface CheckboxProps {
/** prefixCls?: string;
* get focus when component mounted name?: string;
* @default false id?: string;
* @type boolean type?: string;
*/
autofocus?: boolean;
/**
* Specifies whether the checkbox is selected.
* @default false
* @type boolean
*/
checked?: boolean;
/** /**
* Specifies the initial state: whether or not the checkbox is selected. * Specifies the initial state: whether or not the checkbox is selected.
@ -30,13 +25,36 @@ export declare class Checkbox extends AntdComponent {
*/ */
defaultChecked?: boolean; defaultChecked?: boolean;
/**
* Specifies whether the checkbox is selected.
* @default false
* @type boolean
*/
checked?: boolean;
/** /**
* Disable checkbox * Disable checkbox
* @default false * @default false
* @type boolean * @type boolean
*/ */
disabled?: boolean; disabled?: boolean;
tabindex?: string | number;
readonly?: boolean;
/**
* get focus when component mounted
* @default false
* @type boolean
*/
autofocus?: boolean;
value?: any;
}
export declare class Checkbox extends AntdComponent {
static Group: typeof CheckboxGroup;
$props: Omit<AntdProps, 'onChange'> &
CheckboxProps & {
/** /**
* indeterminate checked state of checkbox * indeterminate checked state of checkbox
* @default false * @default false
@ -47,17 +65,17 @@ export declare class Checkbox extends AntdComponent {
/** /**
* remove focus * remove focus
*/ */
blur(): void; onBlur?: (e: FocusEvent) => void;
/** /**
* get focus * get focus
*/ */
focus(): void; onFocus?: (e: FocusEvent) => void;
/** /**
* The callback function that is triggered when the state changes. * The callback function that is triggered when the state changes.
* @param event * @param event
*/ */
onChange?: (e?: Event) => void; onChange?: (e: CheckboxChangeEvent) => void;
}; };
} }