import React from 'react' ; import Checkbox from '@material-ui/core/Checkbox' ; import FormControl from '@material-ui/core/FormControl' ; import FormControlLabel from '@material-ui/core/FormControlLabel' ; import { WidgetProps } from 'react-jsonschema-form' ; const CheckboxWidget = ( props ) => { const { id , value , required , disabled , readonly , label , autofocus , onChange , onBlur , onFocus , } = props ; const _onChange = ( { } , checked ) => onChange ( checked ) ; const _onBlur = ( { target : { value } , } ) => onBlur ( id , value ) ; const _onFocus = ( { target : { value } , } ) => onFocus ( id , value ) ; return ( < FormControl fullWidth = { true } required = { required } > < FormControlLabel control = { < Checkbox id = { id } checked = { typeof value === 'undefined' ? false : value } required = { required } disabled = { disabled || readonly } autoFocus = { autofocus } onChange = { _onChange } onBlur = { _onBlur } onFocus = { _onFocus } / > } label = { label } / > < /FormControl>); } ; export default CheckboxWidget ;