import { Actions , DisableAction } from '../../actions' ; import { computeGroupState , FormGroupState , KeyValue } from '../../state' ; import { childReducer , dispatchActionPerChild } from './util' ; export function disableReducer < TValue extends KeyValue > ( state , action ) { if ( action . type !== DisableAction . TYPE ) { return state ; } if ( action . controlId !== state . id ) { return childReducer ( state , action ) ; } if ( state . isDisabled ) { return state ; } return computeGroupState ( state . id , dispatchActionPerChild ( state . controls , controlId => new DisableAction ( controlId ) ) , state . value , { } , [ ] , state . userDefinedProperties , { wasOrShouldBeDirty : state . isDirty , wasOrShouldBeEnabled : false , wasOrShouldBeTouched : state . isTouched , wasOrShouldBeSubmitted : state . isSubmitted , } ) ; }