@@ -5,8 +5,8 @@ import { useFormControl } from './helpers/useFormControl';
5
5
import { booleanOrFunction } from './helpers/form-helpers' ;
6
6
import { FormGroup } from './FormGroup' ;
7
7
8
- export function FormCheckbox ( { id, name, required : _required , valueLabel, disabled : _disabled } ) {
9
- const { getValue, handleOnChange , register, getFormData } = useFormControl ( name , 'boolean' ) ;
8
+ export function FormCheckbox ( { id, name, required : _required , valueLabel, disabled : _disabled , afterChange } ) {
9
+ const { getValue, handleOnChangeFactory , register, getFormData } = useFormControl ( name , 'boolean' ) ;
10
10
const registerRef = useCallback ( register , [ register ] ) ;
11
11
const disabled = booleanOrFunction ( _disabled , getFormData ( ) ) ;
12
12
const required = booleanOrFunction ( _required , getFormData ( ) ) ;
@@ -17,7 +17,7 @@ export function FormCheckbox({ id, name, required: _required, valueLabel, disabl
17
17
{ ...{ required, name, id, disabled } }
18
18
type = "checkbox"
19
19
className = "custom-control-input"
20
- onChange = { handleOnChange }
20
+ onChange = { handleOnChangeFactory ( afterChange ) }
21
21
checked = { getValue ( ) }
22
22
ref = { registerRef }
23
23
/>
@@ -29,11 +29,12 @@ export function FormCheckbox({ id, name, required: _required, valueLabel, disabl
29
29
}
30
30
31
31
FormCheckbox . propTypes = {
32
+ afterChange : PropTypes . func ,
33
+ disabled : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . func ] ) ,
32
34
id : PropTypes . string . isRequired ,
33
35
name : PropTypes . string . isRequired ,
34
- valueLabel : PropTypes . node ,
35
36
required : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . func ] ) ,
36
- disabled : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . func ] ) ,
37
+ valueLabel : PropTypes . node ,
37
38
} ;
38
39
39
40
export function FormGroupCheckbox ( props ) {
@@ -45,6 +46,7 @@ export function FormGroupCheckbox(props) {
45
46
}
46
47
47
48
FormGroupCheckbox . propTypes = {
49
+ afterChange : PropTypes . func ,
48
50
disabled : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . func ] ) ,
49
51
falseLabel : PropTypes . node ,
50
52
help : PropTypes . node ,
0 commit comments