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