From 0367f3e57e8d90fef16ad864982c9734fe2022ba Mon Sep 17 00:00:00 2001 From: John60676 Date: Wed, 23 Sep 2020 10:34:55 +0800 Subject: [PATCH] fix(types): checkbox and checkbox-group props types (#2882) --- types/checkbox/checkbox-group.d.ts | 8 +- types/checkbox/checkbox.d.ts | 116 +++++++++++++++++------------ 2 files changed, 71 insertions(+), 53 deletions(-) diff --git a/types/checkbox/checkbox-group.d.ts b/types/checkbox/checkbox-group.d.ts index c1f6950dc..aacab5f27 100644 --- a/types/checkbox/checkbox-group.d.ts +++ b/types/checkbox/checkbox-group.d.ts @@ -4,7 +4,7 @@ import { AntdComponent, AntdProps } from '../component'; export declare class CheckboxGroup extends AntdComponent { - $props: AntdProps & { + $props: Omit & { /** * 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; }; } diff --git a/types/checkbox/checkbox.d.ts b/types/checkbox/checkbox.d.ts index 676c16f95..f540edddf 100644 --- a/types/checkbox/checkbox.d.ts +++ b/types/checkbox/checkbox.d.ts @@ -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 & + 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; + }; }