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';
export declare class CheckboxGroup extends AntdComponent {
$props: AntdProps & {
$props: Omit<AntdProps, 'onChange'> & {
/**
* Default selected value
* @type string[]
@ -30,13 +30,13 @@ export declare class CheckboxGroup extends AntdComponent {
* Used for setting the currently selected value.
* @type string[]
*/
value: string[];
value?: string[];
name?: string;
/**
* 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 { 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 {
static Group: typeof CheckboxGroup;
$props: AntdProps & {
/**
* get focus when component mounted
* @default false
* @type boolean
*/
autofocus?: boolean;
$props: Omit<AntdProps, 'onChange'> &
CheckboxProps & {
/**
* indeterminate checked state of checkbox
* @default false
* @type boolean
*/
indeterminate?: boolean;
/**
* Specifies whether the checkbox is selected.
* @default false
* @type boolean
*/
checked?: boolean;
/**
* remove focus
*/
onBlur?: (e: FocusEvent) => void;
/**
* Specifies the initial state: whether or not the checkbox is selected.
* @default false
* @type boolean
*/
defaultChecked?: boolean;
/**
* get focus
*/
onFocus?: (e: FocusEvent) => void;
/**
* Disable checkbox
* @default false
* @type boolean
*/
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;
};
/**
* The callback function that is triggered when the state changes.
* @param event
*/
onChange?: (e: CheckboxChangeEvent) => void;
};
}