import React from 'react' ; import FormControl from '@material-ui/core/FormControl' ; import TextField from '@material-ui/core/TextField' ; import { WidgetProps } from 'react-jsonschema-form' ; const EmailWidget = ( { id , required , readonly , disabled , label , value , onChange , onBlur , onFocus , autofocus , options , schema , } ) => { const _onChange = ( { target : { value } , } ) => onChange ( value === '' ? options . emptyValue : value ) ; const _onBlur = ( { target : { value } } ) => onBlur ( id , value ) ; const _onFocus = ( { target : { value } , } ) => onFocus ( id , value ) ; return ( < FormControl fullWidth = { true } required = { required } > < TextField id = { id } label = { label || schema . title } autoFocus = { autofocus } required = { required } disabled = { disabled || readonly } type = "email" value = { value ? value : '' } onChange = { _onChange } onBlur = { _onBlur } onFocus = { _onFocus } / > < /FormControl>); } ; export default EmailWidget ;