import React , { Component } from 'react' ; import { emailRegex } from '../lib/email' ; const t = require ( '@brandingbrand/tcomb-form-native' ) ; import { SingleLineForm } from './SingleLineForm' ; import { FormLabelPosition } from './Form' ; import FSI18n , { translationKeys } from '@brandingbrand/fsi18n' ; const componentTranslationKeys = translationKeys . flagship . emailForm ; export interface EmailFormValue { email : string ; } export interface EmailFormProps { fieldsStyleConfig ? : any ; labelPosition ? : FormLabelPosition ; onSubmit ? : ( value : EmailFormValue ) => void ; submitButtonStyle ? : any ; submitTextStyle ? : any ; submitText ? : any ; value ? : EmailFormValue ; style ? : any ; fieldsOptions ? : any ; } const EmailType = t . refinement ( t . String , ( str ) => { return emailRegex . test ( ( str || '' ) . trim ( ) ) ; } ) ; export class EmailForm extends Component < EmailFormProps > { fieldsTypes : any ; fieldsOptions : any ; labelPosition : FormLabelPosition ; constructor ( props ) { super ( props ) ; this . fieldsTypes = t . struct ( { email : EmailType } ) ; this . fieldsOptions = { email : { placeholder : FSI18n . string ( componentTranslationKeys . placeholder ) , returnKeyType : 'next' , autoCorrect : false , autoCapitalize : 'none' , keyboardType : 'email-address' , error : FSI18n . string ( componentTranslationKeys . error ) } , ... props . fieldsOptions } ; this . labelPosition = ( typeof props . labelPosition === 'number' ) ? props . labelPosition : FormLabelPosition . Inline ; } componentDidMount ( ) { console . warn ( 'EmailForm is deprecated and will be removed in the next version of Flagship.' ) ; } render ( ) { return ( < SingleLineForm { ... this . props } fieldsTypes = { this . fieldsTypes } fieldsOptions = { this . fieldsOptions } labelPosition = { this . labelPosition } / > ) ; } }