@@ -14,36 +14,33 @@ export type CheckboxInputProps =
1414
1515export const CheckboxInput : React . FC < CheckboxInputProps > = ( props ) => {
1616
17- const [ checked , setChecked ] = React . useState < CheckedState > ( props . initialValue ?? "indeterminate" ) ;
18-
1917 const {
2018 title,
2119 description,
2220 formValidation = {
2321 valid : true ,
2422 notValidMessage : null ,
25- setValue : ( value : CheckedState ) => {
26- } ,
23+ setValue : ( value : CheckedState ) => undefined ,
2724 } ,
2825 ...rest
2926 } = props
3027
28+ const [ checked , setChecked ] = React . useState < CheckedState > ( props . initialValue ?? "indeterminate" ) ;
29+
30+ React . useEffect ( ( ) => {
31+ formValidation . setValue ( checked )
32+ } , [ checked ] )
33+
3134 return < >
3235 { ! ! title ? < InputLabel children = { title } /> : null }
3336 { ! ! description ? < InputDescription children = { description } /> : null }
3437
35- < div { ...mergeCode0Props ( `input ${ ! formValidation ?. valid ? "input--not-valid" : "" } checkbox-input` , { } ) } >
38+ < div { ...mergeCode0Props ( `input ${ ! formValidation ?. valid ? "input--not-valid" : "" } checkbox-input` , { } ) } onClick = { ( ) => setChecked ( prevState => ! prevState ) } >
3639
37- < Checkbox defaultChecked = { checked } { ...mergeCode0Props ( "checkbox-input__button" , {
38- ...rest , onCheckedChange : ( value : CheckedState ) => {
39- if ( rest . onCheckedChange ) rest . onCheckedChange ! ! ( value )
40- setChecked ( value )
41- formValidation . setValue ( value )
42- }
43- } ) } >
40+ < Checkbox checked = { checked } defaultChecked = { checked } { ...mergeCode0Props ( "checkbox-input__button" , rest ) } >
4441 < CheckboxIndicator className = { "checkbox-input__indicator" } >
45- { checked === "indeterminate" && < IconMinus size = { 10 } /> }
46- { checked === true && < IconCheck size = { 10 } /> }
42+ { checked === "indeterminate" && < IconMinus size = { 16 } /> }
43+ { checked === true && < IconCheck size = { 16 } /> }
4744 </ CheckboxIndicator >
4845 </ Checkbox >
4946
0 commit comments