import { Action } from '@ngrx/store' ; import { KeyValue , NgrxFormControlId , ValidationErrors } from './state' ; export class SetValueAction < TValue > implements Action { static readonly TYPE : 'ngrx/forms/SET_VALUE' = 'ngrx/forms/SET_VALUE' ; readonly type = SetValueAction . TYPE ; constructor ( public readonly controlId , public readonly value ) { } } export class SetErrorsAction implements Action { static readonly TYPE : 'ngrx/forms/SET_ERRORS' = 'ngrx/forms/SET_ERRORS' ; readonly type = SetErrorsAction . TYPE ; constructor ( public readonly controlId , public readonly errors ) { } } export class SetAsyncErrorAction implements Action { static readonly TYPE : 'ngrx/forms/SET_ASYNC_ERROR' = 'ngrx/forms/SET_ASYNC_ERROR' ; readonly type = SetAsyncErrorAction . TYPE ; constructor ( public readonly controlId , public readonly name , public readonly value ) { } } export class ClearAsyncErrorAction implements Action { static readonly TYPE : 'ngrx/forms/CLEAR_ASYNC_ERROR' = 'ngrx/forms/CLEAR_ASYNC_ERROR' ; readonly type = ClearAsyncErrorAction . TYPE ; constructor ( public readonly controlId , public readonly name ) { } } export class StartAsyncValidationAction implements Action { static readonly TYPE : 'ngrx/forms/START_ASYNC_VALIDATION' = 'ngrx/forms/START_ASYNC_VALIDATION' ; readonly type = StartAsyncValidationAction . TYPE ; constructor ( public readonly controlId , public readonly name ) { } } export class MarkAsDirtyAction implements Action { static readonly TYPE : 'ngrx/forms/MARK_AS_DIRTY' = 'ngrx/forms/MARK_AS_DIRTY' ; readonly type = MarkAsDirtyAction . TYPE ; constructor ( public readonly controlId ) { } } export class MarkAsPristineAction implements Action { static readonly TYPE : 'ngrx/forms/MARK_AS_PRISTINE' = 'ngrx/forms/MARK_AS_PRISTINE' ; readonly type = MarkAsPristineAction . TYPE ; constructor ( public readonly controlId ) { } } export class EnableAction implements Action { static readonly TYPE : 'ngrx/forms/ENABLE' = 'ngrx/forms/ENABLE' ; readonly type = EnableAction . TYPE ; constructor ( public readonly controlId ) { } } export class DisableAction implements Action { static readonly TYPE : 'ngrx/forms/DISABLE' = 'ngrx/forms/DISABLE' ; readonly type = DisableAction . TYPE ; constructor ( public readonly controlId ) { } } export class MarkAsTouchedAction implements Action { static readonly TYPE : 'ngrx/forms/MARK_AS_TOUCHED' = 'ngrx/forms/MARK_AS_TOUCHED' ; readonly type = MarkAsTouchedAction . TYPE ; constructor ( public readonly controlId ) { } } export class MarkAsUntouchedAction implements Action { static readonly TYPE : 'ngrx/forms/MARK_AS_UNTOUCHED' = 'ngrx/forms/MARK_AS_UNTOUCHED' ; readonly type = MarkAsUntouchedAction . TYPE ; constructor ( public readonly controlId ) { } } export class FocusAction implements Action { static readonly TYPE : 'ngrx/forms/FOCUS' = 'ngrx/forms/FOCUS' ; readonly type = FocusAction . TYPE ; constructor ( public readonly controlId ) { } } export class UnfocusAction implements Action { static readonly TYPE : 'ngrx/forms/UNFOCUS' = 'ngrx/forms/UNFOCUS' ; readonly type = UnfocusAction . TYPE ; constructor ( public readonly controlId ) { } } export class MarkAsSubmittedAction implements Action { static readonly TYPE : 'ngrx/forms/MARK_AS_SUBMITTED' = 'ngrx/forms/MARK_AS_SUBMITTED' ; readonly type = MarkAsSubmittedAction . TYPE ; constructor ( public readonly controlId ) { } } export class MarkAsUnsubmittedAction implements Action { static readonly TYPE : 'ngrx/forms/MARK_AS_UNSUBMITTED' = 'ngrx/forms/MARK_AS_UNSUBMITTED' ; readonly type = MarkAsUnsubmittedAction . TYPE ; constructor ( public readonly controlId ) { } } export class AddArrayControlAction < TValue > implements Action { static readonly TYPE : 'ngrx/forms/ADD_ARRAY_CONTROL' = 'ngrx/forms/ADD_ARRAY_CONTROL' ; readonly type = AddArrayControlAction . TYPE ; constructor ( public readonly controlId , public readonly value , public readonly index ? ) { } } export class AddGroupControlAction < TValue extends KeyValue , TControlKey extends keyof TValue = keyof TValue > implements Action { static readonly TYPE : 'ngrx/forms/ADD_GROUP_CONTROL' = 'ngrx/forms/ADD_GROUP_CONTROL' ; readonly type = AddGroupControlAction . TYPE ; constructor ( public readonly controlId , public readonly name , public readonly value ) { } } export class RemoveArrayControlAction implements Action { static readonly TYPE : 'ngrx/forms/REMOVE_ARRAY_CONTROL' = 'ngrx/forms/REMOVE_ARRAY_CONTROL' ; readonly type = RemoveArrayControlAction . TYPE ; constructor ( public readonly controlId , public readonly index ) { } } export class SwapArrayControlAction implements Action { static readonly TYPE : 'ngrx/forms/SWAP_ARRAY_CONTROL' = 'ngrx/forms/SWAP_ARRAY_CONTROL' ; readonly type = SwapArrayControlAction . TYPE ; constructor ( public readonly controlId , public readonly fromIndex , public readonly toIndex ) { } } export class MoveArrayControlAction implements Action { static readonly TYPE : 'ngrx/forms/MOVE_ARRAY_CONTROL' = 'ngrx/forms/MOVE_ARRAY_CONTROL' ; readonly type = MoveArrayControlAction . TYPE ; constructor ( public readonly controlId , public readonly fromIndex , public readonly toIndex ) { } } export class RemoveGroupControlAction < TValue > implements Action { static readonly TYPE : 'ngrx/forms/REMOVE_CONTROL' = 'ngrx/forms/REMOVE_CONTROL' ; readonly type = RemoveGroupControlAction . TYPE ; constructor ( public readonly controlId , public readonly name ) { } } export class SetUserDefinedPropertyAction implements Action { static readonly TYPE : 'ngrx/forms/SET_USER_DEFINED_PROPERTY' = 'ngrx/forms/SET_USER_DEFINED_PROPERTY' ; readonly type = SetUserDefinedPropertyAction . TYPE ; constructor ( public readonly controlId , public readonly name , public readonly value ) { } } export class ResetAction implements Action { static readonly TYPE : 'ngrx/forms/RESET' = 'ngrx/forms/RESET' ; readonly type = ResetAction . TYPE ; constructor ( public readonly controlId ) { } } export type Actions < TValue > = SetValueAction < TValue > | SetErrorsAction | SetAsyncErrorAction | ClearAsyncErrorAction | StartAsyncValidationAction | MarkAsDirtyAction | MarkAsPristineAction | EnableAction | DisableAction | MarkAsTouchedAction | MarkAsUntouchedAction | FocusAction | UnfocusAction | MarkAsSubmittedAction | MarkAsUnsubmittedAction | AddGroupControlAction < TValue > | RemoveGroupControlAction < TValue > | AddArrayControlAction < any > | RemoveArrayControlAction | SetUserDefinedPropertyAction | ResetAction | SwapArrayControlAction | MoveArrayControlAction ; export function isNgrxFormsAction ( action ) { return ! ! action . type && action . type . startsWith ( 'ngrx/forms/' ) ; } export const ALL_NGRX_FORMS_ACTION_TYPES = [ SetValueAction . TYPE , SetErrorsAction . TYPE , SetAsyncErrorAction . TYPE , ClearAsyncErrorAction . TYPE , StartAsyncValidationAction . TYPE , MarkAsDirtyAction . TYPE , MarkAsPristineAction . TYPE , EnableAction . TYPE , DisableAction . TYPE , MarkAsTouchedAction . TYPE , MarkAsUntouchedAction . TYPE , FocusAction . TYPE , UnfocusAction . TYPE , MarkAsSubmittedAction . TYPE , MarkAsUnsubmittedAction . TYPE , AddGroupControlAction . TYPE , RemoveGroupControlAction . TYPE , AddArrayControlAction . TYPE , RemoveArrayControlAction . TYPE , SetUserDefinedPropertyAction . TYPE , ResetAction . TYPE , SwapArrayControlAction . TYPE , MoveArrayControlAction . TYPE , ] ;