Skip to content

Commit 0367f3e

Browse files
authored
fix(types): checkbox and checkbox-group props types (#2882)
1 parent f942d5b commit 0367f3e

File tree

2 files changed

+74
-56
lines changed

2 files changed

+74
-56
lines changed

types/checkbox/checkbox-group.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { AntdComponent, AntdProps } from '../component';
66
export declare class CheckboxGroup extends AntdComponent {
7-
$props: AntdProps & {
7+
$props: Omit<AntdProps, 'onChange'> & {
88
/**
99
* Default selected value
1010
* @type string[]
@@ -30,13 +30,13 @@ export declare class CheckboxGroup extends AntdComponent {
3030
* Used for setting the currently selected value.
3131
* @type string[]
3232
*/
33-
value: string[];
33+
value?: string[];
3434
name?: string;
3535

3636
/**
3737
* The callback function that is triggered when the state changes.
38-
* @param e
38+
* @param {string[]} checkedValue
3939
*/
40-
onChange?: (checkedValue?: any) => void;
40+
onChange?: (checkedValue?: string[]) => void;
4141
};
4242
}

types/checkbox/checkbox.d.ts

+70-52
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,77 @@
55
import { CheckboxGroup } from './checkbox-group';
66
import { AntdComponent, AntdProps } from '../component';
77

8+
export interface CheckboxChangeEvent {
9+
target: CheckboxProps & { checked: boolean };
10+
stopPropagation: () => void;
11+
preventDefault: () => void;
12+
nativeEvent: MouseEvent;
13+
}
14+
15+
export interface CheckboxProps {
16+
prefixCls?: string;
17+
name?: string;
18+
id?: string;
19+
type?: string;
20+
21+
/**
22+
* Specifies the initial state: whether or not the checkbox is selected.
23+
* @default false
24+
* @type boolean
25+
*/
26+
defaultChecked?: boolean;
27+
28+
/**
29+
* Specifies whether the checkbox is selected.
30+
* @default false
31+
* @type boolean
32+
*/
33+
checked?: boolean;
34+
35+
/**
36+
* Disable checkbox
37+
* @default false
38+
* @type boolean
39+
*/
40+
disabled?: boolean;
41+
tabindex?: string | number;
42+
readonly?: boolean;
43+
44+
/**
45+
* get focus when component mounted
46+
* @default false
47+
* @type boolean
48+
*/
49+
autofocus?: boolean;
50+
value?: any;
51+
}
52+
853
export declare class Checkbox extends AntdComponent {
954
static Group: typeof CheckboxGroup;
1055

11-
$props: AntdProps & {
12-
/**
13-
* get focus when component mounted
14-
* @default false
15-
* @type boolean
16-
*/
17-
autofocus?: boolean;
18-
19-
/**
20-
* Specifies whether the checkbox is selected.
21-
* @default false
22-
* @type boolean
23-
*/
24-
checked?: boolean;
25-
26-
/**
27-
* Specifies the initial state: whether or not the checkbox is selected.
28-
* @default false
29-
* @type boolean
30-
*/
31-
defaultChecked?: boolean;
32-
33-
/**
34-
* Disable checkbox
35-
* @default false
36-
* @type boolean
37-
*/
38-
disabled?: boolean;
39-
40-
/**
41-
* indeterminate checked state of checkbox
42-
* @default false
43-
* @type boolean
44-
*/
45-
indeterminate?: boolean;
46-
47-
/**
48-
* remove focus
49-
*/
50-
blur(): void;
51-
52-
/**
53-
* get focus
54-
*/
55-
focus(): void;
56-
57-
/**
58-
* The callback function that is triggered when the state changes.
59-
* @param event
60-
*/
61-
onChange?: (e?: Event) => void;
62-
};
56+
$props: Omit<AntdProps, 'onChange'> &
57+
CheckboxProps & {
58+
/**
59+
* indeterminate checked state of checkbox
60+
* @default false
61+
* @type boolean
62+
*/
63+
indeterminate?: boolean;
64+
65+
/**
66+
* remove focus
67+
*/
68+
onBlur?: (e: FocusEvent) => void;
69+
70+
/**
71+
* get focus
72+
*/
73+
onFocus?: (e: FocusEvent) => void;
74+
75+
/**
76+
* The callback function that is triggered when the state changes.
77+
* @param event
78+
*/
79+
onChange?: (e: CheckboxChangeEvent) => void;
80+
};
6381
}

0 commit comments

Comments
 (0)