export class Field { public static defaultsEmail = { required : true , } ; public static defaultsPassword = { placeholder : '********' , required : true , minLength : 8 , } ; param type param templateType param key param options public static field ( type , templateType , key , options = { } ) { const hideExpression = options . hideExpression || false ; const expressionProperties = options . expressionProperties || false ; const className = options . className || false ; const templateOptions = { type : templateType , } ; const validators = { validation : options . validators || [ ] } ; const validation = options . validation || { } ; const toKeys = [ 'id' , 'name' , 'label' , 'placeholder' , 'description' , 'labelClasses' , 'fieldClasses' , 'readonly' , 'disabled' , 'required' , 'options' , 'min' , 'max' , 'minLength' , 'pattern' , 'multiple' , 'groupProp' , 'valueProp' , 'labelProp' , ] ; toKeys . forEach ( toKey => { if ( options [ toKey ] ) { templateOptions [ toKey ] = options [ toKey ] ; } } ) ; return { key , type , templateOptions , validators , validation , hideExpression , expressionProperties , className , } ; } public static input ( key , options = { } ) { return Field . field ( 'input' , 'text' , key , options ) ; } public static inputHorizontal ( key , options = { } ) { return Field . field ( 'inputHorizontal' , 'text' , key , options ) ; } public static email ( key , options = { } ) { return Field . field ( 'input' , 'email' , key , Object . assign ( { } , Field . defaultsEmail , options ) ) ; } public static emailHorizontal ( key , options = { } ) { return Field . field ( 'inputHorizontal' , 'email' , key , Object . assign ( { } , Field . defaultsEmail , options ) ) ; } public static range ( key , options = { } ) { return Field . field ( 'range' , 'range' , key , options ) ; } public static password ( key , options = { } ) { return Field . field ( 'input' , 'password' , key , Object . assign ( { } , Field . defaultsPassword , options ) ) ; } public static passwordHorizontal ( key , options = { } ) { return Field . field ( 'inputHorizontal' , 'password' , key , Object . assign ( { } , Field . defaultsPassword , options ) ) ; } public static date ( key , options = { } ) { return Field . field ( 'input' , 'date' , key , options ) ; } public static datetime ( key , options = { } ) { return Field . field ( 'datetime' , 'datetime' , key , options ) ; } public static radio ( key , options = { } ) { return Field . field ( 'radio' , 'radio' , key , options ) ; } public static textarea ( key , options = { } ) { return Field . field ( 'textarea' , 'text' , key , options ) ; } public static select ( key , options = { } ) { return Field . field ( 'select' , 'text' , key , options ) ; } public static multicheckbox ( key , options = { } ) { return Field . field ( 'multicheckbox' , 'multicheckbox' , key , options ) ; } public static checkbox ( key , options = { } ) { return Field . field ( 'checkbox' , 'checkbox' , key , options ) ; } public static group ( fields = [ ] , groupClassName = '' ) { return { fieldGroupClassName : groupClassName ? groupClassName : null , fieldGroup : fields , } ; } public static template ( template ) { return { template } ; } }