export class EventFieldInfo { constructor ( public componentId , public fieldValue ) { } public static fromEvent ( componentId , event ) { const elem = event . target ; if ( elem instanceof Element ) { const fieldData = getFormFieldData ( elem ) ; if ( fieldData ) { return new EventFieldInfo ( componentId , fieldData . value ) ; } } return null ; } } function getFormFieldData ( elem ) { if ( elem instanceof HTMLInputElement ) { return ( elem . type && elem . type . toLowerCase ( ) === 'checkbox' ) ? { value : elem . checked } : { value : elem . value } ; } if ( elem instanceof HTMLSelectElement || elem instanceof HTMLTextAreaElement ) { return { value : elem . value } ; } return null ; }