diff --git a/docs/user-guide/updating-the-state.md b/docs/user-guide/updating-the-state.md index 41678029..22a786d6 100644 --- a/docs/user-guide/updating-the-state.md +++ b/docs/user-guide/updating-the-state.md @@ -121,19 +121,19 @@ The `setValue` update function takes a value and returns a projection function t const control = createFormControlState('control ID', ''); const updatedControl = setValue('new Value')(control); const updatedControlUncurried = setValue(control, 'newValue'); -const updatedControlViaAction = formStateReducer(control, new SetValueAction(control.id, 'newValue')); +const updatedControlViaAction = formStateReducer(control, SetValueAction(control.id, 'newValue')); // group const group = createFormGroupState('group ID', { inner: '' }); const updatedGroup = setValue({ inner: 'newValue' })(group); const updatedGroupUncurried = setValue(group, { inner: 'newValue' }); -const updatedGroupViaAction = formStateReducer(group, new SetValueAction(group.id, { inner: 'newValue' })); +const updatedGroupViaAction = formStateReducer(group, SetValueAction(group.id, { inner: 'newValue' })); // array const array = createFormArrayState('array ID', ['']); const updatedArray = setValue(['newValue'])(array); const updatedArrayUncurried = setValue(array, ['newValue']); -const updatedArrayViaAction = formStateReducer(array, new SetValueAction(array.id, ['newValue'])); +const updatedArrayViaAction = formStateReducer(array, SetValueAction(array.id, ['newValue'])); ``` #### Validating the value @@ -168,19 +168,19 @@ The `setErrors` update function takes one or more error objects and returns a pr const control = createFormControlState('control ID', ''); const updatedControl = setErrors({ missing: true })(control); const updatedControlUncurried = setErrors(control, { missing: true }); -const updatedControlViaAction = formStateReducer(control, new SetErrorsAction(control.id, { missing: true })); +const updatedControlViaAction = formStateReducer(control, SetErrorsAction(control.id, { missing: true })); // group const group = createFormGroupState('group ID', { inner: '' }); const updatedGroup = setErrors({ innerMissing: true })(group); const updatedGroupUncurried = setErrors(group, { innerMissing: true }); -const updatedGroupViaAction = formStateReducer(group, new SetErrorsAction(group.id, { innerMissing: true })); +const updatedGroupViaAction = formStateReducer(group, SetErrorsAction(group.id, { innerMissing: true })); // array const array = createFormArrayState('array ID', ['']); const updatedArray = setErrors({ missing: true })(array); const updatedArrayUncurried = setErrors(array, { missing: true }); -const updatedArrayViaAction = formStateReducer(array, new SetErrorsAction(array.id, { missing: true })); +const updatedArrayViaAction = formStateReducer(array, SetErrorsAction(array.id, { missing: true })); ``` #### Enabling and disabling @@ -192,22 +192,22 @@ The `enable` and `disable` update functions take a form state and enable/disable const control = createFormControlState('control ID', ''); const disabledControl = disable(control); const enabledControl = enable(disabledControl); -const disabledControlViaAction = formStateReducer(control, new DisableAction(control.id)); -const enabledControlViaAction = formStateReducer(disabledControlViaAction, new EnableAction(control.id)); +const disabledControlViaAction = formStateReducer(control, DisableAction(control.id)); +const enabledControlViaAction = formStateReducer(disabledControlViaAction, EnableAction(control.id)); // group const group = createFormGroupState('group ID', { inner: '' }); const disabledGroup = disable(group); const enabledGroup = enable(disabledGroup); -const disabledGroupViaAction = formStateReducer(group, new DisableAction(group.id)); -const enabledGroupViaAction = formStateReducer(disabledGroupViaAction, new EnableAction(group.id)); +const disabledGroupViaAction = formStateReducer(group, DisableAction(group.id)); +const enabledGroupViaAction = formStateReducer(disabledGroupViaAction, EnableAction(group.id)); // array const array = createFormArrayState('array ID', ['']); const disabledArray = disable(array); const enabledArray = enable(disabledArray); -const disabledArrayViaAction = formStateReducer(array, new DisableAction(array.id)); -const enabledArrayViaAction = formStateReducer(disabledArrayViaAction, new EnableAction(array.id)); +const disabledArrayViaAction = formStateReducer(array, DisableAction(array.id)); +const enabledArrayViaAction = formStateReducer(disabledArrayViaAction, EnableAction(array.id)); ``` #### Marking as dirty or pristine @@ -219,22 +219,22 @@ The `markAsDirty` and `markAsPristine` update functions take a form state and ma const control = createFormControlState('control ID', ''); const dirtyControl = markAsDirty(control); const pristineControl = markAsPristine(dirtyControl); -const dirtyControlViaAction = formStateReducer(control, new MarkAsDirtyAction(control.id)); -const pristineControlViaAction = formStateReducer(dirtyControlViaAction, new MarkAsPristineAction(control.id)); +const dirtyControlViaAction = formStateReducer(control, MarkAsDirtyAction(control.id)); +const pristineControlViaAction = formStateReducer(dirtyControlViaAction, MarkAsPristineAction(control.id)); // group const group = createFormGroupState('group ID', { inner: '' }); const dirtyGroup = markAsDirty(group); const pristineGroup = markAsPristine(dirtyGroup); -const dirtyGroupViaAction = formStateReducer(group, new MarkAsDirtyAction(group.id)); -const pristineGroupViaAction = formStateReducer(dirtyGroupViaAction, new MarkAsPristineAction(group.id)); +const dirtyGroupViaAction = formStateReducer(group, MarkAsDirtyAction(group.id)); +const pristineGroupViaAction = formStateReducer(dirtyGroupViaAction, MarkAsPristineAction(group.id)); // array const array = createFormArrayState('array ID', ['']); const dirtyArray = markAsDirty(array); const pristineArray = markAsPristine(dirtyArray); -const dirtyArrayViaAction = formStateReducer(array, new MarkAsDirtyAction(array.id)); -const pristineArrayViaAction = formStateReducer(dirtyArrayViaAction, new MarkAsPristineAction(array.id)); +const dirtyArrayViaAction = formStateReducer(array, MarkAsDirtyAction(array.id)); +const pristineArrayViaAction = formStateReducer(dirtyArrayViaAction, MarkAsPristineAction(array.id)); ``` #### Marking as touched or untouched @@ -246,22 +246,22 @@ The `markAsTouched` and `markAsUntouched` update functions take a form state and const control = createFormControlState('control ID', ''); const touchedControl = markAsTouched(control); const untouchedControl = markAsUntouched(touchedControl); -const touchedControlViaAction = formStateReducer(control, new MarkAsTouchedAction(control.id)); -const untouchedControlViaAction = formStateReducer(touchedControlViaAction, new MarkAsUntouchedAction(control.id)); +const touchedControlViaAction = formStateReducer(control, MarkAsTouchedAction(control.id)); +const untouchedControlViaAction = formStateReducer(touchedControlViaAction, MarkAsUntouchedAction(control.id)); // group const group = createFormGroupState('group ID', { inner: '' }); const touchedGroup = markAsTouched(group); const untouchedGroup = markAsUntouched(touchedGroup); -const touchedGroupViaAction = formStateReducer(group, new MarkAsTouchedAction(group.id)); -const untouchedGroupViaAction = formStateReducer(touchedGroupViaAction, new MarkAsUntouchedAction(group.id)); +const touchedGroupViaAction = formStateReducer(group, MarkAsTouchedAction(group.id)); +const untouchedGroupViaAction = formStateReducer(touchedGroupViaAction, MarkAsUntouchedAction(group.id)); // array const array = createFormArrayState('array ID', ['']); const touchedArray = markAsTouched(array); const untouchedArray = markAsUntouched(touchedArray); -const touchedArrayViaAction = formStateReducer(array, new MarkAsTouchedAction(array.id)); -const untouchedArrayViaAction = formStateReducer(touchedArrayViaAction, new MarkAsUntouchedAction(array.id)); +const touchedArrayViaAction = formStateReducer(array, MarkAsTouchedAction(array.id)); +const untouchedArrayViaAction = formStateReducer(touchedArrayViaAction, MarkAsUntouchedAction(array.id)); ``` #### Marking as submitted or unsubmitted @@ -273,22 +273,22 @@ The `markAsSubmitted` and `markAsUnsubmitted` update functions take a form state const control = createFormControlState('control ID', ''); const submittedControl = markAsSubmitted(control); const unsubmittedControl = markAsUnsubmitted(submittedControl); -const submittedControlViaAction = formStateReducer(control, new MarkAsSubmittedAction(control.id)); -const unsubmittedControlViaAction = formStateReducer(submittedControlViaAction, new MarkAsUnsubmittedAction(control.id)); +const submittedControlViaAction = formStateReducer(control, MarkAsSubmittedAction(control.id)); +const unsubmittedControlViaAction = formStateReducer(submittedControlViaAction, MarkAsUnsubmittedAction(control.id)); // group const group = createFormGroupState('group ID', { inner: '' }); const submittedGroup = markAsSubmitted(group); const unsubmittedGroup = markAsUnsubmitted(submittedGroup); -const submittedGroupViaAction = formStateReducer(group, new MarkAsSubmittedAction(group.id)); -const unsubmittedGroupViaAction = formStateReducer(submittedGroupViaAction, new MarkAsUnsubmittedAction(group.id)); +const submittedGroupViaAction = formStateReducer(group, MarkAsSubmittedAction(group.id)); +const unsubmittedGroupViaAction = formStateReducer(submittedGroupViaAction, MarkAsUnsubmittedAction(group.id)); // array const array = createFormArrayState('array ID', ['']); const submittedArray = markAsSubmitted(array); const unsubmittedArray = markAsUnsubmitted(submittedArray); -const submittedArrayViaAction = formStateReducer(array, new MarkAsSubmittedAction(array.id)); -const unsubmittedArrayViaAction = formStateReducer(submittedArrayViaAction, new MarkAsUnsubmittedAction(array.id)); +const submittedArrayViaAction = formStateReducer(array, MarkAsSubmittedAction(array.id)); +const unsubmittedArrayViaAction = formStateReducer(submittedArrayViaAction, MarkAsUnsubmittedAction(array.id)); ``` #### Resetting @@ -300,19 +300,19 @@ The `reset` update function takes a form state and marks it as pristine, untouch const control = createFormControlState('control ID', ''); const updatedControl = markAsSubmitted(markAsTouched(markAsDirty(control))); const resetControl = reset(updatedControl); -const resetControlViaAction = formStateReducer(updatedControl, new ResetAction(control.id)); +const resetControlViaAction = formStateReducer(updatedControl, ResetAction(control.id)); // group const group = createFormGroupState('group ID', { inner: '' }); const updatedGroup = markAsSubmitted(markAsTouched(markAsDirty(group))); const resetGroup = reset(updatedGroup); -const resetGroupViaAction = formStateReducer(updatedGroup, new ResetAction(group.id)); +const resetGroupViaAction = formStateReducer(updatedGroup, ResetAction(group.id)); // array const array = createFormArrayState('array ID', ['']); const updatedArray = markAsSubmitted(markAsTouched(markAsDirty(array))); const resetArray = reset(updatedArray); -const resetArrayViaAction = formStateReducer(updatedArray, new ResetAction(array.id)); +const resetArrayViaAction = formStateReducer(updatedArray, ResetAction(array.id)); ``` #### Focusing and unfocusing @@ -323,8 +323,8 @@ The `focus` and `unfocus` update functions take a form control state and mark it const control = createFormControlState('control ID', ''); const focusedControl = focus(control); const unfocusedControl = unfocus(focusedControl); -const focusedControlViaAction = formStateReducer(control, new FocusAction(control.id)); -const unfocusedControlViaAction = formStateReducer(focusedControlViaAction, new UnfocusAction(control.id)); +const focusedControlViaAction = formStateReducer(control, FocusAction(control.id)); +const unfocusedControlViaAction = formStateReducer(focusedControlViaAction, UnfocusAction(control.id)); ``` #### Adding and removing group controls @@ -356,7 +356,7 @@ const arrayWithoutControl = removeArrayControl(1)(arrayWithControl); const arrayWithControlUncurried = addArrayControl(array, '1', 1); const arrayWithoutControlUncurried = removeArrayControl(arrayWithControlUncurried, 1); const arrayWithControlViaAction = formStateReducer(array, new AddArrayControlAction(array.id, '1', 1)); -const arrayWithoutControlViaAction = formStateReducer(arrayWithControlViaAction, new RemoveArrayControlAction(array.id, 1)); +const arrayWithoutControlViaAction = formStateReducer(arrayWithControlViaAction, RemoveArrayControlAction(array.id, 1)); ``` #### Setting user-defined properties @@ -368,19 +368,19 @@ The `setUserDefinedProperty` update function takes a name and a value and return const control = createFormControlState('control ID', ''); const updatedControl = setUserDefinedProperty('allowedValues', ['foo', 'bar'])(control); const updatedControlUncurried = setUserDefinedProperty(control, 'allowedValues', ['foo', 'bar']); -const updatedControlViaAction = formStateReducer(control, new SetUserDefinedPropertyAction(control.id, 'allowedValues', ['foo', 'bar'])); +const updatedControlViaAction = formStateReducer(control,SetUserDefinedPropertyAction(control.id, 'allowedValues', ['foo', 'bar'])); // group const group = createFormGroupState('group ID', { inner: '' }); const updatedGroup = setUserDefinedProperty('allowedValues', ['foo', 'bar'])(group); const updatedGroupUncurried = setUserDefinedProperty(group, 'allowedValues', ['foo', 'bar']); -const updatedGroupViaAction = formStateReducer(group, new SetUserDefinedPropertyAction(group.id, 'allowedValues', ['foo', 'bar'])); +const updatedGroupViaAction = formStateReducer(group,SetUserDefinedPropertyAction(group.id, 'allowedValues', ['foo', 'bar'])); // array const array = createFormArrayState('array ID', ['']); const updatedArray = setUserDefinedProperty('allowedValues', ['foo', 'bar'])(array); const updatedArrayUncurried = setUserDefinedProperty(array, 'allowedValues', ['foo', 'bar']); -const updatedArrayViaAction = formStateReducer(array, new SetUserDefinedPropertyAction(array.id, 'allowedValues', ['foo', 'bar'])); +const updatedArrayViaAction = formStateReducer(array,SetUserDefinedPropertyAction(array.id, 'allowedValues', ['foo', 'bar'])); ``` #### Updating groups @@ -640,14 +640,14 @@ function appReducer(state = INITIAL_APP_STATE, action: Action) { const value: boolean = a.value; if (value) { - const formState = formGroupReducer(state.formState, new EnableAction(someNumberId)); + const formState = formGroupReducer(state.formState, EnableAction(someNumberId)); return { ...state, formState, }; } - const formState = formGroupReducer(state.formState, new DisableAction(someNumberId)); + const formState = formGroupReducer(state.formState, DisableAction(someNumberId)); return { ...state, formState, @@ -660,7 +660,7 @@ function appReducer(state = INITIAL_APP_STATE, action: Action) { if (value === null) { const formState = formGroupReducer( state.formState, - new SetErrorsAction(someNumberId, { valueIsNull: true }), + SetErrorsAction(someNumberId, { valueIsNull: true }), ); return { @@ -672,7 +672,7 @@ function appReducer(state = INITIAL_APP_STATE, action: Action) { if (value < 1) { const formState = formGroupReducer( state.formState, - new SetErrorsAction(someNumberId, { valueTooSmall: true }), + SetErrorsAction(someNumberId, { valueTooSmall: true }), ); return { @@ -684,7 +684,7 @@ function appReducer(state = INITIAL_APP_STATE, action: Action) { if (value > 10) { const formState = formGroupReducer( state.formState, - new SetErrorsAction(someNumberId, { valueTooLarge: true }), + SetErrorsAction(someNumberId, { valueTooLarge: true }), ); return { diff --git a/docs/user-guide/validation.md b/docs/user-guide/validation.md index 07bbece1..040fa797 100644 --- a/docs/user-guide/validation.md +++ b/docs/user-guide/validation.md @@ -149,10 +149,10 @@ validateBookExists$: Observable = this.actions$ this.http.get(`api/books/search/${a.searchTerm}`) .map(resp => resp.status === 404 - ? new SetAsyncErrorAction(a.controlId, "exists", true) - : new ClearAsyncErrorAction(a.controlId, "exists") + ? SetAsyncErrorAction(a.controlId, "exists", true) + : ClearAsyncErrorAction(a.controlId, "exists") ) // controlId may either be sent with the action or obtained from the store via withLatestFrom - .startWith(new StartAsyncValidationAction(a.controlId, "exists")) + .startWith(StartAsyncValidationAction(a.controlId, "exists")) ); ``` diff --git a/example-app/src/app/async-validation/async-validation.effects.ts b/example-app/src/app/async-validation/async-validation.effects.ts index acd6b5a5..ab3e835b 100644 --- a/example-app/src/app/async-validation/async-validation.effects.ts +++ b/example-app/src/app/async-validation/async-validation.effects.ts @@ -23,7 +23,7 @@ export class AsyncValidationEffects { switchMap(fs => concat( timer(300).pipe( - map(() => new StartAsyncValidationAction( + map(() => StartAsyncValidationAction( fs.controls.searchTerm.id, 'exists', )) @@ -43,7 +43,7 @@ export class AsyncValidationEffects { new SetSearchResultAction( resp.items.map((i: any) => i.volumeInfo.title), ), - new ClearAsyncErrorAction( + ClearAsyncErrorAction( fs.controls.searchTerm.id, 'exists', ), @@ -52,7 +52,7 @@ export class AsyncValidationEffects { return [ new SetSearchResultAction([]), - new SetAsyncErrorAction( + SetAsyncErrorAction( fs.controls.searchTerm.id, 'exists', fs.value.searchTerm, @@ -61,7 +61,7 @@ export class AsyncValidationEffects { }), catchError(_ => [ new SetSearchResultAction([]), - new SetAsyncErrorAction( + SetAsyncErrorAction( fs.controls.searchTerm.id, 'exists', fs.value.searchTerm, diff --git a/example-app/src/app/dynamic/dynamic.component.ts b/example-app/src/app/dynamic/dynamic.component.ts index 1023f83e..ff15b878 100644 --- a/example-app/src/app/dynamic/dynamic.component.ts +++ b/example-app/src/app/dynamic/dynamic.component.ts @@ -44,7 +44,7 @@ export class DynamicPageComponent { this.formState$.pipe( take(1), map(s => s.controls.array.id), - map(id => new RemoveArrayControlAction(id, index)), + map(id => RemoveArrayControlAction(id, index)), ).subscribe(this.store); } diff --git a/example-app/src/app/local-state-advanced/local-state-advanced.component.ts b/example-app/src/app/local-state-advanced/local-state-advanced.component.ts index 4c915cd4..27d8e848 100644 --- a/example-app/src/app/local-state-advanced/local-state-advanced.component.ts +++ b/example-app/src/app/local-state-advanced/local-state-advanced.component.ts @@ -1,9 +1,9 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { Action, ActionsSubject } from '@ngrx/store'; -import { Actions, SetValueAction } from 'ngrx-forms'; import { Subscription } from 'rxjs'; import { GetManufacturersAction, INITIAL_LOCAL_STATE, reducer } from './local-state-advanced.reducer'; +import {NgrxFormActionTypes, SetValueAction} from "../../../../src/actions"; @Component({ selector: 'ngf-local-state-advanced', @@ -33,16 +33,16 @@ export class LocalStateAdvancedComponent implements OnInit, OnDestroy { this.subscription.unsubscribe(); } - handleFormAction(action: Actions) { + handleFormAction(action: NgrxFormActionTypes) { this.updateState(action); // trigger loading of new manufacturers list in effect - if (action.type === SetValueAction.TYPE && action.controlId === this.localState.formState.controls.countryCode.id) { - this.actionsSubject.next(new GetManufacturersAction(action.value)); + if (action.type === SetValueAction.type && action.controlId === this.localState.formState.controls.countryCode.id) { + this.actionsSubject.next(GetManufacturersAction(action.value)); } } - private updateState(action: Action): boolean { + private updateState(action: NgrxFormActionTypes): boolean { const localState = reducer(this.localState, action); const updated = localState !== this.localState; this.localState = localState; diff --git a/example-app/src/app/local-state-advanced/local-state-advanced.effects.ts b/example-app/src/app/local-state-advanced/local-state-advanced.effects.ts index dc0c5c5b..dc09db31 100644 --- a/example-app/src/app/local-state-advanced/local-state-advanced.effects.ts +++ b/example-app/src/app/local-state-advanced/local-state-advanced.effects.ts @@ -1,29 +1,35 @@ import { Injectable } from '@angular/core'; -import { Actions, Effect, ofType } from '@ngrx/effects'; -import { Action } from '@ngrx/store'; +import { Effect, ofType } from '@ngrx/effects'; import { Observable } from 'rxjs'; import { debounceTime, delay, map } from 'rxjs/operators'; -import { GetManufacturersAction, SetManufacturersAction } from './local-state-advanced.reducer'; +import { + GetManufacturersAction, + ManufacturersActionsTypes, + SetManufacturersAction +} from './local-state-advanced.reducer'; @Injectable() export class LocalStateAdvancedEffects { @Effect() - getManufacturers$: Observable = this.actions$.pipe( - ofType(GetManufacturersAction.TYPE), + getManufacturers$: Observable = this.actions$.pipe( debounceTime(300), delay(1000), - map((action: GetManufacturersAction) => { - if (action.countryCode === 'US') { - return new SetManufacturersAction(['Ford', 'Chevrolet']); - } else if (action.countryCode === 'UK') { - return new SetManufacturersAction(['Aston Martin', 'Jaguar']); - } else { - return new SetManufacturersAction([]); + ofType(GetManufacturersAction.type), + map((action: ManufacturersActionsTypes) => { + if (action.type === GetManufacturersAction.type) { + if (action.countryCode === 'US') { + return SetManufacturersAction(['Ford', 'Chevrolet']); + } else if (action.countryCode === 'UK') { + return SetManufacturersAction(['Aston Martin', 'Jaguar']); + } else { + return SetManufacturersAction([]); + } } + return SetManufacturersAction([]); }) ); - constructor(private actions$: Actions) { } + constructor(private actions$: Observable) { } } diff --git a/example-app/src/app/local-state-advanced/local-state-advanced.reducer.ts b/example-app/src/app/local-state-advanced/local-state-advanced.reducer.ts index 5f3719ed..e6425b17 100644 --- a/example-app/src/app/local-state-advanced/local-state-advanced.reducer.ts +++ b/example-app/src/app/local-state-advanced/local-state-advanced.reducer.ts @@ -1,17 +1,17 @@ -import { Action, combineReducers } from '@ngrx/store'; -import { createFormGroupState, formGroupReducer, FormGroupState, setValue, updateGroup } from 'ngrx-forms'; +import {Action, combineReducers, createAction, union} from '@ngrx/store'; +import { + createFormGroupState, + formGroupReducer, + FormGroupState, + setValue, + updateGroup +} from "../../../../src/ngrx-forms"; -export class GetManufacturersAction implements Action { - static readonly TYPE = 'localStateAdvanced/GET_MANUFACTURERS'; - readonly type = GetManufacturersAction.TYPE; - constructor(public countryCode: string) { } -} +export const GetManufacturersAction = createAction('localStateAdvanced/GET_MANUFACTURERS', (countryCode: string) => ({ countryCode: countryCode })); +export const SetManufacturersAction = createAction('localStateAdvanced/SET_MANUFACTURERS', (manufacturers: string[]) => ({ manufacturers: manufacturers })); -export class SetManufacturersAction implements Action { - static readonly TYPE = 'localStateAdvanced/SET_MANUFACTURERS'; - readonly type = SetManufacturersAction.TYPE; - constructor(public manufacturers: string[]) { } -} +export const ManufacturersActions = union({GetManufacturersAction, SetManufacturersAction}); +export type ManufacturersActionsTypes = typeof ManufacturersActions; export interface FormValue { countryCode: string; @@ -36,10 +36,10 @@ export const INITIAL_LOCAL_STATE: LocalState = { }; const reducers = combineReducers({ - manufacturers(manufacturers = [], a: Action) { + manufacturers(manufacturers: string[] = [], a: Action) { // update from loaded data - if (a.type === SetManufacturersAction.TYPE) { - return (a as SetManufacturersAction).manufacturers; + if (a.type === SetManufacturersAction.type) { + return a as any['manufacturers']; } return manufacturers; }, diff --git a/example-app/src/app/local-state-introduction/local-state-introduction.component.ts b/example-app/src/app/local-state-introduction/local-state-introduction.component.ts index 071c73f2..d5441c8d 100644 --- a/example-app/src/app/local-state-introduction/local-state-introduction.component.ts +++ b/example-app/src/app/local-state-introduction/local-state-introduction.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { Actions } from 'ngrx-forms'; import { INITIAL_FORM_STATE, reducer } from './local-state-introduction.reducer'; +import {NgrxFormActionTypes} from "../../../../src/actions"; @Component({ selector: 'ngf-local-state-introduction', @@ -11,7 +11,7 @@ import { INITIAL_FORM_STATE, reducer } from './local-state-introduction.reducer' export class LocalStateIntroductionComponent { formState = INITIAL_FORM_STATE; - handleFormAction(action: Actions) { + handleFormAction(action: NgrxFormActionTypes) { this.formState = reducer(this.formState, action); } } diff --git a/example-app/src/app/material-example/material.component.ts b/example-app/src/app/material-example/material.component.ts index 3dcbe12c..8ff34b43 100644 --- a/example-app/src/app/material-example/material.component.ts +++ b/example-app/src/app/material-example/material.component.ts @@ -1,10 +1,16 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { select, Store } from '@ngrx/store'; -import { FormGroupState, NgrxValueConverter, NgrxValueConverters, ResetAction, SetValueAction } from 'ngrx-forms'; import { Observable } from 'rxjs'; import { filter, map, take } from 'rxjs/operators'; import { FormValue, INITIAL_STATE, SetSubmittedValueAction, State } from './material.reducer'; +import { + FormGroupState, + NgrxValueConverter, + NgrxValueConverters, + ResetAction, + SetValueAction +} from "../../../../src/ngrx-forms"; @Component({ selector: 'ngf-material', @@ -24,7 +30,7 @@ export class DynamicPageComponent { hobbyOptions = ['Sports', 'Video Games']; dateValueConverter: NgrxValueConverter = { - convertViewToStateValue(value) { + convertViewToStateValue(value: any) { if (value === null) { return null; } @@ -38,8 +44,8 @@ export class DynamicPageComponent { }; reset() { - this.store.dispatch(new SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); - this.store.dispatch(new ResetAction(INITIAL_STATE.id)); + this.store.dispatch(SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); + this.store.dispatch(ResetAction(INITIAL_STATE.id)); } submit() { diff --git a/example-app/src/app/simple-form-ngrx8/simple-form-ngrx8.component.ts b/example-app/src/app/simple-form-ngrx8/simple-form-ngrx8.component.ts index 26545ace..a1a57d4a 100644 --- a/example-app/src/app/simple-form-ngrx8/simple-form-ngrx8.component.ts +++ b/example-app/src/app/simple-form-ngrx8/simple-form-ngrx8.component.ts @@ -1,10 +1,11 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { select, Store } from '@ngrx/store'; -import { FormGroupState, ResetAction, SetValueAction } from 'ngrx-forms'; import { Observable } from 'rxjs'; import { map, take } from 'rxjs/operators'; import { FormValue, INITIAL_STATE, setSubmittedValue, State } from './simple-form-ngrx8.reducer'; +import {ResetAction, SetValueAction} from "../../../../src/actions"; +import {FormGroupState} from "../../../../src/state"; @Component({ selector: 'ngf-simple-form-ngrx8', @@ -22,8 +23,8 @@ export class SimpleFormNgrx8PageComponent { } reset() { - this.store.dispatch(new SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); - this.store.dispatch(new ResetAction(INITIAL_STATE.id)); + this.store.dispatch(SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); + this.store.dispatch(ResetAction(INITIAL_STATE.id)); } submit() { diff --git a/example-app/src/app/simple-form/simple-form.component.ts b/example-app/src/app/simple-form/simple-form.component.ts index c444764d..9a64272f 100644 --- a/example-app/src/app/simple-form/simple-form.component.ts +++ b/example-app/src/app/simple-form/simple-form.component.ts @@ -1,10 +1,11 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { select, Store } from '@ngrx/store'; -import { FormGroupState, ResetAction, SetValueAction } from 'ngrx-forms'; import { Observable } from 'rxjs'; import { map, take } from 'rxjs/operators'; import { FormValue, INITIAL_STATE, SetSubmittedValueAction, State } from './simple-form.reducer'; +import {ResetAction, SetValueAction} from "../../../../src/actions"; +import {FormGroupState} from "../../../../src/state"; @Component({ selector: 'ngf-simple-form', @@ -22,8 +23,8 @@ export class SimpleFormPageComponent { } reset() { - this.store.dispatch(new SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); - this.store.dispatch(new ResetAction(INITIAL_STATE.id)); + this.store.dispatch(SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); + this.store.dispatch(ResetAction(INITIAL_STATE.id)); } submit() { diff --git a/example-app/src/app/sync-validation/sync-validation.component.ts b/example-app/src/app/sync-validation/sync-validation.component.ts index 0cb9c00d..f5fd32db 100644 --- a/example-app/src/app/sync-validation/sync-validation.component.ts +++ b/example-app/src/app/sync-validation/sync-validation.component.ts @@ -39,8 +39,8 @@ export class SyncValidationPageComponent { } reset() { - this.store.dispatch(new SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); - this.store.dispatch(new ResetAction(INITIAL_STATE.id)); + this.store.dispatch(SetValueAction(INITIAL_STATE.id, INITIAL_STATE.value)); + this.store.dispatch(ResetAction(INITIAL_STATE.id)); } submit() { diff --git a/package-lock.json b/package-lock.json index aeb60fd4..579a3e67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,23 +5,47 @@ "requires": true, "dependencies": { "@angular/common": { - "version": "9.1.13", - "resolved": "https://registry.npmjs.org/@angular/common/-/common-9.1.13.tgz", - "integrity": "sha512-QACUhJWlly/nfHUmjopVS1p6ayxxa/NqjyftdCeBJaoyM2YohqWixP/n/keu1K/srJ96aFpUNsZQgmgoRv5SOQ==", - "dev": true + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@angular/common/-/common-11.1.0.tgz", + "integrity": "sha512-jR9fnhzvvpdilyhPnyRlRRFRJ9vf/OhUFJrL42Knaj7uknmjgeu168JhwVdq6uj+v1208suXW+nOXhKNIpH38Q==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + } + } }, "@angular/compiler": { - "version": "9.1.13", - "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-9.1.13.tgz", - "integrity": "sha512-9MLB1Xx7odKuxDoybVwiOB1ZEUZpL8FurYm4RVuW39ntsUt0IMC9Hb8UagZLTAWhaWSHydkD/KBQVVobGqd0lA==", - "dev": true + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-11.1.0.tgz", + "integrity": "sha512-XW+McH/RVjpLtNkft6UYZQbjhXwX/hvLgUa9jGlTuIFM5o7W4XRPnq5sfn3+QvzdROF0j8S5sy47mGVNQOYMNg==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + } + } }, "@angular/compiler-cli": { - "version": "9.1.13", - "resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-9.1.13.tgz", - "integrity": "sha512-40jbfMr1FinOqUyG3k4Moiytjs/Z8zKBgP3S5Qfn80EBJItRdFXwNtvaOi/onaag4+Mv+vigShwsgCewLbt/kA==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-11.1.0.tgz", + "integrity": "sha512-PLeVrqBpn43G7DeBkDQqH38Y+VMlCIbxiP4Vv1rFAmKVNIm9J8m8jdC3EQSTXVV+L3oDCVP5/ERSCZ8Jqx6UoA==", "dev": true, "requires": { + "@babel/core": "^7.8.6", + "@babel/types": "^7.8.6", "canonical-path": "1.0.0", "chokidar": "^3.0.0", "convert-source-map": "^1.5.1", @@ -33,6 +57,7 @@ "semver": "^6.3.0", "source-map": "^0.6.1", "sourcemap-codec": "^1.4.8", + "tslib": "^2.0.0", "yargs": "^16.1.1" }, "dependencies": { @@ -47,32 +72,82 @@ "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "dev": true + }, + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true } } }, "@angular/core": { - "version": "9.1.13", - "resolved": "https://registry.npmjs.org/@angular/core/-/core-9.1.13.tgz", - "integrity": "sha512-mBm24Q9GjkAsxMAzqQ86U1078+yTEpr0+syMEruUtJ0HUH6Fzn3J+6xTLb+BVcGb9RkCkFaV9T5mcn6ZM0f++g==", - "dev": true + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@angular/core/-/core-11.1.0.tgz", + "integrity": "sha512-VhiRWZEj9Q/OvbbSDcgQ4f53oVcMnDB4uNL8xaWnK0Sb3lZA4aQW3VOlROBITS5n2g7D1zRhvUzdfzVuyuMIaQ==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + } + } }, "@angular/forms": { - "version": "9.1.13", - "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-9.1.13.tgz", - "integrity": "sha512-soGVZmPq2bzkxvtTyeJB8p3ejzm4xxt+43hJw6Ag8NxpwUFPVa30oJge3JV+u8Y4yBtl5SbOZ4bBX3EkMxLcGQ==", - "dev": true + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-11.1.0.tgz", + "integrity": "sha512-pHwLPGDHk3JOoK2nA3wJoDCJF2bn8NmVqv8Lh5Pd8NYqLFRIIDiHSjNkqr1eM0JUmExqfU5tCrLrPz4YChdYBA==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + } + } }, "@angular/platform-browser": { - "version": "9.1.13", - "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-9.1.13.tgz", - "integrity": "sha512-F3iTz1zNbtrs7KFKUxbj8qmTsd/fiuTNcpBExjE5TtatRiE6J8vNvN1+Z/1FgPe0UXBSdTzSwZ8/RxWKw20RMw==", - "dev": true + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-11.1.0.tgz", + "integrity": "sha512-wdinsRiKC5mGWWSA5RqferFvpe3Wr9YIVK2Gaj50DlJGOJ/8yWvux3BYjsCd5B44PC8+6dxUEZMgvA6CmhXgpw==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + } + } }, "@angular/platform-browser-dynamic": { - "version": "9.1.13", - "resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-9.1.13.tgz", - "integrity": "sha512-jCeHyAZ4Nap1/FOqAlKEg9UxQaSkHrxnQr6hYtWwC4ZDVUn3zLWQf6J+mbeYNOXN5yQxEiIqqhORYeOCLLqf1w==", - "dev": true + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-11.1.0.tgz", + "integrity": "sha512-1MFRvjbkogtEQO/bWkNm2xOIl8CeIJuRWoXYE00VKShmq4o+2kTHBRQD0NydPQYwqo9o4XpgmIrJXHgwp3S2Qw==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + } + } }, "@babel/code-frame": { "version": "7.12.11", @@ -1195,10 +1270,21 @@ "dev": true }, "@ngrx/store": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/@ngrx/store/-/store-9.2.0.tgz", - "integrity": "sha512-V8AI3mxbMztVpbZpALkLZYlGkofKcu9GaOCY5e+sZ1VcJ90oxhFjBpnmd6MuVdmhep1XAHALb1B8ZbBFn+xsgQ==", - "dev": true + "version": "11.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@ngrx/store/-/store-11.0.0-beta.1.tgz", + "integrity": "sha512-bxHLSAc2sFIwg482MFoKewpOk65iGWPJyX+wnceWyhVy3mGDYkAZ+gVKAOI6te+bIdd9qjK6ISoeYM8+RDCgPA==", + "dev": true, + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + } + } }, "@nodelib/fs.scandir": { "version": "2.1.3", @@ -1227,28 +1313,32 @@ } }, "@rollup/plugin-commonjs": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.1.0.tgz", - "integrity": "sha512-Ycr12N3ZPN96Fw2STurD21jMqzKwL9QuFhms3SD7KKRK7oaXUsBU9Zt0jL/rOPHiPYisI21/rXGO3jr9BnLHUA==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.0.0.tgz", + "integrity": "sha512-/omBIJG1nHQc+bgkYDuLpb/V08QyutP9amOrJRUSlYJZP+b/68gM//D8sxJe3Yry2QnYIr3QjR3x4AlxJEN3GA==", "dev": true, "requires": { - "@rollup/pluginutils": "^3.0.8", + "@rollup/pluginutils": "^3.1.0", "commondir": "^1.0.1", - "estree-walker": "^1.0.1", - "glob": "^7.1.2", - "is-reference": "^1.1.2", - "magic-string": "^0.25.2", - "resolve": "^1.11.0" + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" }, "dependencies": { - "resolve": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", - "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { - "is-core-module": "^2.1.0", - "path-parse": "^1.0.6" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } } } @@ -1263,28 +1353,17 @@ } }, "@rollup/plugin-node-resolve": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz", - "integrity": "sha512-RxtSL3XmdTAE2byxekYLnx+98kEUOrPHF/KRVjLH+DEIHy6kjIw7YINQzn+NXiH/NTrQLAwYs0GWB+csWygA9Q==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.1.0.tgz", + "integrity": "sha512-ouBBppRdWJKCllDXGzJ7ZIkYbaq+5TmyP0smt1vdJCFfoZhLi31vhpmjLhyo8lreHf4RoeSNllaWrvSqHpHRog==", "dev": true, "requires": { - "@rollup/pluginutils": "^3.0.8", - "@types/resolve": "0.0.8", + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", "is-module": "^1.0.0", - "resolve": "^1.14.2" - }, - "dependencies": { - "resolve": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", - "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", - "dev": true, - "requires": { - "is-core-module": "^2.1.0", - "path-parse": "^1.0.6" - } - } + "resolve": "^1.19.0" } }, "@rollup/pluginutils": { @@ -1298,6 +1377,12 @@ "picomatch": "^2.2.2" }, "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, "picomatch": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", @@ -1363,10 +1448,16 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, + "@types/q": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz", + "integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==", + "dev": true + }, "@types/resolve": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", - "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", "dev": true, "requires": { "@types/node": "*" @@ -1444,17 +1535,23 @@ } }, "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.0.3.tgz", + "integrity": "sha512-R50QRlXSxqXcQP5SvKUrw8VZeypvo12i2IX0EeR5PiZ7bEKeHWgzgo264LDadUsCU42lTJVhFikTqJwNeH34gQ==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", "uri-js": "^4.2.2" } }, + "alphanum-sort": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/alphanum-sort/-/alphanum-sort-1.0.2.tgz", + "integrity": "sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM=", + "dev": true + }, "ansi-align": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz", @@ -1464,6 +1561,12 @@ "string-width": "^3.0.0" } }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, "ansi-escapes": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", @@ -1605,12 +1708,6 @@ "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==", "dev": true }, - "at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true - }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -1741,7 +1838,7 @@ "dependencies": { "jsesc": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", "dev": true }, @@ -2591,6 +2688,25 @@ "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", "dev": true }, + "bl": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", + "integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==", + "dev": true, + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + } + } + }, "blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -2629,6 +2745,12 @@ } } }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", + "dev": true + }, "boxen": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/boxen/-/boxen-4.2.0.tgz", @@ -2920,9 +3042,9 @@ "dev": true }, "builtin-modules": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", - "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", + "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", "dev": true }, "builtin-status-codes": { @@ -3002,6 +3124,26 @@ "quick-lru": "^4.0.1" } }, + "caniuse-api": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", + "integrity": "sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==", + "dev": true, + "requires": { + "browserslist": "^4.0.0", + "caniuse-lite": "^1.0.0", + "lodash.memoize": "^4.1.2", + "lodash.uniq": "^4.5.0" + }, + "dependencies": { + "lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=", + "dev": true + } + } + }, "caniuse-lite": { "version": "1.0.30001168", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001168.tgz", @@ -3057,21 +3199,27 @@ "safe-buffer": "^5.0.1" } }, - "clean-css": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", - "integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", - "dev": true, - "requires": { - "source-map": "~0.6.0" - } - }, "cli-boxes": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz", "integrity": "sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==", "dev": true }, + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "cli-spinners": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.5.0.tgz", + "integrity": "sha512-PC+AmIuK04E6aeSs/pUccSujsTzBhu4HzC2dL+CfJB/Jcc2qTRbEwZQDfIUpt2Xl8BodYBEq8w4fc0kU2I9DjQ==", + "dev": true + }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -3138,6 +3286,17 @@ "mimic-response": "^1.0.0" } }, + "coa": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/coa/-/coa-2.0.2.tgz", + "integrity": "sha512-q5/jG+YQnSy4nRTV4F7lPepBJZ8qBNJJDBuJdoejDyLXgmL7IEo+Le2JDZudFTFt7mrCqIRaSjws4ygRCTCAXA==", + "dev": true, + "requires": { + "@types/q": "^1.5.1", + "chalk": "^2.4.1", + "q": "^1.1.2" + } + }, "codecov": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.8.1.tgz", @@ -3211,6 +3370,16 @@ } } }, + "color": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/color/-/color-3.1.3.tgz", + "integrity": "sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ==", + "dev": true, + "requires": { + "color-convert": "^1.9.1", + "color-string": "^1.5.4" + } + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -3226,6 +3395,16 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "color-string": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.4.tgz", + "integrity": "sha512-57yF5yt8Xa3czSEW1jfQDE79Idk0+AkN/4KWad6tbdxUmAs3MvjxlWSWD4deYytcRfoZ9nhKyFl1kj5tBvidbw==", + "dev": true, + "requires": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, "colorette": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", @@ -3353,6 +3532,15 @@ "safe-buffer": "~5.1.1" } }, + "copy-anything": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.1.tgz", + "integrity": "sha512-lA57e7viQHOdPQcrytv5jFeudZZOXuyk47lZym279FiDQ8jeZomXiGuVf6ffMKkJ+3TIai3J1J3yi6M+/4U35g==", + "dev": true, + "requires": { + "is-what": "^3.7.1" + } + }, "core-js": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.8.1.tgz", @@ -3498,6 +3686,22 @@ } } }, + "css-color-names": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", + "integrity": "sha1-gIrcLnnPhHOAabZGyyDsJ762KeA=", + "dev": true + }, + "css-declaration-sorter": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-4.0.1.tgz", + "integrity": "sha512-BcxQSKTSEEQUftYpBVnsH4SF05NTuBokb19/sBt6asXGKZ/6VP7PLG1CBCkFDYOnhXhPh0jMhO6xZ71oYHXHBA==", + "dev": true, + "requires": { + "postcss": "^7.0.1", + "timsort": "^0.3.0" + } + }, "css-parse": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/css-parse/-/css-parse-2.0.0.tgz", @@ -3507,6 +3711,24 @@ "css": "^2.0.0" } }, + "css-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-2.1.0.tgz", + "integrity": "sha512-Dqk7LQKpwLoH3VovzZnkzegqNSuAziQyNZUcrdDM401iY+R5NkGBXGmtO05/yaXQziALuPogeG0b7UAgjnTJTQ==", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "^3.2.1", + "domutils": "^1.7.0", + "nth-check": "^1.0.2" + } + }, + "css-select-base-adapter": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", + "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==", + "dev": true + }, "css-selector-tokenizer": { "version": "0.7.3", "resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.7.3.tgz", @@ -3517,6 +3739,22 @@ "fastparse": "^1.1.2" } }, + "css-tree": { + "version": "1.0.0-alpha.37", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", + "integrity": "sha512-DMxWJg0rnz7UgxKT0Q1HU/L9BeJI0M6ksor0OgqOnF+aRCDWg/N2641HmVyU9KVIu0OVVWOb2IpC9A+BJRnejg==", + "dev": true, + "requires": { + "mdn-data": "2.0.4", + "source-map": "^0.6.1" + } + }, + "css-what": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-3.4.2.tgz", + "integrity": "sha512-ACUm3L0/jiZTqfzRM3Hi9Q8eZqd6IK37mMWPLz9PJxkLWllYeRf+EHUSHYEtFop2Eqytaq1FizFVh7XfBnXCDQ==", + "dev": true + }, "cssauron": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/cssauron/-/cssauron-1.4.0.tgz", @@ -3532,6 +3770,98 @@ "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", "dev": true }, + "cssnano-preset-default": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/cssnano-preset-default/-/cssnano-preset-default-4.0.7.tgz", + "integrity": "sha512-x0YHHx2h6p0fCl1zY9L9roD7rnlltugGu7zXSKQx6k2rYw0Hi3IqxcoAGF7u9Q5w1nt7vK0ulxV8Lo+EvllGsA==", + "dev": true, + "requires": { + "css-declaration-sorter": "^4.0.1", + "cssnano-util-raw-cache": "^4.0.1", + "postcss": "^7.0.0", + "postcss-calc": "^7.0.1", + "postcss-colormin": "^4.0.3", + "postcss-convert-values": "^4.0.1", + "postcss-discard-comments": "^4.0.2", + "postcss-discard-duplicates": "^4.0.2", + "postcss-discard-empty": "^4.0.1", + "postcss-discard-overridden": "^4.0.1", + "postcss-merge-longhand": "^4.0.11", + "postcss-merge-rules": "^4.0.3", + "postcss-minify-font-values": "^4.0.2", + "postcss-minify-gradients": "^4.0.2", + "postcss-minify-params": "^4.0.2", + "postcss-minify-selectors": "^4.0.2", + "postcss-normalize-charset": "^4.0.1", + "postcss-normalize-display-values": "^4.0.2", + "postcss-normalize-positions": "^4.0.2", + "postcss-normalize-repeat-style": "^4.0.2", + "postcss-normalize-string": "^4.0.2", + "postcss-normalize-timing-functions": "^4.0.2", + "postcss-normalize-unicode": "^4.0.1", + "postcss-normalize-url": "^4.0.1", + "postcss-normalize-whitespace": "^4.0.2", + "postcss-ordered-values": "^4.1.2", + "postcss-reduce-initial": "^4.0.3", + "postcss-reduce-transforms": "^4.0.2", + "postcss-svgo": "^4.0.2", + "postcss-unique-selectors": "^4.0.1" + } + }, + "cssnano-util-get-arguments": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cssnano-util-get-arguments/-/cssnano-util-get-arguments-4.0.0.tgz", + "integrity": "sha1-7ToIKZ8h11dBsg87gfGU7UnMFQ8=", + "dev": true + }, + "cssnano-util-get-match": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cssnano-util-get-match/-/cssnano-util-get-match-4.0.0.tgz", + "integrity": "sha1-wOTKB/U4a7F+xeUiULT1lhNlFW0=", + "dev": true + }, + "cssnano-util-raw-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/cssnano-util-raw-cache/-/cssnano-util-raw-cache-4.0.1.tgz", + "integrity": "sha512-qLuYtWK2b2Dy55I8ZX3ky1Z16WYsx544Q0UWViebptpwn/xDBmog2TLg4f+DBMg1rJ6JDWtn96WHbOKDWt1WQA==", + "dev": true, + "requires": { + "postcss": "^7.0.0" + } + }, + "cssnano-util-same-parent": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/cssnano-util-same-parent/-/cssnano-util-same-parent-4.0.1.tgz", + "integrity": "sha512-WcKx5OY+KoSIAxBW6UBBRay1U6vkYheCdjyVNDm85zt5K9mHoGOfsOsqIszfAqrQQFIIKgjh2+FDgIj/zsl21Q==", + "dev": true + }, + "csso": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/csso/-/csso-4.2.0.tgz", + "integrity": "sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA==", + "dev": true, + "requires": { + "css-tree": "^1.1.2" + }, + "dependencies": { + "css-tree": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.1.2.tgz", + "integrity": "sha512-wCoWush5Aeo48GLhfHPbmvZs59Z+M7k5+B1xDnXbdWNcEF423DoFdqSWE0PM5aNk5nI5cp1q7ms36zGApY/sKQ==", + "dev": true, + "requires": { + "mdn-data": "2.0.14", + "source-map": "^0.6.1" + } + }, + "mdn-data": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz", + "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==", + "dev": true + } + } + }, "cuint": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz", @@ -3610,6 +3940,12 @@ "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "dev": true }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, "defaults": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", @@ -3741,12 +4077,46 @@ "void-elements": "^2.0.0" } }, + "dom-serializer": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", + "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "entities": "^2.0.0" + }, + "dependencies": { + "domelementtype": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz", + "integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w==", + "dev": true + } + } + }, "domain-browser": { "version": "4.19.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-4.19.0.tgz", "integrity": "sha512-fRA+BaAWOR/yr/t7T9E9GJztHPeFjj8U35ajyAjCDtAAnTn1Rc1f6W6VGPJrO1tkQv9zWu+JRof7z6oQtiYVFQ==", "dev": true }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", + "dev": true + }, + "domutils": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz", + "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, "dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -3837,6 +4207,12 @@ "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", "dev": true }, + "entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true + }, "errno": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", @@ -4042,9 +4418,9 @@ "dev": true }, "estree-walker": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", - "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", "dev": true }, "esutils": { @@ -4167,12 +4543,6 @@ } } }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, "fastparse": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", @@ -4503,6 +4873,12 @@ "minimalistic-assert": "^1.0.1" } }, + "hex-color-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/hex-color-regex/-/hex-color-regex-1.1.0.tgz", + "integrity": "sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==", + "dev": true + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -4530,6 +4906,24 @@ "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", "dev": true }, + "hsl-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hsl-regex/-/hsl-regex-1.0.0.tgz", + "integrity": "sha1-1JMwx4ntgZ4nakwNJy3/owsY/m4=", + "dev": true + }, + "hsla-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hsla-regex/-/hsla-regex-1.0.0.tgz", + "integrity": "sha1-wc56MWjIxmFAM6S194d/OyJfnDg=", + "dev": true + }, + "html-comment-regex": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/html-comment-regex/-/html-comment-regex-1.1.2.tgz", + "integrity": "sha512-P+M65QY2JQ5Y0G9KKdlDpo0zK+/OHptU5AaBwUfAIDJZk1MYf32Frm84EcOytfJE0t5JvkAnKlmjsXDnWzCJmQ==", + "dev": true + }, "html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -4688,6 +5082,12 @@ "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", "dev": true }, + "indexes-of": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz", + "integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=", + "dev": true + }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", @@ -4723,14 +5123,6 @@ "dev": true, "requires": { "tslib": "^2.0.0" - }, - "dependencies": { - "tslib": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz", - "integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==", - "dev": true - } } }, "inline-source-map": { @@ -4765,6 +5157,12 @@ "integrity": "sha512-YqTdPLfwP7YFN0SsD3QUVCkm9ZG2VzOXv3DOrw5G5mkMbVwptTwVcFv7/C0vOpBmgTxAeTG19XpUs1E522LW9Q==", "dev": true }, + "is-absolute-url": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-2.1.0.tgz", + "integrity": "sha1-UFMN+4T8yap9vnhS6Do3uTufKqY=", + "dev": true + }, "is-arguments": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.0.tgz", @@ -4774,6 +5172,12 @@ "call-bind": "^1.0.0" } }, + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", + "dev": true + }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -4798,6 +5202,20 @@ "ci-info": "^2.0.0" } }, + "is-color-stop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-color-stop/-/is-color-stop-1.1.0.tgz", + "integrity": "sha1-z/9HGu5N1cnhWFmPvhKWe1za00U=", + "dev": true, + "requires": { + "css-color-names": "^0.0.4", + "hex-color-regex": "^1.1.0", + "hsl-regex": "^1.0.0", + "hsla-regex": "^1.0.0", + "rgb-regex": "^1.0.1", + "rgba-regex": "^1.0.0" + } + }, "is-core-module": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", @@ -4859,6 +5277,12 @@ "is-path-inside": "^3.0.1" } }, + "is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true + }, "is-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", @@ -4928,6 +5352,15 @@ "has-symbols": "^1.0.1" } }, + "is-svg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-svg/-/is-svg-3.0.0.tgz", + "integrity": "sha512-gi4iHK53LR2ujhLVVj+37Ykh9GLqYHX6JOVXbLAucaG/Cqw9xwdFOjDM2qeifLs1sF1npXXFvDu0r5HNgCMrzQ==", + "dev": true, + "requires": { + "html-comment-regex": "^1.1.0" + } + }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -4956,6 +5389,12 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, + "is-what": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.12.0.tgz", + "integrity": "sha512-2ilQz5/f/o9V7WRWJQmpFYNmQFZ9iM+OXRonZKcYgTkCzjb949Vi4h282PD1UfmgHk666rcWonbRJ++KI41VGw==", + "dev": true + }, "is-yarn-global": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz", @@ -5096,7 +5535,7 @@ }, "jsesc": { "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true }, @@ -5113,9 +5552,9 @@ "dev": true }, "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true }, "json-stringify-safe": { @@ -5648,17 +6087,19 @@ } }, "less": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/less/-/less-3.13.0.tgz", - "integrity": "sha512-uPhr9uoSGVKKYVGz0rXcYBK1zjwcIWRGcbnSgNt66XuIZYrYPaQiS+LeUOvqedBwrwdBYYaLqSff5ytGYuT7rA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/less/-/less-4.1.0.tgz", + "integrity": "sha512-w1Ag/f34g7LwtQ/sMVSGWIyZx+gG9ZOAEtyxeX1fG75is6BMyC2lD5kG+1RueX7PkAvlQBm2Lf2aN2j0JbVr2A==", "dev": true, "requires": { + "copy-anything": "^2.0.1", "errno": "^0.1.1", "graceful-fs": "^4.1.2", "image-size": "~0.5.0", "make-dir": "^2.1.0", "mime": "^1.4.1", - "native-request": "^1.0.5", + "needle": "^2.5.2", + "parse-node-version": "^1.0.1", "source-map": "~0.6.0", "tslib": "^1.10.0" }, @@ -5710,6 +6151,12 @@ "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, + "lodash.uniq": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", + "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=", + "dev": true + }, "log-symbols": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", @@ -5868,6 +6315,12 @@ "safe-buffer": "^5.1.2" } }, + "mdn-data": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.4.tgz", + "integrity": "sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==", + "dev": true + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -5995,6 +6448,12 @@ "dev": true, "optional": true }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -6068,12 +6527,36 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "native-request": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/native-request/-/native-request-1.0.8.tgz", - "integrity": "sha512-vU2JojJVelUGp6jRcLwToPoWGxSx23z/0iX+I77J3Ht17rf2INGjrhOoQnjVo60nQd8wVsgzKkPfRXBiVdD2ag==", + "needle": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.6.0.tgz", + "integrity": "sha512-KKYdza4heMsEfSWD7VPUIz3zX2XDwOyX2d+geb4vrERZMT5RMU6ujjaD+I5Yr54uZxQ2w6XRTAhHBbSCyovZBg==", "dev": true, - "optional": true + "optional": true, + "requires": { + "debug": "^3.2.6", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "optional": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "optional": true + } + } }, "negotiator": { "version": "0.6.2", @@ -6082,134 +6565,110 @@ "dev": true }, "ng-packagr": { - "version": "9.1.5", - "resolved": "https://registry.npmjs.org/ng-packagr/-/ng-packagr-9.1.5.tgz", - "integrity": "sha512-biuNfM15uLkCW+Vvj8bnuwjX37oX7j5icGm+l71FhM6ydlEl+Cl7PdFXpy9rrIlKFYlYRiPiiiWazGwVGn1icQ==", - "dev": true, - "requires": { - "@rollup/plugin-commonjs": "^11.0.2", - "@rollup/plugin-json": "^4.0.0", - "@rollup/plugin-node-resolve": "^7.1.0", - "ajv": "^6.10.2", - "autoprefixer": "^9.7.6", - "browserslist": "^4.12.0", - "chalk": "^4.0.0", - "chokidar": "^3.2.1", - "clean-css": "^4.1.11", - "commander": "^4.0.0", - "fs-extra": "^9.0.0", - "glob": "^7.1.2", - "injection-js": "^2.2.1", - "less": "^3.10.3", - "node-sass-tilde-importer": "^1.0.0", - "postcss": "^7.0.18", + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/ng-packagr/-/ng-packagr-11.1.2.tgz", + "integrity": "sha512-Ud6DJC4eiiQHDUi3BegW50gJfvUfbXTu9fqR/Hhj0s42PLDOfGzbIAFhz8AhiDNdzptZTsinITvESuKj12CIAA==", + "dev": true, + "requires": { + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^11.1.0", + "ajv": "^7.0.3", + "ansi-colors": "^4.1.1", + "autoprefixer": "^9.6.5", + "browserslist": "^4.16.1", + "chokidar": "^3.5.1", + "commander": "^7.0.0", + "cssnano-preset-default": "^4.0.7", + "glob": "^7.1.6", + "injection-js": "^2.4.0", + "less": "^4.1.0", + "node-sass-tilde-importer": "^1.0.2", + "ora": "^5.1.0", + "postcss": "^7.0.29", "postcss-url": "^8.0.0", "read-pkg-up": "^5.0.0", "rimraf": "^3.0.0", - "rollup": "2.7.5", - "rollup-plugin-sourcemaps": "^0.6.0", + "rollup": "^2.37.0", + "rollup-plugin-sourcemaps": "^0.6.3", "rxjs": "^6.5.0", - "sass": "^1.23.0", - "stylus": "^0.54.7", - "terser": "^4.3.8", - "update-notifier": "^4.0.0" + "sass": "^1.32.5", + "stylus": "^0.54.8", + "terser": "^5.5.1" }, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "browserslist": { + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.1.tgz", + "integrity": "sha512-UXhDrwqsNcpTYJBTZsbGATDxZbiVDsx6UjpmRUmtnP10pr8wAYr5LgFoEFw9ixriQH2mv/NX2SfGzE/o8GndLA==", "dev": true, "requires": { - "color-name": "~1.1.4" + "caniuse-lite": "^1.0.30001173", + "colorette": "^1.2.1", + "electron-to-chromium": "^1.3.634", + "escalade": "^3.1.1", + "node-releases": "^1.1.69" } }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "caniuse-lite": { + "version": "1.0.30001179", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001179.tgz", + "integrity": "sha512-blMmO0QQujuUWZKyVrD1msR4WNDAqb/UPO1Sw2WWsQ7deoM5bJiicKnWJ1Y0NS/aGINSnKPIWBMw5luX+NDUCA==", "dev": true }, - "fs-extra": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz", - "integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==", + "chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", "dev": true, "requires": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^1.0.0" + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.3.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" } }, - "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", + "commander": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.0.0.tgz", + "integrity": "sha512-ovx/7NkTrnPuIV8sqk/GjUIIM1+iUQeqA3ye2VNpq9sVoiZsooObWlQy+OPWGI17GDaEoybuAGJm6U8yC077BA==", "dev": true }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "electron-to-chromium": { + "version": "1.3.645", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.645.tgz", + "integrity": "sha512-T7mYop3aDpRHIQaUYcmzmh6j9MAe560n6ukqjJMbVC6bVTau7dSpvB18bcsBPPtOSe10cKxhJFtlbEzLa0LL1g==", "dev": true }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "fsevents": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.1.tgz", + "integrity": "sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw==", "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - }, - "dependencies": { - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - } - } + "optional": true }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { - "has-flag": "^4.0.0" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, - "universalify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", - "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", + "node-releases": { + "version": "1.1.70", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.70.tgz", + "integrity": "sha512-Slf2s69+2/uAD79pVVQo8uSiC34+g8GWY8UH2Qtqv34ZfhYrxpYpfzs9Js9d6O0mbDmALuxaTlplnBTnSELcrw==", "dev": true } } @@ -6271,6 +6730,21 @@ "integrity": "sha1-LRDAa9/TEuqXd2laTShDlFa3WUI=", "dev": true }, + "normalize-url": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-3.3.0.tgz", + "integrity": "sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==", + "dev": true + }, + "nth-check": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", + "dev": true, + "requires": { + "boolbase": "~1.0.0" + } + }, "num2fraction": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz", @@ -6317,6 +6791,29 @@ "object-keys": "^1.1.1" } }, + "object.getownpropertydescriptors": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.1.tgz", + "integrity": "sha512-6DtXgZ/lIZ9hqx4GtZETobXLR/ZLaa0aqV0kzbn80Rf8Z2e/XFnhA0I7p07N2wH8bBBltr2xQPi6sbKWAY2Eng==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "es-abstract": "^1.18.0-next.1" + } + }, + "object.values": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.2.tgz", + "integrity": "sha512-MYC0jvJopr8EK6dPBiO8Nb9mvjdypOachO5REGk6MXzujbBrAisKo3HmdEI6kZDL6fC31Mwee/5YbtMebixeag==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "es-abstract": "^1.18.0-next.1", + "has": "^1.0.3" + } + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -6335,73 +6832,164 @@ "wrappy": "1" } }, - "os-browserify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", - "dev": true - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, - "p-cancelable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", - "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", - "dev": true - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, "requires": { - "p-limit": "^2.0.0" + "mimic-fn": "^2.1.0" } }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "package-json": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.5.0.tgz", - "integrity": "sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==", + "ora": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.3.0.tgz", + "integrity": "sha512-zAKMgGXUim0Jyd6CXK9lraBnD3H5yPGBPPOkC23a2BG6hsm4Zu6OQSjQuEtV0BHDf4aKHcUFvJiGRrFuW3MG8g==", "dev": true, "requires": { - "got": "^9.6.0", - "registry-auth-token": "^4.0.0", - "registry-url": "^5.0.0", - "semver": "^6.2.0" + "bl": "^4.0.3", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "log-symbols": "^4.0.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" }, "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true - } - } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", + "dev": true + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "p-cancelable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", + "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", + "dev": true + }, + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "package-json": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.5.0.tgz", + "integrity": "sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==", + "dev": true, + "requires": { + "got": "^9.6.0", + "registry-auth-token": "^4.0.0", + "registry-url": "^5.0.0", + "semver": "^6.2.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } }, "pad": { "version": "3.2.0", @@ -6443,6 +7031,12 @@ "lines-and-columns": "^1.1.6" } }, + "parse-node-version": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", + "dev": true + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -6536,6 +7130,481 @@ } } }, + "postcss-calc": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-7.0.5.tgz", + "integrity": "sha512-1tKHutbGtLtEZF6PT4JSihCHfIVldU72mZ8SdZHIYriIZ9fh9k9aWSppaT8rHsyI3dX+KSR+W+Ix9BMY3AODrg==", + "dev": true, + "requires": { + "postcss": "^7.0.27", + "postcss-selector-parser": "^6.0.2", + "postcss-value-parser": "^4.0.2" + } + }, + "postcss-colormin": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/postcss-colormin/-/postcss-colormin-4.0.3.tgz", + "integrity": "sha512-WyQFAdDZpExQh32j0U0feWisZ0dmOtPl44qYmJKkq9xFWY3p+4qnRzCHeNrkeRhwPHz9bQ3mo0/yVkaply0MNw==", + "dev": true, + "requires": { + "browserslist": "^4.0.0", + "color": "^3.0.0", + "has": "^1.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-convert-values": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-convert-values/-/postcss-convert-values-4.0.1.tgz", + "integrity": "sha512-Kisdo1y77KUC0Jmn0OXU/COOJbzM8cImvw1ZFsBgBgMgb1iL23Zs/LXRe3r+EZqM3vGYKdQ2YJVQ5VkJI+zEJQ==", + "dev": true, + "requires": { + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-discard-comments": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-4.0.2.tgz", + "integrity": "sha512-RJutN259iuRf3IW7GZyLM5Sw4GLTOH8FmsXBnv8Ab/Tc2k4SR4qbV4DNbyyY4+Sjo362SyDmW2DQ7lBSChrpkg==", + "dev": true, + "requires": { + "postcss": "^7.0.0" + } + }, + "postcss-discard-duplicates": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-4.0.2.tgz", + "integrity": "sha512-ZNQfR1gPNAiXZhgENFfEglF93pciw0WxMkJeVmw8eF+JZBbMD7jp6C67GqJAXVZP2BWbOztKfbsdmMp/k8c6oQ==", + "dev": true, + "requires": { + "postcss": "^7.0.0" + } + }, + "postcss-discard-empty": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-4.0.1.tgz", + "integrity": "sha512-B9miTzbznhDjTfjvipfHoqbWKwd0Mj+/fL5s1QOz06wufguil+Xheo4XpOnc4NqKYBCNqqEzgPv2aPBIJLox0w==", + "dev": true, + "requires": { + "postcss": "^7.0.0" + } + }, + "postcss-discard-overridden": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-4.0.1.tgz", + "integrity": "sha512-IYY2bEDD7g1XM1IDEsUT4//iEYCxAmP5oDSFMVU/JVvT7gh+l4fmjciLqGgwjdWpQIdb0Che2VX00QObS5+cTg==", + "dev": true, + "requires": { + "postcss": "^7.0.0" + } + }, + "postcss-merge-longhand": { + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/postcss-merge-longhand/-/postcss-merge-longhand-4.0.11.tgz", + "integrity": "sha512-alx/zmoeXvJjp7L4mxEMjh8lxVlDFX1gqWHzaaQewwMZiVhLo42TEClKaeHbRf6J7j82ZOdTJ808RtN0ZOZwvw==", + "dev": true, + "requires": { + "css-color-names": "0.0.4", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0", + "stylehacks": "^4.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-merge-rules": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/postcss-merge-rules/-/postcss-merge-rules-4.0.3.tgz", + "integrity": "sha512-U7e3r1SbvYzO0Jr3UT/zKBVgYYyhAz0aitvGIYOYK5CPmkNih+WDSsS5tvPrJ8YMQYlEMvsZIiqmn7HdFUaeEQ==", + "dev": true, + "requires": { + "browserslist": "^4.0.0", + "caniuse-api": "^3.0.0", + "cssnano-util-same-parent": "^4.0.0", + "postcss": "^7.0.0", + "postcss-selector-parser": "^3.0.0", + "vendors": "^1.0.0" + }, + "dependencies": { + "postcss-selector-parser": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-3.1.2.tgz", + "integrity": "sha512-h7fJ/5uWuRVyOtkO45pnt1Ih40CEleeyCHzipqAZO2e5H20g25Y48uYnFUiShvY4rZWNJ/Bib/KVPmanaCtOhA==", + "dev": true, + "requires": { + "dot-prop": "^5.2.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1" + } + } + } + }, + "postcss-minify-font-values": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-minify-font-values/-/postcss-minify-font-values-4.0.2.tgz", + "integrity": "sha512-j85oO6OnRU9zPf04+PZv1LYIYOprWm6IA6zkXkrJXyRveDEuQggG6tvoy8ir8ZwjLxLuGfNkCZEQG7zan+Hbtg==", + "dev": true, + "requires": { + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-minify-gradients": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-minify-gradients/-/postcss-minify-gradients-4.0.2.tgz", + "integrity": "sha512-qKPfwlONdcf/AndP1U8SJ/uzIJtowHlMaSioKzebAXSG4iJthlWC9iSWznQcX4f66gIWX44RSA841HTHj3wK+Q==", + "dev": true, + "requires": { + "cssnano-util-get-arguments": "^4.0.0", + "is-color-stop": "^1.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-minify-params": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-minify-params/-/postcss-minify-params-4.0.2.tgz", + "integrity": "sha512-G7eWyzEx0xL4/wiBBJxJOz48zAKV2WG3iZOqVhPet/9geefm/Px5uo1fzlHu+DOjT+m0Mmiz3jkQzVHe6wxAWg==", + "dev": true, + "requires": { + "alphanum-sort": "^1.0.0", + "browserslist": "^4.0.0", + "cssnano-util-get-arguments": "^4.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0", + "uniqs": "^2.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-minify-selectors": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-minify-selectors/-/postcss-minify-selectors-4.0.2.tgz", + "integrity": "sha512-D5S1iViljXBj9kflQo4YutWnJmwm8VvIsU1GeXJGiG9j8CIg9zs4voPMdQDUmIxetUOh60VilsNzCiAFTOqu3g==", + "dev": true, + "requires": { + "alphanum-sort": "^1.0.0", + "has": "^1.0.0", + "postcss": "^7.0.0", + "postcss-selector-parser": "^3.0.0" + }, + "dependencies": { + "postcss-selector-parser": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-3.1.2.tgz", + "integrity": "sha512-h7fJ/5uWuRVyOtkO45pnt1Ih40CEleeyCHzipqAZO2e5H20g25Y48uYnFUiShvY4rZWNJ/Bib/KVPmanaCtOhA==", + "dev": true, + "requires": { + "dot-prop": "^5.2.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1" + } + } + } + }, + "postcss-normalize-charset": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-4.0.1.tgz", + "integrity": "sha512-gMXCrrlWh6G27U0hF3vNvR3w8I1s2wOBILvA87iNXaPvSNo5uZAMYsZG7XjCUf1eVxuPfyL4TJ7++SGZLc9A3g==", + "dev": true, + "requires": { + "postcss": "^7.0.0" + } + }, + "postcss-normalize-display-values": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-display-values/-/postcss-normalize-display-values-4.0.2.tgz", + "integrity": "sha512-3F2jcsaMW7+VtRMAqf/3m4cPFhPD3EFRgNs18u+k3lTJJlVe7d0YPO+bnwqo2xg8YiRpDXJI2u8A0wqJxMsQuQ==", + "dev": true, + "requires": { + "cssnano-util-get-match": "^4.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-normalize-positions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-positions/-/postcss-normalize-positions-4.0.2.tgz", + "integrity": "sha512-Dlf3/9AxpxE+NF1fJxYDeggi5WwV35MXGFnnoccP/9qDtFrTArZ0D0R+iKcg5WsUd8nUYMIl8yXDCtcrT8JrdA==", + "dev": true, + "requires": { + "cssnano-util-get-arguments": "^4.0.0", + "has": "^1.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-normalize-repeat-style": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-repeat-style/-/postcss-normalize-repeat-style-4.0.2.tgz", + "integrity": "sha512-qvigdYYMpSuoFs3Is/f5nHdRLJN/ITA7huIoCyqqENJe9PvPmLhNLMu7QTjPdtnVf6OcYYO5SHonx4+fbJE1+Q==", + "dev": true, + "requires": { + "cssnano-util-get-arguments": "^4.0.0", + "cssnano-util-get-match": "^4.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-normalize-string": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-string/-/postcss-normalize-string-4.0.2.tgz", + "integrity": "sha512-RrERod97Dnwqq49WNz8qo66ps0swYZDSb6rM57kN2J+aoyEAJfZ6bMx0sx/F9TIEX0xthPGCmeyiam/jXif0eA==", + "dev": true, + "requires": { + "has": "^1.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-normalize-timing-functions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-timing-functions/-/postcss-normalize-timing-functions-4.0.2.tgz", + "integrity": "sha512-acwJY95edP762e++00Ehq9L4sZCEcOPyaHwoaFOhIwWCDfik6YvqsYNxckee65JHLKzuNSSmAdxwD2Cud1Z54A==", + "dev": true, + "requires": { + "cssnano-util-get-match": "^4.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-normalize-unicode": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-normalize-unicode/-/postcss-normalize-unicode-4.0.1.tgz", + "integrity": "sha512-od18Uq2wCYn+vZ/qCOeutvHjB5jm57ToxRaMeNuf0nWVHaP9Hua56QyMF6fs/4FSUnVIw0CBPsU0K4LnBPwYwg==", + "dev": true, + "requires": { + "browserslist": "^4.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-normalize-url": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-normalize-url/-/postcss-normalize-url-4.0.1.tgz", + "integrity": "sha512-p5oVaF4+IHwu7VpMan/SSpmpYxcJMtkGppYf0VbdH5B6hN8YNmVyJLuY9FmLQTzY3fag5ESUUHDqM+heid0UVA==", + "dev": true, + "requires": { + "is-absolute-url": "^2.0.0", + "normalize-url": "^3.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-normalize-whitespace": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-whitespace/-/postcss-normalize-whitespace-4.0.2.tgz", + "integrity": "sha512-tO8QIgrsI3p95r8fyqKV+ufKlSHh9hMJqACqbv2XknufqEDhDvbguXGBBqxw9nsQoXWf0qOqppziKJKHMD4GtA==", + "dev": true, + "requires": { + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-ordered-values": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/postcss-ordered-values/-/postcss-ordered-values-4.1.2.tgz", + "integrity": "sha512-2fCObh5UanxvSxeXrtLtlwVThBvHn6MQcu4ksNT2tsaV2Fg76R2CV98W7wNSlX+5/pFwEyaDwKLLoEV7uRybAw==", + "dev": true, + "requires": { + "cssnano-util-get-arguments": "^4.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-reduce-initial": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/postcss-reduce-initial/-/postcss-reduce-initial-4.0.3.tgz", + "integrity": "sha512-gKWmR5aUulSjbzOfD9AlJiHCGH6AEVLaM0AV+aSioxUDd16qXP1PCh8d1/BGVvpdWn8k/HiK7n6TjeoXN1F7DA==", + "dev": true, + "requires": { + "browserslist": "^4.0.0", + "caniuse-api": "^3.0.0", + "has": "^1.0.0", + "postcss": "^7.0.0" + } + }, + "postcss-reduce-transforms": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-reduce-transforms/-/postcss-reduce-transforms-4.0.2.tgz", + "integrity": "sha512-EEVig1Q2QJ4ELpJXMZR8Vt5DQx8/mo+dGWSR7vWXqcob2gQLyQGsionYcGKATXvQzMPn6DSN1vTN7yFximdIAg==", + "dev": true, + "requires": { + "cssnano-util-get-match": "^4.0.0", + "has": "^1.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-selector-parser": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.4.tgz", + "integrity": "sha512-gjMeXBempyInaBqpp8gODmwZ52WaYsVOsfr4L4lDQ7n3ncD6mEyySiDtgzCT+NYC0mmeOLvtsF8iaEf0YT6dBw==", + "dev": true, + "requires": { + "cssesc": "^3.0.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1", + "util-deprecate": "^1.0.2" + } + }, + "postcss-svgo": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-4.0.2.tgz", + "integrity": "sha512-C6wyjo3VwFm0QgBy+Fu7gCYOkCmgmClghO+pjcxvrcBKtiKt0uCF+hvbMO1fyv5BMImRK90SMb+dwUnfbGd+jw==", + "dev": true, + "requires": { + "is-svg": "^3.0.0", + "postcss": "^7.0.0", + "postcss-value-parser": "^3.0.0", + "svgo": "^1.0.0" + }, + "dependencies": { + "postcss-value-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", + "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "dev": true + } + } + }, + "postcss-unique-selectors": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-unique-selectors/-/postcss-unique-selectors-4.0.1.tgz", + "integrity": "sha512-+JanVaryLo9QwZjKrmJgkI4Fn8SBgRO6WXQBJi7KiAVPlmxikB5Jzc4EvXMT2H0/m0RjrVVm9rGNhZddm/8Spg==", + "dev": true, + "requires": { + "alphanum-sort": "^1.0.0", + "postcss": "^7.0.0", + "uniqs": "^2.0.0" + } + }, "postcss-url": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/postcss-url/-/postcss-url-8.0.0.tgz", @@ -6550,9 +7619,9 @@ }, "dependencies": { "mime": { - "version": "2.4.7", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.7.tgz", - "integrity": "sha512-dhNd1uA2u397uQk3Nv5LM4lm93WYDUXFn3Fu291FJerns4jyTudqhIWe4W04YLy7Uk1tm1Ore04NpjRvQp/NPA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.0.tgz", + "integrity": "sha512-ft3WayFSFUVBuJj7BMLKAQcSlItKtfjsKDDsii3rqFDAZ7t11zRe8ASw/GlmivGwVUYtwkQrxiGGpL6gFvB0ag==", "dev": true } } @@ -6641,6 +7710,12 @@ "escape-goat": "^2.0.0" } }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + }, "qjobs": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", @@ -6736,6 +7811,17 @@ "read-pkg": "^5.0.0" } }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, "readdirp": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", @@ -6880,6 +7966,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -6917,6 +8009,16 @@ "lowercase-keys": "^1.0.0" } }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -6929,6 +8031,18 @@ "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==", "dev": true }, + "rgb-regex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rgb-regex/-/rgb-regex-1.0.1.tgz", + "integrity": "sha1-wODWiC3w4jviVKR16O3UGRX+rrE=", + "dev": true + }, + "rgba-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/rgba-regex/-/rgba-regex-1.0.0.tgz", + "integrity": "sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=", + "dev": true + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -6949,9 +8063,9 @@ } }, "rollup": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.7.5.tgz", - "integrity": "sha512-xQSM8uzhgtF6tTnTVEvOQThrcG3LPUP3T/4l4EukzDp0kbTY1QRDuXjiwtYzs9odKj9Bj/PccRG6viFfS7DmCQ==", + "version": "2.38.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.38.0.tgz", + "integrity": "sha512-ay9zDiNitZK/LNE/EM2+v5CZ7drkB2xyDljvb1fQJCGnq43ZWRkhxN145oV8GmoW1YNi4sA/1Jdkr2LfawJoXw==", "dev": true, "requires": { "fsevents": "~2.1.2" @@ -6980,6 +8094,14 @@ "dev": true, "requires": { "tslib": "^1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + } } }, "safe-buffer": { @@ -6995,9 +8117,9 @@ "dev": true }, "sass": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.30.0.tgz", - "integrity": "sha512-26EUhOXRLaUY7+mWuRFqGeGGNmhB1vblpTENO1Z7mAzzIZeVxZr9EZoaY1kyGLFWdSOZxRMAufiN2mkbO6dAlw==", + "version": "1.32.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.5.tgz", + "integrity": "sha512-kU1yJ5zUAmPxr7f3q0YXTAd1oZjSR1g3tYyv+xu0HZSl5JiNOaE987eiz7wCUvbm4I9fGWGU2TgApTtcP4GMNQ==", "dev": true, "requires": { "chokidar": ">=2.0.0 <4.0.0" @@ -7090,6 +8212,15 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "dev": true, + "requires": { + "is-arrayish": "^0.3.1" + } + }, "slash": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", @@ -7377,6 +8508,12 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "stable": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", + "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", + "dev": true + }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -7553,7 +8690,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -7590,6 +8727,30 @@ "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=", "dev": true }, + "stylehacks": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-4.0.3.tgz", + "integrity": "sha512-7GlLk9JwlElY4Y6a/rmbH2MhVlTyVmiJd1PfTCqFaIBEGMYNsrO/v3SeGTdhBThLg4Z+NbOk/qFMwCa+J+3p/g==", + "dev": true, + "requires": { + "browserslist": "^4.0.0", + "postcss": "^7.0.0", + "postcss-selector-parser": "^3.0.0" + }, + "dependencies": { + "postcss-selector-parser": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-3.1.2.tgz", + "integrity": "sha512-h7fJ/5uWuRVyOtkO45pnt1Ih40CEleeyCHzipqAZO2e5H20g25Y48uYnFUiShvY4rZWNJ/Bib/KVPmanaCtOhA==", + "dev": true, + "requires": { + "dot-prop": "^5.2.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1" + } + } + } + }, "stylus": { "version": "0.54.8", "resolved": "https://registry.npmjs.org/stylus/-/stylus-0.54.8.tgz", @@ -7685,6 +8846,27 @@ } } }, + "svgo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-1.3.2.tgz", + "integrity": "sha512-yhy/sQYxR5BkC98CY7o31VGsg014AKLEPxdfhora76l36hD9Rdy5NZA/Ocn6yayNPgSamYdtX2rFJdcv07AYVw==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "coa": "^2.0.2", + "css-select": "^2.0.0", + "css-select-base-adapter": "^0.1.1", + "css-tree": "1.0.0-alpha.37", + "csso": "^4.0.2", + "js-yaml": "^3.13.1", + "mkdirp": "~0.5.1", + "object.values": "^1.1.0", + "sax": "~1.2.4", + "stable": "^0.1.8", + "unquote": "~1.1.1", + "util.promisify": "~1.0.0" + } + }, "teeny-request": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-6.0.1.tgz", @@ -7705,16 +8887,22 @@ "dev": true }, "terser": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", - "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.5.1.tgz", + "integrity": "sha512-6VGWZNVP2KTUcltUQJ25TtNjx/XgdDsBDKGt8nN0MpydU36LmbPPcMBd2kmtZNNGVVDLg44k7GKeHHj+4zPIBQ==", "dev": true, "requires": { "commander": "^2.20.0", - "source-map": "~0.6.1", - "source-map-support": "~0.5.12" + "source-map": "~0.7.2", + "source-map-support": "~0.5.19" }, "dependencies": { + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true + }, "source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -7723,6 +8911,14 @@ "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } } } @@ -7742,6 +8938,12 @@ "setimmediate": "^1.0.4" } }, + "timsort": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", + "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", + "dev": true + }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -7875,15 +9077,15 @@ } }, "tsickle": { - "version": "0.38.1", - "resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.38.1.tgz", - "integrity": "sha512-4xZfvC6+etRu6ivKCNqMOd1FqcY/m6JY3Y+yr5+Xw+i751ciwrWINi6x/3l1ekcODH9GZhlf0ny2LpzWxnjWYA==", + "version": "0.39.1", + "resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.39.1.tgz", + "integrity": "sha512-CCc9cZhZbKoNizVM+K3Uqgit/go8GacjpqTv1cpwG/n2P0gB9GMoWZbxrUULDE9Wz26Lh86CGf6QyIPUVV1lnQ==", "dev": true }, "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", "dev": true }, "tslint": { @@ -7912,6 +9114,12 @@ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true + }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true } } }, @@ -7950,6 +9158,14 @@ "dev": true, "requires": { "tslib": "^1.8.1" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + } } }, "tty-browserify": { @@ -8001,9 +9217,9 @@ } }, "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", + "integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==", "dev": true }, "ua-parser-js": { @@ -8040,6 +9256,18 @@ "integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==", "dev": true }, + "uniq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", + "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", + "dev": true + }, + "uniqs": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/uniqs/-/uniqs-2.0.0.tgz", + "integrity": "sha1-/+3ks2slKQaW5uFl1KWe25mOawI=", + "dev": true + }, "unique-string": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", @@ -8061,6 +9289,12 @@ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, + "unquote": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unquote/-/unquote-1.1.1.tgz", + "integrity": "sha1-j97XMk7G6IoP+LkF58CYzcCG1UQ=", + "dev": true + }, "update-notifier": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-4.1.3.tgz", @@ -8134,9 +9368,9 @@ } }, "uri-js": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz", - "integrity": "sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "requires": { "punycode": "^2.1.0" @@ -8201,6 +9435,39 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "util.promisify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.1.tgz", + "integrity": "sha512-g9JpC/3He3bm38zsLupWryXHoEcS22YHthuPQSJdMy6KNrzIRzWqcsHzD/WUnqe45whVou4VIsPew37DoXWNrA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.2", + "has-symbols": "^1.0.1", + "object.getownpropertydescriptors": "^2.1.0" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", + "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.2", + "is-regex": "^1.1.1", + "object-inspect": "^1.8.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.1", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + } + } + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -8223,6 +9490,12 @@ "spdx-expression-parse": "^3.0.0" } }, + "vendors": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.4.tgz", + "integrity": "sha512-/juG65kTL4Cy2su4P8HjtkTxk6VmJDiOPBufWniqQ6wknac6jNiXS9vU+hO3wgusiyqWlzTbVHi0dyJqRONg3w==", + "dev": true + }, "vm-browserify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", diff --git a/package.json b/package.json index a3c8dccd..cf3854d1 100644 --- a/package.json +++ b/package.json @@ -47,21 +47,21 @@ ], "license": "MIT", "peerDependencies": { - "@angular/core": ">=9.0.0", - "@angular/common": ">=9.0.0", - "@angular/forms": ">=9.0.0", - "@ngrx/store": ">=9.0.0", - "typescript": ">=3.8.3" + "@angular/core": ">=11.0.0", + "@angular/common": ">=11.0.0", + "@angular/forms": ">=11.0.0", + "@ngrx/store": ">=11.0.0-beta.1", + "typescript": ">=4.0.0" }, "devDependencies": { - "@angular/common": "9.1.13", - "@angular/compiler": "9.1.13", - "@angular/compiler-cli": "9.1.13", - "@angular/core": "9.1.13", - "@angular/forms": "9.1.13", - "@angular/platform-browser": "9.1.13", - "@angular/platform-browser-dynamic": "9.1.13", - "@ngrx/store": "9.2.0", + "@angular/common": "11.1.0", + "@angular/compiler": "11.1.0", + "@angular/compiler-cli": "11.1.0", + "@angular/core": "11.1.0", + "@angular/forms": "11.1.0", + "@angular/platform-browser": "11.1.0", + "@angular/platform-browser-dynamic": "11.1.0", + "@ngrx/store": "11.0.0-beta.1", "@types/jasmine": "3.5.11", "@types/node": "14.14.14", "codecov": "3.8.1", @@ -75,16 +75,16 @@ "karma-spec-reporter": "0.0.32", "karma-typescript": "5.2.0", "karma-typescript-es6-transform": "5.2.0", - "ng-packagr": "9.1.5", + "ng-packagr": "11.1.2", "reflect-metadata": "0.1.13", "rimraf": "3.0.2", "rxjs": "6.6.3", "tsd": "0.14.0", - "tsickle": "0.38.1", - "tslib": "1.14.1", + "tsickle": "0.39.1", + "tslib": "2.1.0", "tslint": "5.20.1", "tslint-eslint-rules": "5.4.0", - "typescript": "3.8.3", + "typescript": "4.1.3", "zone.js": "0.10.3" } } diff --git a/src/actions.spec.ts b/src/actions.spec.ts index 3f918998..c6544361 100644 --- a/src/actions.spec.ts +++ b/src/actions.spec.ts @@ -2,15 +2,15 @@ import { isNgrxFormsAction } from './actions'; describe(isNgrxFormsAction.name, () => { it('should return true if type is ngrx/forms/', () => { - expect(isNgrxFormsAction({ type: 'ngrx/forms/' })).toBe(true); + expect(isNgrxFormsAction({ type: 'ngrx/forms/' } as any)).toBe(true); }); it('should return true if type startsWith ngrx/forms/', () => { - expect(isNgrxFormsAction({ type: 'ngrx/forms/test' })).toBe(true); + expect(isNgrxFormsAction({ type: 'ngrx/forms/test' } as any)).toBe(true); }); it('should return false if type does not have ngrx/forms/', () => { - expect(isNgrxFormsAction({ type: 'some-type' })).toBe(false); + expect(isNgrxFormsAction({ type: 'some-type' } as any)).toBe(false); }); it('should return false if type is missing', () => { diff --git a/src/actions.ts b/src/actions.ts index bae8366e..cde4eef9 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,287 +1,137 @@ -import { Action } from '@ngrx/store'; +import { createAction, union} from '@ngrx/store'; import { KeyValue, NgrxFormControlId, ValidationErrors } from './state'; -// NOTE: the explicit type declaration for the `TYPE` properties is required -// for the output declarations to properly use the literal string type instead -// of just `string` - -export class SetValueAction implements Action { - static readonly TYPE: 'ngrx/forms/SET_VALUE' = 'ngrx/forms/SET_VALUE'; - readonly type = SetValueAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - public readonly value: TValue, - ) { } -} - -export class SetErrorsAction implements Action { - static readonly TYPE: 'ngrx/forms/SET_ERRORS' = 'ngrx/forms/SET_ERRORS'; - readonly type = SetErrorsAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - public readonly errors: ValidationErrors, - ) { } -} - -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: NgrxFormControlId, - public readonly name: string, - public readonly value: any, - ) { } -} - -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: NgrxFormControlId, - public readonly name: string, - ) { } -} - -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: NgrxFormControlId, - public readonly name: string, - ) { } -} - -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: NgrxFormControlId, - ) { } -} - -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: NgrxFormControlId, - ) { } -} - -export class EnableAction implements Action { - static readonly TYPE: 'ngrx/forms/ENABLE' = 'ngrx/forms/ENABLE'; - readonly type = EnableAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - ) { } -} - -export class DisableAction implements Action { - static readonly TYPE: 'ngrx/forms/DISABLE' = 'ngrx/forms/DISABLE'; - readonly type = DisableAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - ) { } -} - -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: NgrxFormControlId, - ) { } -} - -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: NgrxFormControlId, - ) { } -} - -export class FocusAction implements Action { - static readonly TYPE: 'ngrx/forms/FOCUS' = 'ngrx/forms/FOCUS'; - readonly type = FocusAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - ) { } -} - -export class UnfocusAction implements Action { - static readonly TYPE: 'ngrx/forms/UNFOCUS' = 'ngrx/forms/UNFOCUS'; - readonly type = UnfocusAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - ) { } -} - -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: NgrxFormControlId, - ) { } -} - -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: NgrxFormControlId, - ) { } -} - -export class AddArrayControlAction implements Action { - static readonly TYPE: 'ngrx/forms/ADD_ARRAY_CONTROL' = 'ngrx/forms/ADD_ARRAY_CONTROL'; - readonly type = AddArrayControlAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - public readonly value: TValue, - public readonly index?: number, - ) { } -} - -export class AddGroupControlAction implements Action { - static readonly TYPE: 'ngrx/forms/ADD_GROUP_CONTROL' = 'ngrx/forms/ADD_GROUP_CONTROL'; - readonly type = AddGroupControlAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - public readonly name: keyof TValue, - public readonly value: TValue[TControlKey], - ) { } -} - -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: NgrxFormControlId, - public readonly index: number, - ) { } -} - -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: NgrxFormControlId, - public readonly fromIndex: number, - public readonly toIndex: number - ) { } -} - -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: NgrxFormControlId, - public readonly fromIndex: number, - public readonly toIndex: number - ) { } -} - -export class RemoveGroupControlAction implements Action { - static readonly TYPE: 'ngrx/forms/REMOVE_CONTROL' = 'ngrx/forms/REMOVE_CONTROL'; - readonly type = RemoveGroupControlAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - public readonly name: keyof TValue, - ) { } -} - -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: NgrxFormControlId, - public readonly name: string, - public readonly value: any, - ) { } -} - -export class ResetAction implements Action { - static readonly TYPE: 'ngrx/forms/RESET' = 'ngrx/forms/RESET'; - readonly type = ResetAction.TYPE; - - constructor( - public readonly controlId: NgrxFormControlId, - ) { } -} - -export type Actions = - | SetValueAction - | SetErrorsAction - | SetAsyncErrorAction - | ClearAsyncErrorAction - | StartAsyncValidationAction - | MarkAsDirtyAction - | MarkAsPristineAction - | EnableAction - | DisableAction - | MarkAsTouchedAction - | MarkAsUntouchedAction - | FocusAction - | UnfocusAction - | MarkAsSubmittedAction - | MarkAsUnsubmittedAction - | AddGroupControlAction - | RemoveGroupControlAction - | AddArrayControlAction - | RemoveArrayControlAction - | SetUserDefinedPropertyAction - | ResetAction - | SwapArrayControlAction - | MoveArrayControlAction - ; - -export function isNgrxFormsAction(action: Action) { +// Enum for the ngrx/forms actions, internal use only +enum NGRX_FORMS_ACTION_TYPES { + SetValueActionType = 'ngrx/forms/SET_VALUE', + SetErrorsActionType = 'ngrx/forms/SET_ERRORS', + SetAsyncErrorActionType = 'ngrx/forms/SET_ASYNC_ERROR', + ClearAsyncErrorActionType = 'ngrx/forms/CLEAR_ASYNC_ERROR', + StartAsyncValidationActionType = 'ngrx/forms/START_ASYNC_VALIDATION', + MarkAsDirtyActionType = 'ngrx/forms/MARK_AS_DIRTY', + MarkAsPristineActionType = 'ngrx/forms/MARK_AS_PRISTINE', + EnableActionType = 'ngrx/forms/ENABLE', + DisableActionType = 'ngrx/forms/DISABLE', + MarkAsTouchedActionType = 'ngrx/forms/MARK_AS_TOUCHED', + MarkAsUntouchedActionType = 'ngrx/forms/MARK_AS_UNTOUCHED', + FocusActionType = 'ngrx/forms/FOCUS', + UnfocusActionType = 'ngrx/forms/UNFOCUS', + MarkAsSubmittedActionType = 'ngrx/forms/MARK_AS_SUBMITTED', + MarkAsUnsubmittedActionType = 'ngrx/forms/MARK_AS_UNSUBMITTED', + AddArrayControlActionType = 'ngrx/forms/ADD_ARRAY_CONTROL', + AddGroupControlActionType = 'ngrx/forms/ADD_GROUP_CONTROL', + RemoveArrayControlActionType = 'ngrx/forms/REMOVE_ARRAY_CONTROL', + SwapArrayControlActionType = 'ngrx/forms/SWAP_ARRAY_CONTROL', + MoveArrayControlActionType = 'ngrx/forms/MOVE_ARRAY_CONTROL', + RemoveGroupControlActionType = 'ngrx/forms/REMOVE_CONTROL', + SetUserDefinedPropertyActionType = 'ngrx/forms/SET_USER_DEFINED_PROPERTY', + ResetActionType = 'ngrx/forms/RESET' +} + +// using the creator fnc doesnt break api and we can use generic types +export const SetValueAction = createAction(NGRX_FORMS_ACTION_TYPES.SetValueActionType, (controlId: NgrxFormControlId, value: any) => ({ controlId: controlId, value: value })); +export const SetErrorsAction = createAction(NGRX_FORMS_ACTION_TYPES.SetErrorsActionType, (controlId: NgrxFormControlId, errors: ValidationErrors) => ({controlId, errors})); +// +export const SetAsyncErrorAction = createAction(NGRX_FORMS_ACTION_TYPES.SetAsyncErrorActionType,(controlId: NgrxFormControlId, name: string, value: any) => ({controlId, name, value})); +export const ClearAsyncErrorAction = createAction(NGRX_FORMS_ACTION_TYPES.ClearAsyncErrorActionType, (controlId: NgrxFormControlId, name: string) => ({controlId, name})); +export const StartAsyncValidationAction = createAction(NGRX_FORMS_ACTION_TYPES.StartAsyncValidationActionType, (controlId: NgrxFormControlId, name: string) => ({controlId, name})); +// +export const MarkAsDirtyAction = createAction(NGRX_FORMS_ACTION_TYPES.MarkAsDirtyActionType,(controlId: NgrxFormControlId) => ({controlId})); +export const MarkAsTouchedAction = createAction(NGRX_FORMS_ACTION_TYPES.MarkAsTouchedActionType,(controlId: NgrxFormControlId) => ({controlId})); +export const MarkAsUntouchedAction = createAction(NGRX_FORMS_ACTION_TYPES.MarkAsUntouchedActionType, (controlId: NgrxFormControlId) => ({controlId})); +export const MarkAsPristineAction = createAction(NGRX_FORMS_ACTION_TYPES.MarkAsPristineActionType,(controlId: NgrxFormControlId) => ({controlId})); +export const MarkAsSubmittedAction = createAction(NGRX_FORMS_ACTION_TYPES.MarkAsSubmittedActionType,(controlId: NgrxFormControlId) => ({controlId})); +export const MarkAsUnsubmittedAction = createAction(NGRX_FORMS_ACTION_TYPES.MarkAsUnsubmittedActionType, (controlId: NgrxFormControlId) => ({controlId})); +// +export const EnableAction = createAction(NGRX_FORMS_ACTION_TYPES.EnableActionType, (controlId: NgrxFormControlId) => ({controlId})); +export const DisableAction = createAction(NGRX_FORMS_ACTION_TYPES.DisableActionType, (controlId: NgrxFormControlId) => ({controlId})); +// +export const FocusAction = createAction(NGRX_FORMS_ACTION_TYPES.FocusActionType, (controlId: NgrxFormControlId) => ({controlId})); +export const UnfocusAction = createAction(NGRX_FORMS_ACTION_TYPES.UnfocusActionType, (controlId: NgrxFormControlId) => ({controlId})); +// +export const AddArrayControlAction = createAction(NGRX_FORMS_ACTION_TYPES.AddArrayControlActionType, + (controlId: NgrxFormControlId, value: TValue, index?: number) => ({controlId, value, index})); +export const AddGroupControlAction = createAction(NGRX_FORMS_ACTION_TYPES.AddGroupControlActionType, + (controlId: NgrxFormControlId, name: keyof TValue, value: TValue[TControlKey]) => ({controlId, name, value})); + +export const RemoveArrayControlAction = createAction(NGRX_FORMS_ACTION_TYPES.RemoveArrayControlActionType, + (controlId: NgrxFormControlId, index: number) => ({controlId, index})); + +export const SwapArrayControlAction = createAction(NGRX_FORMS_ACTION_TYPES.SwapArrayControlActionType, + (controlId: NgrxFormControlId, fromIndex: number, toIndex: number) => ({controlId, fromIndex, toIndex})); + +export const MoveArrayControlAction = createAction(NGRX_FORMS_ACTION_TYPES.MoveArrayControlActionType, + (controlId: NgrxFormControlId, fromIndex: number, toIndex: number) => ({controlId, fromIndex, toIndex})); + +export const RemoveGroupControlAction = createAction(NGRX_FORMS_ACTION_TYPES.RemoveGroupControlActionType, + (controlId: NgrxFormControlId, name: TValue) => ({controlId, name})); + +export const SetUserDefinedPropertyAction = createAction(NGRX_FORMS_ACTION_TYPES.SetUserDefinedPropertyActionType, + (controlId: NgrxFormControlId, name: string, value: any) => ({controlId, name, value})); + +export const ResetAction = createAction(NGRX_FORMS_ACTION_TYPES.ResetActionType, + (controlId: NgrxFormControlId) => ({controlId})); + +export const NgrxFormActions = union({ + SetValueAction, + SetErrorsAction, + // + SetAsyncErrorAction, + ClearAsyncErrorAction, + StartAsyncValidationAction, + // + MarkAsDirtyAction, + MarkAsTouchedAction, + MarkAsUntouchedAction, + MarkAsPristineAction, + MarkAsSubmittedAction, + MarkAsUnsubmittedAction, + // + EnableAction, + DisableAction, + // + FocusAction, + UnfocusAction, + // + AddArrayControlAction, + AddGroupControlAction, + RemoveArrayControlAction, + SwapArrayControlAction, + MoveArrayControlAction, + RemoveGroupControlAction, + SetUserDefinedPropertyAction, + ResetAction +}); + +export type NgrxFormActionTypes = typeof NgrxFormActions; + +export function isNgrxFormsAction(action: NgrxFormActionTypes) { return !!action.type && action.type.startsWith('ngrx/forms/'); } -export const ALL_NGRX_FORMS_ACTION_TYPES: Actions['type'][] = [ - 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, +// needed for onNgrxForms +export const ALL_NGRX_FORMS_ACTION_TYPES: NgrxFormActionTypes['type'][] = [ + 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, ]; diff --git a/src/array/reducer.spec.ts b/src/array/reducer.spec.ts index 2125c376..2b2e89f7 100644 --- a/src/array/reducer.spec.ts +++ b/src/array/reducer.spec.ts @@ -37,12 +37,12 @@ describe('form array reducer', () => { }); it('should skip any action with non-equal control ID', () => { - const resultState = formArrayReducer(INITIAL_STATE, new SetValueAction(`A${FORM_CONTROL_ID}`, 'A') as any); + const resultState = formArrayReducer(INITIAL_STATE, SetValueAction(`A${FORM_CONTROL_ID}`, 'A') as any); expect(resultState).toBe(INITIAL_STATE); }); it(`should forward ${FocusAction.name}s to children`, () => { - const resultState = formArrayReducer(INITIAL_STATE, new FocusAction(FORM_CONTROL_0_ID) as any); + const resultState = formArrayReducer(INITIAL_STATE, FocusAction(FORM_CONTROL_0_ID) as any); expect(resultState.controls[0].isFocused).toEqual(true); expect(resultState.controls[0].isUnfocused).toEqual(false); }); @@ -58,7 +58,7 @@ describe('form array reducer', () => { }, ], }; - const resultState = formArrayReducer(state, new UnfocusAction(FORM_CONTROL_0_ID) as any); + const resultState = formArrayReducer(state, UnfocusAction(FORM_CONTROL_0_ID) as any); expect(resultState.controls[0].isFocused).toEqual(false); expect(resultState.controls[0].isUnfocused).toEqual(true); }); @@ -66,43 +66,43 @@ describe('form array reducer', () => { it(`should forward ${AddGroupControlAction.name}s to children`, () => { const value = [{ inner: '' }]; const state = createFormArrayState(FORM_CONTROL_ID, value); - const resultState = formArrayReducer(state, new AddGroupControlAction(FORM_CONTROL_0_ID, 'inner2', '')); + const resultState = formArrayReducer(state, AddGroupControlAction(FORM_CONTROL_0_ID, 'inner2', '')); expect((resultState.controls[0].controls as any).inner2).toBeDefined(); }); it(`should forward ${RemoveGroupControlAction.name}s to children`, () => { const value = [{ inner: '', inner2: '' }]; const state = createFormArrayState(FORM_CONTROL_ID, value); - const resultState = formArrayReducer(state, new RemoveGroupControlAction(FORM_CONTROL_0_ID, 'inner2')); + const resultState = formArrayReducer(state, RemoveGroupControlAction(FORM_CONTROL_0_ID, 'inner2')); expect(resultState.controls[0].controls.inner2).toBeUndefined(); }); it('should not update state if no child was updated', () => { - const resultState = formArrayReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_0_ID, '') as any); + const resultState = formArrayReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_0_ID, '') as any); expect(resultState).toBe(INITIAL_STATE); }); it('should not update state value if no child value was updated', () => { - const resultState = formArrayReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_0_ID)); + const resultState = formArrayReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_0_ID)); expect(resultState.value).toBe(INITIAL_STATE.value); }); it('should not reset child states', () => { const value = 'A'; - const state = formArrayReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_0_ID, value) as any); - const resultState = formArrayReducer(state, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const state = formArrayReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_0_ID, value) as any); + const resultState = formArrayReducer(state, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].value).toBe(value); }); it('should not be stateful', () => { - formArrayReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, [])); - expect(() => formArrayReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID))).not.toThrowError(); + formArrayReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, [])); + expect(() => formArrayReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID))).not.toThrowError(); }); it('should preserve the order of properties when stringified', () => { const expected = JSON.stringify(INITIAL_STATE); - let state = formArrayReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); - state = formArrayReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + let state = formArrayReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); + state = formArrayReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(JSON.stringify(state)).toEqual(expected); }); @@ -111,12 +111,12 @@ describe('form array reducer', () => { }); it('should throw if state is not an array state', () => { - expect(() => formArrayReducer(INITIAL_STATE.controls[0] as any, new MarkAsDirtyAction(FORM_CONTROL_ID))).toThrowError(); + expect(() => formArrayReducer(INITIAL_STATE.controls[0] as any, MarkAsDirtyAction(FORM_CONTROL_ID))).toThrowError(); }); describe(SetValueAction.name, () => { it('should update state', () => { - const resultState = formArrayReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, ['A'])); + const resultState = formArrayReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, ['A'])); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -124,7 +124,7 @@ describe('form array reducer', () => { describe(SetErrorsAction.name, () => { it('should update state', () => { const errors = { required: true }; - const resultState = formArrayReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = formArrayReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -132,7 +132,7 @@ describe('form array reducer', () => { describe(StartAsyncValidationAction.name, () => { it('should update state', () => { const name = 'required'; - const resultState = formArrayReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = formArrayReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -142,7 +142,7 @@ describe('form array reducer', () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = formArrayReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = formArrayReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -159,14 +159,14 @@ describe('form array reducer', () => { isValidationPending: true, }; - const resultState = formArrayReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = formArrayReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsDirtyAction.name, () => { it('should update state', () => { - const resultState = formArrayReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -174,7 +174,7 @@ describe('form array reducer', () => { describe(MarkAsPristineAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = formArrayReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -182,21 +182,21 @@ describe('form array reducer', () => { describe(EnableAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = formArrayReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(DisableAction.name, () => { it('should update state', () => { - const resultState = formArrayReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsTouchedAction.name, () => { it('should update state', () => { - const resultState = formArrayReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -204,14 +204,14 @@ describe('form array reducer', () => { describe(MarkAsUntouchedAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = formArrayReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsSubmittedAction.name, () => { it('should update state', () => { - const resultState = formArrayReducer(INITIAL_STATE, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(INITIAL_STATE, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -219,14 +219,14 @@ describe('form array reducer', () => { describe(MarkAsUnsubmittedAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = formArrayReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = formArrayReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(SetUserDefinedPropertyAction.name, () => { it('should update state', () => { - const action = new SetUserDefinedPropertyAction(FORM_CONTROL_ID, 'prop', 12); + const action = SetUserDefinedPropertyAction(FORM_CONTROL_ID, 'prop', 12); const resultState = formArrayReducer(INITIAL_STATE, action); expect(resultState).not.toBe(INITIAL_STATE); }); @@ -234,7 +234,7 @@ describe('form array reducer', () => { describe(ResetAction.name, () => { it('should update state', () => { - const action = new ResetAction(FORM_CONTROL_ID); + const action = ResetAction(FORM_CONTROL_ID); const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; const resultState = formArrayReducer(state, action); expect(resultState).not.toBe(INITIAL_STATE); @@ -243,7 +243,7 @@ describe('form array reducer', () => { describe(AddArrayControlAction.name, () => { it('should update state', () => { - const action = new AddArrayControlAction(FORM_CONTROL_ID, ''); + const action = AddArrayControlAction(FORM_CONTROL_ID, ''); const resultState = formArrayReducer(INITIAL_STATE, action); expect(resultState).not.toBe(INITIAL_STATE); }); @@ -251,7 +251,7 @@ describe('form array reducer', () => { describe(RemoveArrayControlAction.name, () => { it('should update state', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 0); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 0); const resultState = formArrayReducer(INITIAL_STATE, action); expect(resultState).not.toBe(INITIAL_STATE); }); diff --git a/src/array/reducer.ts b/src/array/reducer.ts index a3490e1c..07d944b1 100644 --- a/src/array/reducer.ts +++ b/src/array/reducer.ts @@ -1,10 +1,9 @@ import { Action } from '@ngrx/store'; import { - Actions, AddGroupControlAction, FocusAction, - isNgrxFormsAction, + isNgrxFormsAction, NgrxFormActionTypes, RemoveGroupControlAction, UnfocusAction, } from '../actions'; @@ -30,7 +29,7 @@ import { startAsyncValidationReducer } from './reducer/start-async-validation'; import { swapControlReducer } from './reducer/swap-control'; import { childReducer } from './reducer/util'; -export function formArrayReducerInternal(state: FormArrayState, action: Actions) { +export function formArrayReducerInternal(state: FormArrayState, action: NgrxFormActionTypes) { if (!isArrayState(state)) { throw new Error('The state must be an array state'); } @@ -44,10 +43,10 @@ export function formArrayReducerInternal(state: FormArrayState, } switch (action.type) { - case FocusAction.TYPE: - case UnfocusAction.TYPE: - case AddGroupControlAction.TYPE: - case RemoveGroupControlAction.TYPE: + case FocusAction.type: + case UnfocusAction.type: + case AddGroupControlAction.type: + case RemoveGroupControlAction.type: return childReducer(state, action); default: diff --git a/src/array/reducer/add-control.spec.ts b/src/array/reducer/add-control.spec.ts index db77d9da..8fb26f18 100644 --- a/src/array/reducer/add-control.spec.ts +++ b/src/array/reducer/add-control.spec.ts @@ -13,7 +13,7 @@ import { describe(`form array ${addControlReducer.name}`, () => { it('should create child state for control child', () => { const value = 'B'; - const action = new AddArrayControlAction(FORM_CONTROL_ID, value); + const action = AddArrayControlAction(FORM_CONTROL_ID, value); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual([...INITIAL_STATE.value, value]); expect(resultState.controls[2].value).toEqual(value); @@ -21,7 +21,7 @@ describe(`form array ${addControlReducer.name}`, () => { it('should create child state for group child', () => { const value = { inner: 'D' }; - const action = new AddArrayControlAction(FORM_CONTROL_ID, value); + const action = AddArrayControlAction(FORM_CONTROL_ID, value); const resultState = addControlReducer(INITIAL_STATE_NESTED_GROUP, action); expect(resultState.value).toEqual([...INITIAL_STATE_NESTED_GROUP.value, value]); expect(resultState.controls[2].value).toBe(value); @@ -31,7 +31,7 @@ describe(`form array ${addControlReducer.name}`, () => { it('should create child state for array child', () => { const value = ['A']; - const action = new AddArrayControlAction(FORM_CONTROL_ID, value); + const action = AddArrayControlAction(FORM_CONTROL_ID, value); const resultState = addControlReducer(INITIAL_STATE_NESTED_ARRAY, action); expect(resultState.value).toEqual([...INITIAL_STATE_NESTED_ARRAY.value, value]); expect(resultState.controls[2].value).toEqual(value); @@ -41,7 +41,7 @@ describe(`form array ${addControlReducer.name}`, () => { it('should create child state at the given index', () => { const value = 'B'; - const action = new AddArrayControlAction(FORM_CONTROL_ID, value, 1); + const action = AddArrayControlAction(FORM_CONTROL_ID, value, 1); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual(['', value, '']); expect(resultState.controls[1].value).toEqual(value); @@ -52,7 +52,7 @@ describe(`form array ${addControlReducer.name}`, () => { it('should create child state at the start', () => { const value = 'B'; - const action = new AddArrayControlAction(FORM_CONTROL_ID, value, 0); + const action = AddArrayControlAction(FORM_CONTROL_ID, value, 0); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual([value, '', '']); expect(resultState.controls[0].value).toEqual(value); @@ -63,25 +63,25 @@ describe(`form array ${addControlReducer.name}`, () => { it('should mark the state as dirty', () => { const value = 'B'; - const action = new AddArrayControlAction(FORM_CONTROL_ID, value); + const action = AddArrayControlAction(FORM_CONTROL_ID, value); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.isDirty).toBe(true); }); it('should throw if trying to add control at out of bounds index', () => { - const action = new AddArrayControlAction(FORM_CONTROL_ID, '', 3); + const action = AddArrayControlAction(FORM_CONTROL_ID, '', 3); expect(() => addControlReducer(INITIAL_STATE, action)).toThrowError(); }); it('should throw if trying to add control at negative index', () => { - const action = new AddArrayControlAction(FORM_CONTROL_ID, '', -1); + const action = AddArrayControlAction(FORM_CONTROL_ID, '', -1); expect(() => addControlReducer(INITIAL_STATE, action)).toThrowError(); }); it('should forward actions to children', () => { const state = createFormArrayState(FORM_CONTROL_ID, [['']]); const value = 'B'; - const action = new AddArrayControlAction(state.controls[0].id, value); + const action = AddArrayControlAction(state.controls[0].id, value); const resultState = addControlReducer(state, action); expect(resultState.controls[0].value).toEqual([...state.controls[0].value, value]); expect(resultState.controls[0].controls[1].value).toEqual(value); @@ -99,7 +99,7 @@ describe(`form array ${addControlReducer.name}`, () => { }, }; - const action = new AddArrayControlAction(FORM_CONTROL_ID, value, 0); + const action = AddArrayControlAction(FORM_CONTROL_ID, value, 0); const resultState = addControlReducer(INITIAL_DEEPLY_NESTED_GROUPS_FORM_STATE, action); expect(resultState.controls[0].value).toEqual(value); diff --git a/src/array/reducer/add-control.ts b/src/array/reducer/add-control.ts index 32f69527..d1df4028 100644 --- a/src/array/reducer/add-control.ts +++ b/src/array/reducer/add-control.ts @@ -1,12 +1,12 @@ -import { Actions, AddArrayControlAction } from '../../actions'; +import { AddArrayControlAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, createChildState, FormArrayState, FormState } from '../../state'; import { childReducer, updateIdRecursive } from './util'; export function addControlReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== AddArrayControlAction.TYPE) { + if (action.type !== AddArrayControlAction.type) { return state; } diff --git a/src/array/reducer/clear-async-error.spec.ts b/src/array/reducer/clear-async-error.spec.ts index 76e2c865..882206be 100644 --- a/src/array/reducer/clear-async-error.spec.ts +++ b/src/array/reducer/clear-async-error.spec.ts @@ -8,7 +8,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { it('should remove error from state', () => { const name = 'required'; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: true }, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -17,7 +17,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { it('should remove the validation from pending validations if validation is the last pending', () => { const name = 'required'; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: true }, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); @@ -34,7 +34,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([name2]); expect(resultState.isValidationPending).toBe(true); }); @@ -43,7 +43,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { const name = 'required'; const errors = { $min: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toBe(errors); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -60,7 +60,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState).toBe(state); }); @@ -75,7 +75,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -104,7 +104,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _0: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -132,7 +132,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _0: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -160,7 +160,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _0: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -195,7 +195,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _0: errors1, _1: errors2 }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -226,7 +226,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name1)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name1)); expect(resultState.errors).toEqual({ _0: { [`$${name2}`]: value2 } }); expect(resultState.isValidationPending).toEqual(false); }); @@ -256,7 +256,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_0_ID, name2)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_0_ID, name2)); expect(resultState.errors).toEqual({ [`$${name1}`]: value1 }); expect(resultState.isValidationPending).toEqual(false); }); @@ -275,7 +275,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -294,7 +294,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -313,7 +313,7 @@ describe(`form array ${clearAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); diff --git a/src/array/reducer/clear-async-error.ts b/src/array/reducer/clear-async-error.ts index e38c1714..2ad4d6e9 100644 --- a/src/array/reducer/clear-async-error.ts +++ b/src/array/reducer/clear-async-error.ts @@ -1,12 +1,12 @@ -import { Actions, ClearAsyncErrorAction } from '../../actions'; +import { ClearAsyncErrorAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer } from './util'; export function clearAsyncErrorReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== ClearAsyncErrorAction.TYPE) { + if (action.type !== ClearAsyncErrorAction.type) { return state; } diff --git a/src/array/reducer/disable.spec.ts b/src/array/reducer/disable.spec.ts index 46045a84..80a0bb82 100644 --- a/src/array/reducer/disable.spec.ts +++ b/src/array/reducer/disable.spec.ts @@ -9,21 +9,21 @@ import { describe(`form array ${disableReducer.name}`, () => { it('should update state if enabled', () => { - const resultState = disableReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState.isEnabled).toEqual(false); expect(resultState.isDisabled).toEqual(true); }); it('should not update state if disabled', () => { const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState).toBe(state); }); it('should mark the state as valid and clear all errors', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState.isValid).toEqual(true); expect(resultState.isInvalid).toEqual(false); expect(resultState.errors).toEqual({}); @@ -31,13 +31,13 @@ describe(`form array ${disableReducer.name}`, () => { it('should clear all pending validations', () => { const state = { ...INITIAL_STATE, pendingValidations: ['required'], isValidationPending: true }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); it('should disable control children', () => { - const resultState = disableReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isEnabled).toBe(false); expect(resultState.controls[0].isDisabled).toBe(true); expect(resultState.controls[1].isEnabled).toBe(false); @@ -45,19 +45,19 @@ describe(`form array ${disableReducer.name}`, () => { }); it('should disable group children', () => { - const resultState = disableReducer(INITIAL_STATE_NESTED_GROUP, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE_NESTED_GROUP, DisableAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isEnabled).toBe(false); expect(resultState.controls[0].isDisabled).toBe(true); }); it('should disable array children', () => { - const resultState = disableReducer(INITIAL_STATE_NESTED_ARRAY, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE_NESTED_ARRAY, DisableAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isEnabled).toBe(false); expect(resultState.controls[0].isDisabled).toBe(true); }); it('should forward actions to children', () => { - const resultState = disableReducer(INITIAL_STATE, new DisableAction(INITIAL_STATE.controls[0].id)); + const resultState = disableReducer(INITIAL_STATE, DisableAction(INITIAL_STATE.controls[0].id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/array/reducer/disable.ts b/src/array/reducer/disable.ts index 38db4d5a..d16ecc7b 100644 --- a/src/array/reducer/disable.ts +++ b/src/array/reducer/disable.ts @@ -1,12 +1,12 @@ -import { Actions, DisableAction } from '../../actions'; +import {DisableAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function disableReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== DisableAction.TYPE) { + if (action.type !== DisableAction.type) { return state; } @@ -20,7 +20,7 @@ export function disableReducer( return computeArrayState( state.id, - dispatchActionPerChild(state.controls, controlId => new DisableAction(controlId)), + dispatchActionPerChild(state.controls, controlId => DisableAction(controlId)), state.value, {}, [], diff --git a/src/array/reducer/enable.spec.ts b/src/array/reducer/enable.spec.ts index 5bd695a8..2ae048fd 100644 --- a/src/array/reducer/enable.spec.ts +++ b/src/array/reducer/enable.spec.ts @@ -10,12 +10,12 @@ import { describe(`form array ${enableReducer.name}`, () => { it('should enable itself and all children recursively', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isEnabled', false], ['isDisabled', true]]); - const resultState = enableReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE); }); it('should not update state if all children are enabled recursively', () => { - const resultState = enableReducer(INITIAL_STATE, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(INITIAL_STATE, EnableAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); @@ -31,7 +31,7 @@ describe(`form array ${enableReducer.name}`, () => { }, ], }; - const resultState = enableReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE); }); @@ -47,7 +47,7 @@ describe(`form array ${enableReducer.name}`, () => { INITIAL_STATE.controls[1], ], }; - const resultState = enableReducer(state, new EnableAction(state.controls[0].id)); + const resultState = enableReducer(state, EnableAction(state.controls[0].id)); expect(resultState).not.toBe(state); }); @@ -58,7 +58,7 @@ describe(`form array ${enableReducer.name}`, () => { isEnabled: false, }; - const resultState = enableReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState.isEnabled).toBe(true); }); }); diff --git a/src/array/reducer/enable.ts b/src/array/reducer/enable.ts index 8c314b7d..4ab6bb0b 100644 --- a/src/array/reducer/enable.ts +++ b/src/array/reducer/enable.ts @@ -1,12 +1,12 @@ -import { Actions, EnableAction } from '../../actions'; +import {EnableAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function enableReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== EnableAction.TYPE) { + if (action.type !== EnableAction.type) { return state; } @@ -14,7 +14,7 @@ export function enableReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new EnableAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => EnableAction(controlId)); if (controls === state.controls && state.isEnabled) { return state; diff --git a/src/array/reducer/mark-as-dirty.spec.ts b/src/array/reducer/mark-as-dirty.spec.ts index 33c364ca..ab23395e 100644 --- a/src/array/reducer/mark-as-dirty.spec.ts +++ b/src/array/reducer/mark-as-dirty.spec.ts @@ -12,12 +12,12 @@ describe(`form array ${markAsDirtyReducer.name}`, () => { const INITIAL_STATE_DIRTY = setPropertiesRecursively(INITIAL_STATE, [['isDirty', true], ['isPristine', false]]); it('should mark itself and all children recursively as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_DIRTY); }); it('should not update state if all children are marked as dirty recursively', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE_DIRTY, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE_DIRTY, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE_DIRTY); }); @@ -35,30 +35,30 @@ describe(`form array ${markAsDirtyReducer.name}`, () => { }, ], }; - const resultState = markAsDirtyReducer(state, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(state, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_DIRTY); }); it('should mark control children as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(true); expect(resultState.controls[0].isPristine).toEqual(false); }); it('should mark group children as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE_NESTED_GROUP, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE_NESTED_GROUP, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(true); expect(resultState.controls[0].isPristine).toEqual(false); }); it('should mark array children as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE_NESTED_ARRAY, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE_NESTED_ARRAY, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(true); expect(resultState.controls[0].isPristine).toEqual(false); }); it('should forward actions to children', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE, new MarkAsDirtyAction(INITIAL_STATE.controls[0].id)); + const resultState = markAsDirtyReducer(INITIAL_STATE, MarkAsDirtyAction(INITIAL_STATE.controls[0].id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/array/reducer/mark-as-dirty.ts b/src/array/reducer/mark-as-dirty.ts index 6203064a..7c53667c 100644 --- a/src/array/reducer/mark-as-dirty.ts +++ b/src/array/reducer/mark-as-dirty.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsDirtyAction } from '../../actions'; +import { MarkAsDirtyAction, NgrxFormActionTypes } from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsDirtyReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== MarkAsDirtyAction.TYPE) { + if (action.type !== MarkAsDirtyAction.type) { return state; } @@ -14,7 +14,7 @@ export function markAsDirtyReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new MarkAsDirtyAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => MarkAsDirtyAction(controlId)); if (controls === state.controls) { return state; diff --git a/src/array/reducer/mark-as-pristine.spec.ts b/src/array/reducer/mark-as-pristine.spec.ts index 771d60d6..af3d2b1c 100644 --- a/src/array/reducer/mark-as-pristine.spec.ts +++ b/src/array/reducer/mark-as-pristine.spec.ts @@ -11,40 +11,40 @@ import { describe(`form array ${markAsPristineReducer.name}`, () => { it('should update state if dirty', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); }); it('should not update state if pristine', () => { - const resultState = markAsPristineReducer(INITIAL_STATE, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(INITIAL_STATE, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should mark control children as pristine', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(false); expect(resultState.controls[0].isPristine).toEqual(true); }); it('should mark group children as pristine', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_GROUP, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(false); expect(resultState.controls[0].isPristine).toEqual(true); }); it('should mark array children as pristine', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_ARRAY, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(false); expect(resultState.controls[0].isPristine).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(state.controls[0].id)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(state.controls[0].id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/array/reducer/mark-as-pristine.ts b/src/array/reducer/mark-as-pristine.ts index 7af113eb..bbcba737 100644 --- a/src/array/reducer/mark-as-pristine.ts +++ b/src/array/reducer/mark-as-pristine.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsPristineAction } from '../../actions'; +import { MarkAsPristineAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsPristineReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== MarkAsPristineAction.TYPE) { + if (action.type !== MarkAsPristineAction.type) { return state; } @@ -20,7 +20,7 @@ export function markAsPristineReducer( return computeArrayState( state.id, - dispatchActionPerChild(state.controls, controlId => new MarkAsPristineAction(controlId)), + dispatchActionPerChild(state.controls, controlId => MarkAsPristineAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/array/reducer/mark-as-submitted.spec.ts b/src/array/reducer/mark-as-submitted.spec.ts index 16a2e230..1c316e62 100644 --- a/src/array/reducer/mark-as-submitted.spec.ts +++ b/src/array/reducer/mark-as-submitted.spec.ts @@ -12,12 +12,12 @@ describe(`form array ${markAsSubmittedReducer.name}`, () => { const INITIAL_STATE_SUBMITTED = setPropertiesRecursively(INITIAL_STATE, [['isSubmitted', true], ['isUnsubmitted', false]]); it('should mark itself and all children recursively as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_SUBMITTED); }); it('should not update state if all children are marked as submitted recursively', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE_SUBMITTED, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE_SUBMITTED, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE_SUBMITTED); }); @@ -35,30 +35,30 @@ describe(`form array ${markAsSubmittedReducer.name}`, () => { }, ], }; - const resultState = markAsSubmittedReducer(state, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(state, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_SUBMITTED); }); it('should mark control children as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isSubmitted).toEqual(true); expect(resultState.controls[0].isUnsubmitted).toEqual(false); }); it('should mark group children as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE_NESTED_GROUP, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE_NESTED_GROUP, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isSubmitted).toEqual(true); expect(resultState.controls[0].isUnsubmitted).toEqual(false); }); it('should mark array children as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE_NESTED_ARRAY, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE_NESTED_ARRAY, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isSubmitted).toEqual(true); expect(resultState.controls[0].isUnsubmitted).toEqual(false); }); it('should forward actions to children', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE, new MarkAsSubmittedAction(INITIAL_STATE.controls[0].id)); + const resultState = markAsSubmittedReducer(INITIAL_STATE, MarkAsSubmittedAction(INITIAL_STATE.controls[0].id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/array/reducer/mark-as-submitted.ts b/src/array/reducer/mark-as-submitted.ts index 36eb27e1..06768ac1 100644 --- a/src/array/reducer/mark-as-submitted.ts +++ b/src/array/reducer/mark-as-submitted.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsSubmittedAction } from '../../actions'; +import { MarkAsSubmittedAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsSubmittedReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== MarkAsSubmittedAction.TYPE) { + if (action.type !== MarkAsSubmittedAction.type) { return state; } @@ -14,7 +14,7 @@ export function markAsSubmittedReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new MarkAsSubmittedAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => MarkAsSubmittedAction(controlId)); if (controls === state.controls) { return state; diff --git a/src/array/reducer/mark-as-touched.spec.ts b/src/array/reducer/mark-as-touched.spec.ts index 30a628ca..a2f29833 100644 --- a/src/array/reducer/mark-as-touched.spec.ts +++ b/src/array/reducer/mark-as-touched.spec.ts @@ -12,12 +12,12 @@ describe(`form array ${markAsTouchedReducer.name}`, () => { const INITIAL_STATE_TOUCHED = setPropertiesRecursively(INITIAL_STATE, [['isTouched', true], ['isUntouched', false]]); it('should mark itself and all children recursively as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_TOUCHED); }); it('should not update state if all children are marked as touched recursively', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE_TOUCHED, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE_TOUCHED, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE_TOUCHED); }); @@ -35,30 +35,30 @@ describe(`form array ${markAsTouchedReducer.name}`, () => { }, ], }; - const resultState = markAsTouchedReducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_TOUCHED); }); it('should mark control children as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isTouched).toEqual(true); expect(resultState.controls[0].isUntouched).toEqual(false); }); it('should mark group children as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE_NESTED_GROUP, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE_NESTED_GROUP, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isTouched).toEqual(true); expect(resultState.controls[0].isUntouched).toEqual(false); }); it('should mark array children as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE_NESTED_ARRAY, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE_NESTED_ARRAY, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isTouched).toEqual(true); expect(resultState.controls[0].isUntouched).toEqual(false); }); it('should forward actions to children', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE, new MarkAsTouchedAction(INITIAL_STATE.controls[0].id)); + const resultState = markAsTouchedReducer(INITIAL_STATE, MarkAsTouchedAction(INITIAL_STATE.controls[0].id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/array/reducer/mark-as-touched.ts b/src/array/reducer/mark-as-touched.ts index ac9aad70..b482f705 100644 --- a/src/array/reducer/mark-as-touched.ts +++ b/src/array/reducer/mark-as-touched.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsTouchedAction } from '../../actions'; +import { MarkAsTouchedAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsTouchedReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== MarkAsTouchedAction.TYPE) { + if (action.type !== MarkAsTouchedAction.type) { return state; } @@ -14,7 +14,7 @@ export function markAsTouchedReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new MarkAsTouchedAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => MarkAsTouchedAction(controlId)); if (controls === state.controls) { return state; diff --git a/src/array/reducer/mark-as-unsubmitted.spec.ts b/src/array/reducer/mark-as-unsubmitted.spec.ts index 5d5f821a..c086e4d1 100644 --- a/src/array/reducer/mark-as-unsubmitted.spec.ts +++ b/src/array/reducer/mark-as-unsubmitted.spec.ts @@ -11,40 +11,40 @@ import { describe(`form array ${markAsUnsubmittedReducer.name}`, () => { it('should update state if submitted', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.isSubmitted).toEqual(false); expect(resultState.isUnsubmitted).toEqual(true); }); it('should not update state if unsubmitted', () => { - const resultState = markAsUnsubmittedReducer(INITIAL_STATE, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(INITIAL_STATE, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should mark control children as unsubmitted', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isSubmitted).toEqual(false); expect(resultState.controls[0].isUnsubmitted).toEqual(true); }); it('should mark group children as unsubmitted', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_GROUP, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isSubmitted).toEqual(false); expect(resultState.controls[0].isUnsubmitted).toEqual(true); }); it('should mark array children as unsubmitted', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_ARRAY, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isSubmitted).toEqual(false); expect(resultState.controls[0].isUnsubmitted).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(state.controls[0].id)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(state.controls[0].id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/array/reducer/mark-as-unsubmitted.ts b/src/array/reducer/mark-as-unsubmitted.ts index 2b3f938e..0021508e 100644 --- a/src/array/reducer/mark-as-unsubmitted.ts +++ b/src/array/reducer/mark-as-unsubmitted.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsUnsubmittedAction } from '../../actions'; +import { MarkAsUnsubmittedAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsUnsubmittedReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== MarkAsUnsubmittedAction.TYPE) { + if (action.type !== MarkAsUnsubmittedAction.type) { return state; } @@ -20,7 +20,7 @@ export function markAsUnsubmittedReducer( return computeArrayState( state.id, - dispatchActionPerChild(state.controls, controlId => new MarkAsUnsubmittedAction(controlId)), + dispatchActionPerChild(state.controls, controlId => MarkAsUnsubmittedAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/array/reducer/mark-as-untouched.spec.ts b/src/array/reducer/mark-as-untouched.spec.ts index 9eb896d0..e2d8bfa9 100644 --- a/src/array/reducer/mark-as-untouched.spec.ts +++ b/src/array/reducer/mark-as-untouched.spec.ts @@ -11,40 +11,40 @@ import { describe(`form array ${markAsUntouchedReducer.name}`, () => { it('should update state if touched', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.isTouched).toEqual(false); expect(resultState.isUntouched).toEqual(true); }); it('should not update state if untouched', () => { - const resultState = markAsUntouchedReducer(INITIAL_STATE, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(INITIAL_STATE, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should mark control children as untouched', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isTouched).toEqual(false); expect(resultState.controls[0].isUntouched).toEqual(true); }); it('should mark group children as untouched', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_GROUP, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isTouched).toEqual(false); expect(resultState.controls[0].isUntouched).toEqual(true); }); it('should mark array children as untouched', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_ARRAY, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isTouched).toEqual(false); expect(resultState.controls[0].isUntouched).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(state.controls[0].id)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(state.controls[0].id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/array/reducer/mark-as-untouched.ts b/src/array/reducer/mark-as-untouched.ts index d61e64ae..e8047e90 100644 --- a/src/array/reducer/mark-as-untouched.ts +++ b/src/array/reducer/mark-as-untouched.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsUntouchedAction } from '../../actions'; +import { MarkAsUntouchedAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsUntouchedReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== MarkAsUntouchedAction.TYPE) { + if (action.type !== MarkAsUntouchedAction.type) { return state; } @@ -20,7 +20,7 @@ export function markAsUntouchedReducer( return computeArrayState( state.id, - dispatchActionPerChild(state.controls, controlId => new MarkAsUntouchedAction(controlId)), + dispatchActionPerChild(state.controls, controlId => MarkAsUntouchedAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/array/reducer/move-control.spec.ts b/src/array/reducer/move-control.spec.ts index 524a2089..5a814686 100644 --- a/src/array/reducer/move-control.spec.ts +++ b/src/array/reducer/move-control.spec.ts @@ -8,26 +8,26 @@ describe(`form array ${moveControlReducer.name}`, () => { const testArrayState = createFormArrayState(FORM_CONTROL_ID, testArrayValue); it('should move controls forward', () => { - let action = new MoveArrayControlAction(FORM_CONTROL_ID, 2, 5); + let action = MoveArrayControlAction(FORM_CONTROL_ID, 2, 5); let resultState = moveControlReducer(testArrayState, action); expect(resultState).not.toBe(testArrayState); expect(resultState.controls).not.toBe(testArrayState.controls); expect(resultState.value).toEqual([0, 1, 3, 4, 5, 2]); expect(resultState.isDirty).toEqual(true); - action = new MoveArrayControlAction(FORM_CONTROL_ID, 0, 3); + action = MoveArrayControlAction(FORM_CONTROL_ID, 0, 3); resultState = moveControlReducer(testArrayState, action); expect(resultState.value).toEqual([1, 2, 3, 0, 4, 5]); }); it('should move controls backwards', () => { - let action = new MoveArrayControlAction(FORM_CONTROL_ID, 5, 2); + let action = MoveArrayControlAction(FORM_CONTROL_ID, 5, 2); let resultState = moveControlReducer(testArrayState, action); expect(resultState).not.toBe(testArrayState); expect(resultState.controls).not.toBe(testArrayState.controls); expect(resultState.value).toEqual([0, 1, 5, 2, 3, 4]); - action = new MoveArrayControlAction(FORM_CONTROL_ID, 3, 0); + action = MoveArrayControlAction(FORM_CONTROL_ID, 3, 0); resultState = moveControlReducer(testArrayState, action); expect(resultState.value).toEqual([3, 0, 1, 2, 4, 5]); }); @@ -36,39 +36,39 @@ describe(`form array ${moveControlReducer.name}`, () => { expect(() => moveControlReducer( INITIAL_STATE_NESTED_GROUP, - new MoveArrayControlAction(FORM_CONTROL_ID, 0, INITIAL_STATE_NESTED_GROUP.controls.length)) + MoveArrayControlAction(FORM_CONTROL_ID, 0, INITIAL_STATE_NESTED_GROUP.controls.length)) ).toThrowError(); expect(() => moveControlReducer( INITIAL_STATE_NESTED_GROUP, - new MoveArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, 0)) + MoveArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, 0)) ).toThrowError(); expect(() => moveControlReducer( INITIAL_STATE_NESTED_GROUP, - new MoveArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, -3)) + MoveArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, -3)) ).toThrowError(); expect(() => moveControlReducer( INITIAL_STATE_NESTED_GROUP, - new MoveArrayControlAction(FORM_CONTROL_ID, -1, 0)) + MoveArrayControlAction(FORM_CONTROL_ID, -1, 0)) ).toThrowError(); }); it('should return the state on a 0 move', () => { - const action = new MoveArrayControlAction(FORM_CONTROL_ID, 1, 1); + const action = MoveArrayControlAction(FORM_CONTROL_ID, 1, 1); const resultState = moveControlReducer(testArrayState, action); expect(resultState).toBe(testArrayState); }); it('should return the state if applied on a different state ID', () => { - const action = new MoveArrayControlAction(FORM_CONTROL_0_ID, 0, 1); + const action = MoveArrayControlAction(FORM_CONTROL_0_ID, 0, 1); const resultState = moveControlReducer(testArrayState, action); expect(resultState).toBe(testArrayState); }); it('should update nested group IDs after a move', () => { - const action = new MoveArrayControlAction(FORM_CONTROL_ID, 0, 1); + const action = MoveArrayControlAction(FORM_CONTROL_ID, 0, 1); const resultState = moveControlReducer(INITIAL_STATE_NESTED_GROUP, action); resultState.controls.forEach((control, index) => { expect(control.id).toEqual(`${FORM_CONTROL_ID}.${index}`); @@ -79,7 +79,7 @@ describe(`form array ${moveControlReducer.name}`, () => { it('should update nested array child IDs after a move', () => { const testValue = [{ array: [0, 1, 2, 3] }, { array: [0, 1, 2, 3] }]; const testState = createFormArrayState(FORM_CONTROL_ID, testValue); - const action = new MoveArrayControlAction(FORM_CONTROL_ID, 0, 1); + const action = MoveArrayControlAction(FORM_CONTROL_ID, 0, 1); const resultState = moveControlReducer(testState, action); resultState.controls.forEach((control, index) => { expect(control.id).toEqual(`${FORM_CONTROL_ID}.${index}`); @@ -91,7 +91,7 @@ describe(`form array ${moveControlReducer.name}`, () => { }); it('should mark the array as dirty', () => { - const action = new MoveArrayControlAction(FORM_CONTROL_ID, 3, 1); + const action = MoveArrayControlAction(FORM_CONTROL_ID, 3, 1); const resultState = moveControlReducer(testArrayState, action); expect(resultState).not.toBe(testArrayState); expect(resultState.isDirty).toEqual(true); diff --git a/src/array/reducer/move-control.ts b/src/array/reducer/move-control.ts index 7339bef2..380df23e 100644 --- a/src/array/reducer/move-control.ts +++ b/src/array/reducer/move-control.ts @@ -1,4 +1,4 @@ -import { Actions, MoveArrayControlAction } from '../../actions'; +import {MoveArrayControlAction, NgrxFormActionTypes} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, updateIdRecursive } from './util'; @@ -25,9 +25,9 @@ export function move(array: readonly any[], fromIndex: number, toIndex: number) export function moveControlReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== MoveArrayControlAction.TYPE) { + if (action.type !== MoveArrayControlAction.type) { return state; } if (action.controlId !== state.id) { diff --git a/src/array/reducer/remove-control.spec.ts b/src/array/reducer/remove-control.spec.ts index b205086b..49520bf0 100644 --- a/src/array/reducer/remove-control.spec.ts +++ b/src/array/reducer/remove-control.spec.ts @@ -12,7 +12,7 @@ describe(`form group ${removeControlReducer.name}`, () => { const INITIAL_STATE_NESTED_ARRAY = createFormArrayState(FORM_CONTROL_ID, INITIAL_FORM_ARRAY_VALUE_NESTED_ARRAY); it('should remove child state', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 0); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 0); const resultState = removeControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual([INITIAL_FORM_ARRAY_VALUE[1]]); expect(resultState.controls[1]).toBeUndefined(); @@ -20,7 +20,7 @@ describe(`form group ${removeControlReducer.name}`, () => { }); it('should remove child state for group children', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 0); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 0); const resultState = removeControlReducer(INITIAL_STATE_NESTED_GROUP, action); expect(resultState.value).toEqual([INITIAL_FORM_ARRAY_VALUE_NESTED_GROUP[1]]); expect(resultState.controls[1]).toBeUndefined(); @@ -29,7 +29,7 @@ describe(`form group ${removeControlReducer.name}`, () => { }); it('should remove child state for array children', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 0); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 0); const resultState = removeControlReducer(INITIAL_STATE_NESTED_ARRAY, action); expect(resultState.value).toEqual([INITIAL_FORM_ARRAY_VALUE_NESTED_ARRAY[1]]); expect(resultState.controls[1]).toBeUndefined(); @@ -38,19 +38,19 @@ describe(`form group ${removeControlReducer.name}`, () => { }); it('should update nested child IDs for group children', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 0); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 0); const resultState = removeControlReducer(INITIAL_STATE_NESTED_GROUP, action); expect(resultState.controls[0].controls.inner.id).toEqual(`${FORM_CONTROL_ID}.0.inner`); }); it('should update nested child IDs for array children', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 0); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 0); const resultState = removeControlReducer(INITIAL_STATE_NESTED_ARRAY, action); expect(resultState.controls[0].controls[0].id).toEqual(`${FORM_CONTROL_ID}.0.0`); }); it('should remove last element', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 1); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 1); const resultState = removeControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual([INITIAL_FORM_ARRAY_VALUE[0]]); expect(resultState.controls[1]).toBeUndefined(); @@ -58,7 +58,7 @@ describe(`form group ${removeControlReducer.name}`, () => { }); it('should mark the state as dirty', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 1); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 1); const resultState = removeControlReducer(INITIAL_STATE, action); expect(resultState.isDirty).toBe(true); }); @@ -79,7 +79,7 @@ describe(`form group ${removeControlReducer.name}`, () => { }, ], }; - const action = new RemoveArrayControlAction(id, 0); + const action = RemoveArrayControlAction(id, 0); const resultState = removeControlReducer(state, action); expect(resultState.value).toEqual([]); expect(resultState.errors).toEqual({}); @@ -103,7 +103,7 @@ describe(`form group ${removeControlReducer.name}`, () => { }, ], }; - const action = new RemoveArrayControlAction(id, 0); + const action = RemoveArrayControlAction(id, 0); const resultState = removeControlReducer(state, action); expect(resultState.value).toEqual([]); expect(resultState.errors).toEqual(errors); @@ -111,18 +111,18 @@ describe(`form group ${removeControlReducer.name}`, () => { }); it('should throw if trying to remove non-existing control', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, 2); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, 2); expect(() => removeControlReducer(INITIAL_STATE, action)).toThrowError(); }); it('should throw if trying to remove control at negative index', () => { - const action = new RemoveArrayControlAction(FORM_CONTROL_ID, -1); + const action = RemoveArrayControlAction(FORM_CONTROL_ID, -1); expect(() => removeControlReducer(INITIAL_STATE, action)).toThrowError(); }); it('should forward actions to children', () => { const state = createFormArrayState(FORM_CONTROL_ID, [['']]); - const action = new RemoveArrayControlAction(state.controls[0].id, 0); + const action = RemoveArrayControlAction(state.controls[0].id, 0); const resultState = removeControlReducer(state, action); expect(resultState.controls[0].value).toEqual([]); }); diff --git a/src/array/reducer/remove-control.ts b/src/array/reducer/remove-control.ts index a14574cd..a719d473 100644 --- a/src/array/reducer/remove-control.ts +++ b/src/array/reducer/remove-control.ts @@ -1,12 +1,12 @@ -import { Actions, RemoveArrayControlAction } from '../../actions'; +import { NgrxFormActionTypes, RemoveArrayControlAction} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, updateIdRecursive } from './util'; export function removeControlReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== RemoveArrayControlAction.TYPE) { + if (action.type !== RemoveArrayControlAction.type) { return state; } diff --git a/src/array/reducer/reset.spec.ts b/src/array/reducer/reset.spec.ts index b460e772..f6179332 100644 --- a/src/array/reducer/reset.spec.ts +++ b/src/array/reducer/reset.spec.ts @@ -11,7 +11,7 @@ import { describe(`form array ${resetReducer.name}`, () => { it('should update state if dirty', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -22,7 +22,7 @@ describe(`form array ${resetReducer.name}`, () => { it('should update state if touched', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -33,7 +33,7 @@ describe(`form array ${resetReducer.name}`, () => { it('should update state if submitted', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -43,34 +43,34 @@ describe(`form array ${resetReducer.name}`, () => { }); it('should not update state if pristine and untouched and unsubmitted', () => { - const resultState = resetReducer(INITIAL_STATE, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(INITIAL_STATE, ResetAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should reset control children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(false); expect(resultState.controls[0].isPristine).toEqual(true); }); it('should reset group children', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_GROUP, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(false); expect(resultState.controls[0].isPristine).toEqual(true); }); it('should reset array children', () => { const state = setPropertiesRecursively(INITIAL_STATE_NESTED_ARRAY, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.controls[0].isDirty).toEqual(false); expect(resultState.controls[0].isPristine).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(state.controls[0].id)); + const resultState = resetReducer(state, ResetAction(state.controls[0].id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/array/reducer/reset.ts b/src/array/reducer/reset.ts index e59cbd2b..1ff15266 100644 --- a/src/array/reducer/reset.ts +++ b/src/array/reducer/reset.ts @@ -1,12 +1,12 @@ -import { Actions, ResetAction } from '../../actions'; +import {NgrxFormActionTypes, ResetAction} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function resetReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== ResetAction.TYPE) { + if (action.type !== ResetAction.type) { return state; } @@ -20,7 +20,7 @@ export function resetReducer( return computeArrayState( state.id, - dispatchActionPerChild(state.controls, controlId => new ResetAction(controlId)), + dispatchActionPerChild(state.controls, controlId => ResetAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/array/reducer/set-async-error.spec.ts b/src/array/reducer/set-async-error.spec.ts index b81b1f53..85276ba9 100644 --- a/src/array/reducer/set-async-error.spec.ts +++ b/src/array/reducer/set-async-error.spec.ts @@ -16,7 +16,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors).toEqual({ [`$${name}`]: value }); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -26,7 +26,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); @@ -36,7 +36,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { const name2 = 'min'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name, name2], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([name2]); expect(resultState.isValidationPending).toBe(true); }); @@ -45,7 +45,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: value }, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors[`$${name}`]).toBe(value); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -55,7 +55,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = { field: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: value }, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, { ...value })); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, { ...value })); expect(resultState.errors[`$${name}`]).toBe(value); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -65,7 +65,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState).toBe(state); }); @@ -73,7 +73,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: ['min'], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors).toEqual({ [`$${name}`]: value }); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -93,7 +93,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_0_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_0_ID, name, value)); expect(resultState.errors).toEqual({ _0: { [`$${name}`]: value } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -114,7 +114,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_0_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_0_ID, name, value)); expect(resultState.errors).toEqual({ _0: { [`$${name}`]: value } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -135,7 +135,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_0_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_0_ID, name, value)); expect(resultState.errors).toEqual({ _0: { [`$${name}`]: value } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -163,8 +163,8 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - let resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_0_ID, name1, value1)); - resultState = setAsyncErrorReducer(resultState, new SetAsyncErrorAction(FORM_CONTROL_1_ID, name2, value2)); + let resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_0_ID, name1, value1)); + resultState = setAsyncErrorReducer(resultState, SetAsyncErrorAction(FORM_CONTROL_1_ID, name2, value2)); expect(resultState.errors).toEqual({ _0: { [`$${name1}`]: value1 }, _1: { [`$${name2}`]: value2 } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -194,7 +194,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name1, value1)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name1, value1)); expect(resultState.errors).toEqual({ [`$${name1}`]: value1, _0: { [`$${name2}`]: value2 } }); }); @@ -217,7 +217,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_0_ID, name2, value2)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_0_ID, name2, value2)); expect(resultState.errors).toEqual({ [`$${name1}`]: value1, _0: { [`$${name2}`]: value2 } }); }); @@ -236,7 +236,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -256,7 +256,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -276,7 +276,7 @@ describe(`form array ${setAsyncErrorReducer.name}`, () => { }, ], }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); diff --git a/src/array/reducer/set-async-error.ts b/src/array/reducer/set-async-error.ts index 2638a3e7..046784e1 100644 --- a/src/array/reducer/set-async-error.ts +++ b/src/array/reducer/set-async-error.ts @@ -1,13 +1,13 @@ -import { Actions, SetAsyncErrorAction } from '../../actions'; +import {NgrxFormActionTypes, SetAsyncErrorAction} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { deepEquals } from '../../util'; import { childReducer } from './util'; export function setAsyncErrorReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== SetAsyncErrorAction.TYPE) { + if (action.type !== SetAsyncErrorAction.type) { return state; } diff --git a/src/array/reducer/set-errors.spec.ts b/src/array/reducer/set-errors.spec.ts index 4ad25970..b6e2e900 100644 --- a/src/array/reducer/set-errors.spec.ts +++ b/src/array/reducer/set-errors.spec.ts @@ -13,7 +13,7 @@ import { describe(`form array ${setErrorsReducer.name}`, () => { it('should update state if there are errors', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState.errors).toEqual(errors); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -22,7 +22,7 @@ describe(`form array ${setErrorsReducer.name}`, () => { it('should update state if there are no errors', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, {})); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, {})); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -30,32 +30,32 @@ describe(`form array ${setErrorsReducer.name}`, () => { it('should not update state if errors are same', () => { const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { required: true } }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, state.errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, state.errors)); expect(resultState).toBe(state); }); it('should not update state if errors are equal', () => { const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { required: true } }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, { required: true })); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, { required: true })); expect(resultState).toBe(state); }); it('should not update state if control is disabled', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState).toBe(state); }); it('should not update state if errors are equal and empty', () => { - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, {})); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, {})); expect(resultState).toBe(INITIAL_STATE); }); it('should update state if array is empty', () => { const errors = { required: true }; const state = createFormArrayState('test ID', []); - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState.errors).toEqual(errors); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -65,21 +65,21 @@ describe(`form array ${setErrorsReducer.name}`, () => { const syncErrors = { required: true }; const asyncErrors = { $required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: asyncErrors }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, syncErrors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, syncErrors)); expect(resultState.errors).toEqual({ ...asyncErrors, ...syncErrors }); }); it('should throw if trying to set invalid error value', () => { - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, null as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, 1 as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, [] as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, { $required: true }))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, { _inner: true }))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, null as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, 1 as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, [] as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, { $required: true }))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, { _inner: true }))).toThrowError(); }); it('should aggregate child errors', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_0_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_0_ID, errors)); expect(resultState.errors).toEqual({ _0: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -87,7 +87,7 @@ describe(`form array ${setErrorsReducer.name}`, () => { it('should aggregate child errors for group children', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE_NESTED_GROUP, new SetErrorsAction(FORM_CONTROL_0_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE_NESTED_GROUP, SetErrorsAction(FORM_CONTROL_0_ID, errors)); expect(resultState.errors).toEqual({ _0: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -95,7 +95,7 @@ describe(`form array ${setErrorsReducer.name}`, () => { it('should aggregate child errors for array children', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE_NESTED_ARRAY, new SetErrorsAction(FORM_CONTROL_0_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE_NESTED_ARRAY, SetErrorsAction(FORM_CONTROL_0_ID, errors)); expect(resultState.errors).toEqual({ _0: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -104,8 +104,8 @@ describe(`form array ${setErrorsReducer.name}`, () => { it('should aggregate multiple child errors', () => { const errors1 = { required: true }; const errors2 = { min: 0 }; - let resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_0_ID, errors1)); - resultState = setErrorsReducer(resultState, new SetErrorsAction(FORM_CONTROL_1_ID, errors2)); + let resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_0_ID, errors1)); + resultState = setErrorsReducer(resultState, SetErrorsAction(FORM_CONTROL_1_ID, errors2)); expect(resultState.errors).toEqual({ _0: errors1, _1: errors2 }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -130,7 +130,7 @@ describe(`form array ${setErrorsReducer.name}`, () => { }, ], }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, errors1)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, errors1)); expect(resultState.errors).toEqual({ ...errors1, _0: errors2 }); }); @@ -143,7 +143,7 @@ describe(`form array ${setErrorsReducer.name}`, () => { errors: errors1, }; const errors2 = { min: 0 }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_0_ID, errors2)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_0_ID, errors2)); expect(resultState.errors).toEqual({ ...errors1, _0: errors2 }); }); }); diff --git a/src/array/reducer/set-errors.ts b/src/array/reducer/set-errors.ts index fbab9f69..715d000d 100644 --- a/src/array/reducer/set-errors.ts +++ b/src/array/reducer/set-errors.ts @@ -1,13 +1,13 @@ -import { Actions, SetErrorsAction } from '../../actions'; +import {NgrxFormActionTypes, SetErrorsAction} from '../../actions'; import { computeArrayState, FormArrayState, ValidationErrors } from '../../state'; import { deepEquals } from '../../util'; import { childReducer } from './util'; export function setErrorsReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== SetErrorsAction.TYPE) { + if (action.type !== SetErrorsAction.type) { return state; } diff --git a/src/array/reducer/set-user-defined-property.spec.ts b/src/array/reducer/set-user-defined-property.spec.ts index 07225e3a..0d833736 100644 --- a/src/array/reducer/set-user-defined-property.spec.ts +++ b/src/array/reducer/set-user-defined-property.spec.ts @@ -9,7 +9,7 @@ describe(`form group ${setUserDefinedPropertyReducer.name}`, () => { it('should update state user defined properties if different', () => { const prop = 'prop'; const value = 12; - const resultState = setUserDefinedPropertyReducer(INITIAL_STATE, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(INITIAL_STATE, SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); expect(resultState.userDefinedProperties).toEqual({ [prop]: value, }); @@ -19,14 +19,14 @@ describe(`form group ${setUserDefinedPropertyReducer.name}`, () => { const prop = 'prop'; const value = 12; const state = { ...INITIAL_STATE, userDefinedProperties: { [prop]: value } }; - const resultState = setUserDefinedPropertyReducer(state, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(state, SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); expect(resultState).toBe(state); }); it('should update state user defined properties for children', () => { const prop = 'prop'; const value = 12; - const resultState = setUserDefinedPropertyReducer(INITIAL_STATE, new SetUserDefinedPropertyAction(FORM_CONTROL_0_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(INITIAL_STATE, SetUserDefinedPropertyAction(FORM_CONTROL_0_ID, prop, value)); expect(resultState.controls[0].userDefinedProperties).toEqual({ [prop]: value, }); diff --git a/src/array/reducer/set-user-defined-property.ts b/src/array/reducer/set-user-defined-property.ts index 7bb91017..ee7da7a7 100644 --- a/src/array/reducer/set-user-defined-property.ts +++ b/src/array/reducer/set-user-defined-property.ts @@ -1,12 +1,12 @@ -import { Actions, SetUserDefinedPropertyAction } from '../../actions'; +import { NgrxFormActionTypes, SetUserDefinedPropertyAction} from '../../actions'; import { FormArrayState } from '../../state'; import { childReducer } from './util'; export function setUserDefinedPropertyReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== SetUserDefinedPropertyAction.TYPE) { + if (action.type !== SetUserDefinedPropertyAction.type) { return state; } diff --git a/src/array/reducer/set-value.spec.ts b/src/array/reducer/set-value.spec.ts index 6b06b973..ca59b4cd 100644 --- a/src/array/reducer/set-value.spec.ts +++ b/src/array/reducer/set-value.spec.ts @@ -12,106 +12,106 @@ import { describe(`form array ${setValueReducer.name}`, () => { it('should update state value if different', () => { const value = ['A', '']; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); }); it('should not update state value if same', () => { const value = ['', '']; const state = { ...INITIAL_STATE, value }; - const resultState = setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(state,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState).toBe(state); }); it('should not mark state as dirty', () => { const value = ['A', '']; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.isDirty).toEqual(false); }); it('should update child state value', () => { const value = ['A', '']; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.controls[0].value).toEqual(value[0]); }); it('should create child states on demand', () => { const value = ['', '', '']; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls[2].value).toEqual(value[2]); }); it('should create child states on demand for group children', () => { const value = [{ inner: '' }, { inner: '' }, { inner: '' }]; - const resultState = setValueReducer(INITIAL_STATE_NESTED_GROUP, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE_NESTED_GROUP,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls[2].value).toEqual(value[2]); }); it('should create child states on demand for array children', () => { const value = [[''], [''], ['']]; - const resultState = setValueReducer(INITIAL_STATE_NESTED_ARRAY, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE_NESTED_ARRAY,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls[2].value).toEqual(value[2]); }); it('should create child states on demand for null children', () => { const value = ['', '', null]; - const resultState = setValueReducer(INITIAL_STATE as FormArrayState, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE as FormArrayState,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls[2].value).toEqual(value[2]); }); it('should remove child states on demand', () => { const value = ['']; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls[1]).toBeUndefined(); }); it('should remove child states on demand when value is empty', () => { const value: string[] = []; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls[0]).toBeUndefined(); }); it('should aggregate child values', () => { const value = 'A'; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_0_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_0_ID, value) as any); expect(resultState.value).toEqual([value, '']); }); it('should not mark state as dirty if child value is updated', () => { const value = 'A'; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_0_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE,SetValueAction(FORM_CONTROL_0_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls[0].isDirty).toEqual(false); }); it('should aggregate child values for group children', () => { const value = { inner: 'A' }; - const resultState = setValueReducer(INITIAL_STATE_NESTED_GROUP, new SetValueAction(FORM_CONTROL_0_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE_NESTED_GROUP,SetValueAction(FORM_CONTROL_0_ID, value) as any); expect(resultState.value).toEqual([value, { inner: '' }]); }); it('should not mark state as dirty if group child value is updated', () => { const value = { inner: 'A' }; - const resultState = setValueReducer(INITIAL_STATE_NESTED_GROUP, new SetValueAction(FORM_CONTROL_0_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE_NESTED_GROUP,SetValueAction(FORM_CONTROL_0_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls[0].isDirty).toEqual(false); }); it('should aggregate child values for array children', () => { const value = ['A']; - const resultState = setValueReducer(INITIAL_STATE_NESTED_ARRAY, new SetValueAction(FORM_CONTROL_0_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE_NESTED_ARRAY,SetValueAction(FORM_CONTROL_0_ID, value) as any); expect(resultState.value).toEqual([value, ['']]); }); it('should not mark state as dirty if array child value is updated', () => { const value = ['A']; - const resultState = setValueReducer(INITIAL_STATE_NESTED_ARRAY, new SetValueAction(FORM_CONTROL_0_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE_NESTED_ARRAY,SetValueAction(FORM_CONTROL_0_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls[0].isDirty).toEqual(false); }); @@ -131,7 +131,7 @@ describe(`form array ${setValueReducer.name}`, () => { INITIAL_STATE.controls[1], ], }; - const resultState = setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, [])); + const resultState = setValueReducer(state,SetValueAction(FORM_CONTROL_ID, [])); expect(resultState.value).toEqual([]); expect(resultState.errors).toEqual({}); expect(resultState.controls[0]).toBeUndefined(); @@ -153,14 +153,14 @@ describe(`form array ${setValueReducer.name}`, () => { INITIAL_STATE.controls[1], ], }; - const resultState = setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, [])); + const resultState = setValueReducer(state,SetValueAction(FORM_CONTROL_ID, [])); expect(resultState.value).toEqual([]); expect(resultState.errors).toEqual(errors); expect(resultState.controls[0]).toBeUndefined(); }); it('should throw if trying to set date as value', () => { - const action = new SetValueAction(FORM_CONTROL_ID, new Date() as any); + const action =SetValueAction(FORM_CONTROL_ID, new Date() as any); expect(() => setValueReducer(INITIAL_STATE, action)).toThrowError(); }); }); diff --git a/src/array/reducer/set-value.ts b/src/array/reducer/set-value.ts index 8096da1d..7197d5d7 100644 --- a/src/array/reducer/set-value.ts +++ b/src/array/reducer/set-value.ts @@ -1,13 +1,13 @@ -import { Actions, SetValueAction } from '../../actions'; +import {NgrxFormActionTypes, SetValueAction} from '../../actions'; import { formStateReducer } from '../../reducer'; import { computeArrayState, createChildState, FormArrayState } from '../../state'; import { childReducer } from './util'; export function setValueReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== SetValueAction.TYPE) { + if (action.type !== SetValueAction.type) { return state; } @@ -26,12 +26,12 @@ export function setValueReducer( const value = action.value; const controls = value - .map((v, i) => { + .map((v: any, i: number) => { if (!state.controls[i]) { return createChildState(`${state.id}.${i}`, v); } - return formStateReducer(state.controls[i], new SetValueAction(state.controls[i].id, v)); + return formStateReducer(state.controls[i], SetValueAction(state.controls[i].id, v)); }); return computeArrayState( diff --git a/src/array/reducer/start-async-validation.spec.ts b/src/array/reducer/start-async-validation.spec.ts index 4be2bf58..5652aaea 100644 --- a/src/array/reducer/start-async-validation.spec.ts +++ b/src/array/reducer/start-async-validation.spec.ts @@ -13,7 +13,7 @@ describe(`form array ${startAsyncValidationReducer.name}`, () => { it('should update state with pending validation', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([name]); expect(resultState.isValidationPending).toBe(true); }); @@ -22,7 +22,7 @@ describe(`form array ${startAsyncValidationReducer.name}`, () => { const name = 'required'; const existingName = 'min'; const state = { ...INITIAL_STATE, pendingValidations: [existingName], isValidationPending: true }; - const resultState = startAsyncValidationReducer(state, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(state, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([existingName, name]); expect(resultState.isValidationPending).toBe(true); }); @@ -30,25 +30,25 @@ describe(`form array ${startAsyncValidationReducer.name}`, () => { it('should not update state if validation is already pending', () => { const name = 'required'; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = startAsyncValidationReducer(state, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(state, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState).toBe(state); }); it('should mark state as having validation pending if control child is marked as having validation pending', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_0_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_0_ID, name)); expect(resultState.isValidationPending).toEqual(true); }); it('should mark state as having validation pending if group child is marked as having validation pending', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE_NESTED_ARRAY, new StartAsyncValidationAction(FORM_CONTROL_0_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE_NESTED_ARRAY, StartAsyncValidationAction(FORM_CONTROL_0_ID, name)); expect(resultState.isValidationPending).toEqual(true); }); it('should mark state as having validation pending if array child is marked as having validation pending', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE_NESTED_GROUP, new StartAsyncValidationAction(FORM_CONTROL_0_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE_NESTED_GROUP, StartAsyncValidationAction(FORM_CONTROL_0_ID, name)); expect(resultState.isValidationPending).toEqual(true); }); }); diff --git a/src/array/reducer/start-async-validation.ts b/src/array/reducer/start-async-validation.ts index 54114f8e..5f6151ac 100644 --- a/src/array/reducer/start-async-validation.ts +++ b/src/array/reducer/start-async-validation.ts @@ -1,12 +1,12 @@ -import { Actions, StartAsyncValidationAction } from '../../actions'; +import { NgrxFormActionTypes, StartAsyncValidationAction} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer } from './util'; export function startAsyncValidationReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== StartAsyncValidationAction.TYPE) { + if (action.type !== StartAsyncValidationAction.type) { return state; } diff --git a/src/array/reducer/swap-control.spec.ts b/src/array/reducer/swap-control.spec.ts index 64723a0d..8577749f 100644 --- a/src/array/reducer/swap-control.spec.ts +++ b/src/array/reducer/swap-control.spec.ts @@ -9,14 +9,14 @@ describe(`form array ${swapControlReducer.name}`, () => { const testArrayState = createFormArrayState(FORM_CONTROL_ID, testArrayValue); it('should swap controls forwards', () => { - const action = new SwapArrayControlAction(FORM_CONTROL_ID, 0, 2); + const action = SwapArrayControlAction(FORM_CONTROL_ID, 0, 2); const resultState = swapControlReducer(testArrayState, action); expect(resultState.value).toEqual([2, 1, 0, 3, 4, 5]); expect(resultState.isDirty).toEqual(true); }); it('should swap controls backwards', () => { - const action = new SwapArrayControlAction(FORM_CONTROL_ID, 5, 1); + const action = SwapArrayControlAction(FORM_CONTROL_ID, 5, 1); const resultState = swapControlReducer(testArrayState, action); expect(resultState.value).toEqual([0, 5, 2, 3, 4, 1]); expect(resultState.isDirty).toEqual(true); @@ -26,24 +26,24 @@ describe(`form array ${swapControlReducer.name}`, () => { it('should throw on out of bound or negative indices', () => { expect(() => swapControlReducer( INITIAL_STATE_NESTED_GROUP, - new SwapArrayControlAction(FORM_CONTROL_ID, 0, INITIAL_STATE_NESTED_GROUP.controls.length)) + SwapArrayControlAction(FORM_CONTROL_ID, 0, INITIAL_STATE_NESTED_GROUP.controls.length)) ).toThrow(); expect(() => swapControlReducer( INITIAL_STATE_NESTED_GROUP, - new SwapArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, 0)) + SwapArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, 0)) ).toThrow(); expect(() => swapControlReducer( INITIAL_STATE_NESTED_GROUP, - new SwapArrayControlAction(FORM_CONTROL_ID, -3, INITIAL_STATE_NESTED_GROUP.controls.length)) + SwapArrayControlAction(FORM_CONTROL_ID, -3, INITIAL_STATE_NESTED_GROUP.controls.length)) ).toThrow(); expect(() => swapControlReducer( INITIAL_STATE_NESTED_GROUP, - new SwapArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, -2)) + SwapArrayControlAction(FORM_CONTROL_ID, INITIAL_STATE_NESTED_GROUP.controls.length, -2)) ).toThrow(); }); it('should update deeply nested child IDs after a swap', () => { - const action = new SwapArrayControlAction(FORM_CONTROL_ID, 0, 1); + const action = SwapArrayControlAction(FORM_CONTROL_ID, 0, 1); const resultState = swapControlReducer(INITIAL_STATE_NESTED_GROUP, action); resultState.controls.forEach((control, index) => { expect(control.id).toEqual(`${FORM_CONTROL_ID}.${index}`); @@ -52,14 +52,14 @@ describe(`form array ${swapControlReducer.name}`, () => { }); it('should return the state unmodified if no element was moved', () => { - const action = new SwapArrayControlAction(FORM_CONTROL_ID, 1, 1); + const action = SwapArrayControlAction(FORM_CONTROL_ID, 1, 1); const resultState = swapControlReducer(testArrayState, action); expect(resultState).toBe(testArrayState); expect(resultState.isDirty).toEqual(false); }); it('should return the state if applied on a different state ID', () => { - const action = new SwapArrayControlAction(FORM_CONTROL_0_ID, 0, 1); + const action = SwapArrayControlAction(FORM_CONTROL_0_ID, 0, 1); const resultState = swapControlReducer(testArrayState, action); expect(resultState).toBe(testArrayState); }); @@ -67,7 +67,7 @@ describe(`form array ${swapControlReducer.name}`, () => { it('should update nested array child IDs after a swap', () => { const testValue = [{ array: [0, 1, 2, 3] }, { array: [0, 1, 2, 3] }]; const testState = createFormArrayState(FORM_CONTROL_ID, testValue); - const action = new SwapArrayControlAction(FORM_CONTROL_ID, 0, 1); + const action = SwapArrayControlAction(FORM_CONTROL_ID, 0, 1); const resultState = moveControlReducer(testState, action); resultState.controls.forEach((control, index) => { expect(control.id).toEqual(`${FORM_CONTROL_ID}.${index}`); @@ -79,7 +79,7 @@ describe(`form array ${swapControlReducer.name}`, () => { }); it('should mark the array as dirty', () => { - const action = new SwapArrayControlAction(FORM_CONTROL_ID, 2, 1); + const action = SwapArrayControlAction(FORM_CONTROL_ID, 2, 1); const resultState = swapControlReducer(testArrayState, action); expect(resultState.isDirty).toEqual(true); }); diff --git a/src/array/reducer/swap-control.ts b/src/array/reducer/swap-control.ts index d4e7f7c6..376562a0 100644 --- a/src/array/reducer/swap-control.ts +++ b/src/array/reducer/swap-control.ts @@ -1,4 +1,4 @@ -import { Actions, SwapArrayControlAction } from '../../actions'; +import { NgrxFormActionTypes, SwapArrayControlAction} from '../../actions'; import { computeArrayState, FormArrayState } from '../../state'; import { childReducer, updateIdRecursive } from './util'; @@ -10,9 +10,9 @@ function swapArrayValues(a: readonly any[], i: number, j: number) { export function swapControlReducer( state: FormArrayState, - action: Actions, + action: NgrxFormActionTypes, ): FormArrayState { - if (action.type !== SwapArrayControlAction.TYPE) { + if (action.type !== SwapArrayControlAction.type) { return state; } diff --git a/src/array/reducer/util.ts b/src/array/reducer/util.ts index 94df5cee..500c0d54 100644 --- a/src/array/reducer/util.ts +++ b/src/array/reducer/util.ts @@ -1,10 +1,11 @@ -import { Actions } from '../../actions'; +import { NgrxFormActionTypes } from '../../actions'; import { formStateReducer } from '../../reducer'; import { computeArrayState, FormArrayState, FormGroupControls, FormGroupState, FormState, isArrayState, isGroupState } from '../../state'; + export function dispatchActionPerChild( controls: readonly FormState[], - actionCreator: (controlId: string) => Actions, + actionCreator: (controlId: string) => NgrxFormActionTypes, ): readonly FormState[] { let hasChanged = false; const newControls = controls @@ -19,7 +20,7 @@ export function dispatchActionPerChild( function callChildReducers( controls: readonly FormState[], - action: Actions, + action: NgrxFormActionTypes, ): readonly FormState[] { let hasChanged = false; const newControls = controls @@ -32,7 +33,7 @@ function callChildReducers( return hasChanged ? newControls : controls; } -export function childReducer(state: FormArrayState, action: Actions) { +export function childReducer(state: FormArrayState, action: NgrxFormActionTypes) { const controls = callChildReducers(state.controls, action); if (state.controls === controls) { diff --git a/src/control/directive.spec.ts b/src/control/directive.spec.ts index b6c439cb..ef44ff95 100644 --- a/src/control/directive.spec.ts +++ b/src/control/directive.spec.ts @@ -91,8 +91,8 @@ describe(NgrxFormControlDirective.name, () => { expect(spy).toHaveBeenCalledWith(INITIAL_STATE.value); }); - it('should not throw if id changes and new state is disabled but adapter does not support disabling', () => { - delete viewAdapter.setIsDisabled; + it('should not throw if id changes and State is disabled but adapter does not support disabling', () => { + delete (viewAdapter as FormViewAdapter).setIsDisabled; expect(() => directive.ngrxFormControlState = { ...INITIAL_STATE, id: `${FORM_CONTROL_ID}1`, isDisabled: true, isEnabled: false }).not.toThrowError(); }); @@ -121,7 +121,7 @@ describe(NgrxFormControlDirective.name, () => { }); it('should not throw after the view is initialized and adapter does not support disabling', () => { - delete viewAdapter.setIsDisabled; + delete (viewAdapter as FormViewAdapter).setIsDisabled; directive.ngrxFormControlState = { ...INITIAL_STATE, isDisabled: true, isEnabled: false }; expect(() => directive.ngAfterViewInit()).not.toThrowError(); }); @@ -130,7 +130,7 @@ describe(NgrxFormControlDirective.name, () => { const newValue = 'new value'; actions$.pipe(first()).subscribe(a => { - expect(a).toEqual(new SetValueAction(INITIAL_STATE.id, newValue)); + expect(a).toEqual(SetValueAction(INITIAL_STATE.id, newValue)); done(); }); @@ -149,7 +149,7 @@ describe(NgrxFormControlDirective.name, () => { it(`should dispatch a ${MarkAsDirtyAction.name} if the view value changes when the state is not marked as dirty`, done => { actions$.pipe(skip(1)).pipe(first()).subscribe(a => { - expect(a).toEqual(new MarkAsDirtyAction(INITIAL_STATE.id)); + expect(a).toEqual(MarkAsDirtyAction(INITIAL_STATE.id)); done(); }); @@ -202,7 +202,7 @@ describe(NgrxFormControlDirective.name, () => { it(`should dispatch a ${MarkAsTouchedAction.name} if the view adapter notifies and the state is not touched`, done => { actions$.pipe(first()).subscribe(a => { - expect(a).toEqual(new MarkAsTouchedAction(INITIAL_STATE.id)); + expect(a).toEqual(MarkAsTouchedAction(INITIAL_STATE.id)); done(); }); @@ -233,7 +233,7 @@ describe(NgrxFormControlDirective.name, () => { const newValue = 'new value'; actions$.pipe(first()).subscribe(a => { - expect(a).toEqual(new SetValueAction(INITIAL_STATE.id, newValue)); + expect(a).toEqual(SetValueAction(INITIAL_STATE.id, newValue)); done(); }); @@ -359,7 +359,7 @@ describe(NgrxFormControlDirective.name, () => { it('should convert the view value if it changes', done => { actions$.pipe(first()).subscribe(a => { - expect(a).toEqual(new SetValueAction(INITIAL_STATE.id, STATE_VALUE)); + expect(a).toEqual(SetValueAction(INITIAL_STATE.id, STATE_VALUE)); done(); }); @@ -429,7 +429,7 @@ describe(NgrxFormControlDirective.name, () => { directive.ngOnInit(); actions$.pipe(first()).subscribe(a => { - expect(a).toEqual(new FocusAction(INITIAL_STATE.id)); + expect(a).toEqual(FocusAction(INITIAL_STATE.id)); done(); }); @@ -456,7 +456,7 @@ describe(NgrxFormControlDirective.name, () => { directive.ngOnInit(); actions$.pipe(first()).subscribe(a => { - expect(a).toEqual(new UnfocusAction(INITIAL_STATE.id)); + expect(a).toEqual(UnfocusAction(INITIAL_STATE.id)); done(); }); diff --git a/src/control/directive.ts b/src/control/directive.ts index a93e7bad..b19c8851 100644 --- a/src/control/directive.ts +++ b/src/control/directive.ts @@ -14,7 +14,14 @@ import { import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { ActionsSubject } from '@ngrx/store'; -import { Actions, FocusAction, MarkAsDirtyAction, MarkAsTouchedAction, SetValueAction, UnfocusAction } from '../actions'; +import { + FocusAction, + MarkAsDirtyAction, + MarkAsTouchedAction, + NgrxFormActionTypes, + SetValueAction, + UnfocusAction +} from '../actions'; import { FormControlState, FormControlValueTypes } from '../state'; import { selectViewAdapter } from '../view-adapter/util'; import { FormViewAdapter, NGRX_FORM_VIEW_ADAPTER } from '../view-adapter/view-adapter'; @@ -193,7 +200,7 @@ export class NgrxFormControlDirective imp } } - protected dispatchAction(action: Actions>) { + protected dispatchAction(action: NgrxFormActionTypes) { if (this.actionsSubject !== null) { this.actionsSubject.next(action); } else { @@ -215,14 +222,14 @@ export class NgrxFormControlDirective imp const dispatchMarkAsDirtyAction = () => { if (this.state.isPristine) { - this.dispatchAction(new MarkAsDirtyAction(this.state.id)); + this.dispatchAction(MarkAsDirtyAction(this.state.id)); } }; const dispatchSetValueAction = () => { this.stateValue = this.ngrxValueConverter.convertViewToStateValue(this.viewValue); if (this.stateValue !== this.state.value) { - this.dispatchAction(new SetValueAction(this.state.id, this.stateValue as NgrxFormControlValueType)); + this.dispatchAction(SetValueAction(this.state.id, this.stateValue as NgrxFormControlValueType)); dispatchMarkAsDirtyAction(); } @@ -238,7 +245,7 @@ export class NgrxFormControlDirective imp this.viewAdapter.setOnTouchedCallback(() => { if (!this.state.isTouched && this.ngrxUpdateOn !== NGRX_UPDATE_ON_TYPE.NEVER) { - this.dispatchAction(new MarkAsTouchedAction(this.state.id)); + this.dispatchAction(MarkAsTouchedAction(this.state.id)); } if (this.ngrxUpdateOn === NGRX_UPDATE_ON_TYPE.BLUR) { @@ -265,7 +272,7 @@ export class NgrxFormControlDirective imp const isControlFocused = this.el.nativeElement === this.dom!.activeElement; if (isControlFocused !== this.state.isFocused) { - this.dispatchAction(isControlFocused ? new FocusAction(this.state.id) : new UnfocusAction(this.state.id)); + this.dispatchAction(isControlFocused ? FocusAction(this.state.id) : UnfocusAction(this.state.id)); } } } diff --git a/src/control/e2e.spec/local-state.spec.ts b/src/control/e2e.spec/local-state.spec.ts index ae40fa69..80a7a1a9 100644 --- a/src/control/e2e.spec/local-state.spec.ts +++ b/src/control/e2e.spec/local-state.spec.ts @@ -4,7 +4,7 @@ import { Action, ActionsSubject } from '@ngrx/store'; import { Observable, Subject } from 'rxjs'; import { count } from 'rxjs/operators'; -import { MarkAsDirtyAction } from '../../actions'; +import {MarkAsDirtyAction, NgrxFormActionTypes} from '../../actions'; import { NgrxFormsModule } from '../../module'; import { createFormControlState, FormControlState } from '../../state'; @@ -23,7 +23,7 @@ export class NumberSelectComponentLocalStateComponent { options = SELECT_NUMBER_OPTIONS; action: Action | null = null; - handleAction(actionParam: Action) { + handleAction(actionParam: NgrxFormActionTypes) { this.action = actionParam; } } @@ -76,6 +76,6 @@ describe(NumberSelectComponentLocalStateComponent.name, () => { element.dispatchEvent(new Event('change')); expect(component.action).toBeTruthy(); - expect(component.action!.type).toBe(MarkAsDirtyAction.TYPE); + expect(component.action!.type).toBe(MarkAsDirtyAction.type); }); }); diff --git a/src/control/e2e.spec/radio.spec.ts b/src/control/e2e.spec/radio.spec.ts index 5a7e1c04..ad67b29b 100644 --- a/src/control/e2e.spec/radio.spec.ts +++ b/src/control/e2e.spec/radio.spec.ts @@ -4,7 +4,7 @@ import { Action, ActionsSubject } from '@ngrx/store'; import { Observable, Subject } from 'rxjs'; import { bufferCount, skip, take } from 'rxjs/operators'; -import { MarkAsDirtyAction, SetValueAction } from '../../actions'; +import {MarkAsDirtyAction, SetValueAction, NgrxFormActionTypes} from '../../actions'; import { NgrxFormsModule } from '../../module'; import { createFormControlState, FormControlState } from '../../state'; @@ -25,7 +25,7 @@ describe(RadioTestComponent.name, () => { let component: RadioTestComponent; let fixture: ComponentFixture; let actionsSubject: ActionsSubject; - let actions$: Observable; + let actions$: Observable; let element1: HTMLInputElement; let element2: HTMLInputElement; const FORM_CONTROL_ID = 'test ID'; @@ -34,7 +34,7 @@ describe(RadioTestComponent.name, () => { beforeEach(() => { actionsSubject = new Subject() as ActionsSubject; - actions$ = actionsSubject as Observable; // cast required due to mismatch of lift() function signature + actions$ = actionsSubject as unknown as Observable; // cast required due to mismatch of lift() function signature }); beforeEach(async(() => { @@ -78,8 +78,8 @@ describe(RadioTestComponent.name, () => { it(`should trigger a ${SetValueAction.name} with the selected value when an option is selected`, done => { actions$.pipe(take(1)).subscribe(a => { - expect(a.type).toBe(SetValueAction.TYPE); - expect((a as SetValueAction).value).toBe(RADIO_OPTIONS[0]); + expect(a.type).toBe(SetValueAction.type); + // expect((a as SetValueAction).value).toBe(RADIO_OPTIONS[0]); done(); }); @@ -88,7 +88,7 @@ describe(RadioTestComponent.name, () => { it(`should trigger a ${MarkAsDirtyAction.name} when an option is selected`, done => { actions$.pipe(skip(1), take(1)).subscribe(a => { - expect(a.type).toBe(MarkAsDirtyAction.TYPE); + expect(a.type).toBe(MarkAsDirtyAction.type); done(); }); @@ -97,12 +97,12 @@ describe(RadioTestComponent.name, () => { it(`should trigger ${SetValueAction.name}s and ${MarkAsDirtyAction.name}s when switching between options`, done => { actions$.pipe(bufferCount(4), take(1)).subscribe(([a1, a2, a3, a4]) => { - expect(a1.type).toBe(SetValueAction.TYPE); - expect(a2.type).toBe(MarkAsDirtyAction.TYPE); - expect(a3.type).toBe(SetValueAction.TYPE); - expect(a4.type).toBe(MarkAsDirtyAction.TYPE); - expect((a1 as SetValueAction).value).toBe(RADIO_OPTIONS[0]); - expect((a3 as SetValueAction).value).toBe(RADIO_OPTIONS[1]); + expect(a1.type).toBe(SetValueAction.type); + expect(a2.type).toBe(MarkAsDirtyAction.type); + expect(a3.type).toBe(SetValueAction.type); + expect(a4.type).toBe(MarkAsDirtyAction.type); + // expect((a1 as SetValueAction).value).toBe(RADIO_OPTIONS[0]); + // expect((a3 as SetValueAction).value).toBe(RADIO_OPTIONS[1]); done(); }); @@ -116,8 +116,8 @@ describe(RadioTestComponent.name, () => { const newValue = 'new value'; actions$.pipe(take(1)).subscribe(a => { - expect(a.type).toBe(SetValueAction.TYPE); - expect((a as SetValueAction).value).toBe(newValue); + expect(a.type).toBe(SetValueAction.type); + // expect((a as SetValueAction).value).toBe(newValue); done(); }); diff --git a/src/control/e2e.spec/select-multiple.spec.ts b/src/control/e2e.spec/select-multiple.spec.ts index 6a2233d6..f79d5c83 100644 --- a/src/control/e2e.spec/select-multiple.spec.ts +++ b/src/control/e2e.spec/select-multiple.spec.ts @@ -69,8 +69,8 @@ describe(SelectMultipleComponent.name, () => { it('should trigger a SetValueAction with the selected value when an option is selected', done => { actions$.pipe(first()).subscribe(a => { - expect(a.type).toBe(SetValueAction.TYPE); - expect((a as SetValueAction).value).toBe(JSON.stringify(SELECT_OPTIONS)); + expect(a.type).toBe(SetValueAction.type); + // expect((a as SetValueAction).value).toBe(JSON.stringify(SELECT_OPTIONS)); done(); }); @@ -80,7 +80,7 @@ describe(SelectMultipleComponent.name, () => { it(`should trigger a ${MarkAsDirtyAction.name} when an option is selected`, done => { actions$.pipe(skip(1), first()).subscribe(a => { - expect(a.type).toBe(MarkAsDirtyAction.TYPE); + expect(a.type).toBe(MarkAsDirtyAction.type); done(); }); @@ -145,8 +145,8 @@ describe(SelectMultipleWithoutConverterComponent.name, () => { it('should trigger a SetValueAction with the selected value when an option is selected', done => { actions$.pipe(first()).subscribe(a => { - expect(a.type).toBe(SetValueAction.TYPE); - expect((a as SetValueAction>).value).toEqual(box(SELECT_OPTIONS)); + expect(a.type).toBe(SetValueAction.type); + // expect((a as SetValueAction>).value).toEqual(box(SELECT_OPTIONS)); done(); }); @@ -156,7 +156,7 @@ describe(SelectMultipleWithoutConverterComponent.name, () => { it(`should trigger a ${MarkAsDirtyAction.name} when an option is selected`, done => { actions$.pipe(skip(1), first()).subscribe(a => { - expect(a.type).toBe(MarkAsDirtyAction.TYPE); + expect(a.type).toBe(MarkAsDirtyAction.type); done(); }); diff --git a/src/control/e2e.spec/select.spec.ts b/src/control/e2e.spec/select.spec.ts index 3e9b8a4b..28939fc8 100644 --- a/src/control/e2e.spec/select.spec.ts +++ b/src/control/e2e.spec/select.spec.ts @@ -70,8 +70,8 @@ describe(SelectComponent.name, () => { it(`should trigger a ${SetValueAction.name} with the selected value when an option is selected`, done => { actions$.pipe(first()).subscribe(a => { - expect(a.type).toBe(SetValueAction.TYPE); - expect((a as SetValueAction).value).toBe(SELECT_OPTIONS[0]); + expect(a.type).toBe(SetValueAction.type); + // expect((a as SetValueAction).value).toBe(SELECT_OPTIONS[0]); done(); }); @@ -81,7 +81,7 @@ describe(SelectComponent.name, () => { it(`should trigger a ${MarkAsDirtyAction.name} when an option is selected`, done => { actions$.pipe(skip(1), first()).subscribe(a => { - expect(a.type).toBe(MarkAsDirtyAction.TYPE); + expect(a.type).toBe(MarkAsDirtyAction.type); done(); }); @@ -153,8 +153,8 @@ describe(NumberSelectComponent.name, () => { it(`should trigger a ${SetValueAction.name} with the selected value when an option is selected`, done => { actions$.pipe(first()).subscribe(a => { - expect(a.type).toBe(SetValueAction.TYPE); - expect((a as SetValueAction).value).toBe(SELECT_NUMBER_OPTIONS[0]); + expect(a.type).toBe(SetValueAction.type); + // expect((a as SetValueAction).value).toBe(SELECT_NUMBER_OPTIONS[0]); done(); }); @@ -164,7 +164,7 @@ describe(NumberSelectComponent.name, () => { it(`should trigger a ${MarkAsDirtyAction.name} when an option is selected`, done => { actions$.pipe(skip(1), first()).subscribe(a => { - expect(a.type).toBe(MarkAsDirtyAction.TYPE); + expect(a.type).toBe(MarkAsDirtyAction.type); done(); }); diff --git a/src/control/local-state-directive.spec.ts b/src/control/local-state-directive.spec.ts index a7edb453..56770332 100644 --- a/src/control/local-state-directive.spec.ts +++ b/src/control/local-state-directive.spec.ts @@ -60,7 +60,7 @@ describe(NgrxLocalFormControlDirective.name, () => { const newValue = 'new value'; directive.ngrxFormsAction.pipe(first()).subscribe(a => { - expect(a).toEqual(new SetValueAction(INITIAL_STATE.id, newValue)); + expect(a).toEqual(SetValueAction(INITIAL_STATE.id, newValue)); done(); }); diff --git a/src/control/local-state-directive.ts b/src/control/local-state-directive.ts index 45ff5229..1a4da0e8 100644 --- a/src/control/local-state-directive.ts +++ b/src/control/local-state-directive.ts @@ -10,9 +10,9 @@ import { } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { Actions } from '../actions'; import { FormViewAdapter, NGRX_FORM_VIEW_ADAPTER } from '../view-adapter/view-adapter'; -import { Document, NgrxFormControlDirective, NgrxFormControlValueType } from './directive'; +import {Document, NgrxFormControlDirective} from './directive'; +import {NgrxFormActionTypes} from "../actions"; @Directive({ // tslint:disable-next-line:directive-selector @@ -21,7 +21,7 @@ import { Document, NgrxFormControlDirective, NgrxFormControlValueType } from './ export class NgrxLocalFormControlDirective extends NgrxFormControlDirective { - @Output() ngrxFormsAction = new EventEmitter>>(); + @Output() ngrxFormsAction = new EventEmitter(); // type fix me constructor( el: ElementRef, @@ -32,7 +32,7 @@ export class NgrxLocalFormControlDirective>) { + protected dispatchAction(action: NgrxFormActionTypes) { this.ngrxFormsAction.emit(action); } } diff --git a/src/control/reducer.spec.ts b/src/control/reducer.spec.ts index af09ffe9..0011980f 100644 --- a/src/control/reducer.spec.ts +++ b/src/control/reducer.spec.ts @@ -26,14 +26,14 @@ describe('form control reducer', () => { const INITIAL_STATE = createFormControlState(FORM_CONTROL_ID, INITIAL_FORM_CONTROL_VALUE); it('should skip any action with non-equal control ID', () => { - const resultState = formControlReducer(INITIAL_STATE, new SetValueAction(`${FORM_CONTROL_ID}A`, 'A')); + const resultState = formControlReducer(INITIAL_STATE, SetValueAction(`${FORM_CONTROL_ID}A`, 'A')); expect(resultState).toBe(INITIAL_STATE); }); it('should preserve the order of properties when stringified', () => { const expected = JSON.stringify(INITIAL_STATE); - let state = formControlReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); - state = formControlReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + let state = formControlReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); + state = formControlReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(JSON.stringify(state)).toEqual(expected); }); @@ -42,12 +42,12 @@ describe('form control reducer', () => { }); it('should throw if state is not a control state', () => { - expect(() => formControlReducer({ ...INITIAL_STATE, value: [], controls: [] } as any, new MarkAsDirtyAction(FORM_CONTROL_ID))).toThrowError(); + expect(() => formControlReducer({ ...INITIAL_STATE, value: [], controls: [] } as any, MarkAsDirtyAction(FORM_CONTROL_ID))).toThrowError(); }); describe(SetValueAction.name, () => { it('should update state', () => { - const resultState = formControlReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, 'A')); + const resultState = formControlReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, 'A')); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -55,7 +55,7 @@ describe('form control reducer', () => { describe(SetErrorsAction.name, () => { it('should update state', () => { const errors = { required: true }; - const resultState = formControlReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = formControlReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -63,7 +63,7 @@ describe('form control reducer', () => { describe(StartAsyncValidationAction.name, () => { it('should update state', () => { const name = 'required'; - const resultState = formControlReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = formControlReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -73,7 +73,7 @@ describe('form control reducer', () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = formControlReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = formControlReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -90,14 +90,14 @@ describe('form control reducer', () => { isValidationPending: true, }; - const resultState = formControlReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = formControlReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsDirtyAction.name, () => { it('should update state', () => { - const resultState = formControlReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -105,7 +105,7 @@ describe('form control reducer', () => { describe(MarkAsPristineAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = formControlReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -113,21 +113,21 @@ describe('form control reducer', () => { describe(EnableAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = formControlReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(DisableAction.name, () => { it('should update state', () => { - const resultState = formControlReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsTouchedAction.name, () => { it('should update state', () => { - const resultState = formControlReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -135,14 +135,14 @@ describe('form control reducer', () => { describe(MarkAsUntouchedAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = formControlReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(FocusAction.name, () => { it('should update state', () => { - const resultState = formControlReducer(INITIAL_STATE, new FocusAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(INITIAL_STATE, FocusAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -150,21 +150,21 @@ describe('form control reducer', () => { describe(UnfocusAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isFocused: true, isUnfocused: false }; - const resultState = formControlReducer(state, new UnfocusAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(state, UnfocusAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(SetUserDefinedPropertyAction.name, () => { it('should update state', () => { - const resultState = formControlReducer(INITIAL_STATE, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, 'prop', 12)); + const resultState = formControlReducer(INITIAL_STATE, SetUserDefinedPropertyAction(FORM_CONTROL_ID, 'prop', 12)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsSubmittedAction.name, () => { it('should update state', () => { - const resultState = formControlReducer(INITIAL_STATE, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(INITIAL_STATE, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -172,7 +172,7 @@ describe('form control reducer', () => { describe(MarkAsUnsubmittedAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = formControlReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -180,7 +180,7 @@ describe('form control reducer', () => { describe(ResetAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = formControlReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = formControlReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/control/reducer.ts b/src/control/reducer.ts index 6485eb82..c4b22371 100644 --- a/src/control/reducer.ts +++ b/src/control/reducer.ts @@ -1,6 +1,5 @@ import { Action } from '@ngrx/store'; -import { Actions } from '../actions'; import { FormControlState, FormControlValueTypes, isArrayState, isGroupState } from '../state'; import { clearAsyncErrorReducer } from './reducer/clear-async-error'; import { disableReducer } from './reducer/disable'; @@ -19,10 +18,11 @@ import { setUserDefinedPropertyReducer } from './reducer/set-user-defined-proper import { setValueReducer } from './reducer/set-value'; import { startAsyncValidationReducer } from './reducer/start-async-validation'; import { unfocusReducer } from './reducer/unfocus'; +import {NgrxFormActionTypes} from "../actions"; export function formControlReducerInternal( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { if (isGroupState(state) || isArrayState(state)) { throw new Error('The state must be a control state'); diff --git a/src/control/reducer/clear-async-error.spec.ts b/src/control/reducer/clear-async-error.spec.ts index a067e571..1d0b4311 100644 --- a/src/control/reducer/clear-async-error.spec.ts +++ b/src/control/reducer/clear-async-error.spec.ts @@ -12,7 +12,7 @@ describe(`form control ${clearAsyncErrorReducer.name}`, () => { it('should remove error from state', () => { const name = 'required'; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: true }, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -21,7 +21,7 @@ describe(`form control ${clearAsyncErrorReducer.name}`, () => { it('should remove the validation from pending validations if validation is the last pending', () => { const name = 'required'; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: true }, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); @@ -38,7 +38,7 @@ describe(`form control ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([name2]); expect(resultState.isValidationPending).toBe(true); }); @@ -47,7 +47,7 @@ describe(`form control ${clearAsyncErrorReducer.name}`, () => { const name = 'required'; const errors = { $min: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toBe(errors); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -64,7 +64,7 @@ describe(`form control ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ $min: true }); expect(resultState.pendingValidations).toEqual(state.pendingValidations); expect(resultState.isValidationPending).toBe(state.isValidationPending); @@ -81,7 +81,7 @@ describe(`form control ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState).toBe(state); }); @@ -96,7 +96,7 @@ describe(`form control ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); diff --git a/src/control/reducer/clear-async-error.ts b/src/control/reducer/clear-async-error.ts index 99497a2d..74b97f13 100644 --- a/src/control/reducer/clear-async-error.ts +++ b/src/control/reducer/clear-async-error.ts @@ -1,12 +1,12 @@ -import { Actions, ClearAsyncErrorAction } from '../../actions'; +import {ClearAsyncErrorAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; import { isEmpty } from '../../util'; export function clearAsyncErrorReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== ClearAsyncErrorAction.TYPE) { + if (action.type !== ClearAsyncErrorAction.type) { return state; } diff --git a/src/control/reducer/disable.spec.ts b/src/control/reducer/disable.spec.ts index 201f07a4..45237d96 100644 --- a/src/control/reducer/disable.spec.ts +++ b/src/control/reducer/disable.spec.ts @@ -10,21 +10,21 @@ describe('form control disableReducer', () => { it('should skip any actionof the wrong type', () => expect(disableReducer(INITIAL_STATE, { type: '' } as any)).toBe(INITIAL_STATE)); it('should update state if enabled', () => { - const resultState = disableReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState.isEnabled).toEqual(false); expect(resultState.isDisabled).toEqual(true); }); it('should not update state if disabled', () => { const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState).toBe(state); }); it('should mark the state as valid and clear all errors', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState.isValid).toEqual(true); expect(resultState.isInvalid).toEqual(false); expect(resultState.errors).toEqual({}); @@ -32,7 +32,7 @@ describe('form control disableReducer', () => { it('should clear all pending validations', () => { const state = { ...INITIAL_STATE, pendingValidations: ['required'], isValidationPending: true }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); diff --git a/src/control/reducer/disable.ts b/src/control/reducer/disable.ts index 4f8ce951..9ee62994 100644 --- a/src/control/reducer/disable.ts +++ b/src/control/reducer/disable.ts @@ -1,11 +1,11 @@ -import { Actions, DisableAction } from '../../actions'; +import { DisableAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function disableReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== DisableAction.TYPE) { + if (action.type !== DisableAction.type) { return state; } diff --git a/src/control/reducer/enable.spec.ts b/src/control/reducer/enable.spec.ts index db2efd78..f77a85b4 100644 --- a/src/control/reducer/enable.spec.ts +++ b/src/control/reducer/enable.spec.ts @@ -11,13 +11,13 @@ describe('form control enableReducer', () => { it('should update state if disabled', () => { const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = enableReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState.isEnabled).toEqual(true); expect(resultState.isDisabled).toEqual(false); }); it('should not update state if enabled', () => { - const resultState = enableReducer(INITIAL_STATE, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(INITIAL_STATE, EnableAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); }); diff --git a/src/control/reducer/enable.ts b/src/control/reducer/enable.ts index e84ae182..9918fc31 100644 --- a/src/control/reducer/enable.ts +++ b/src/control/reducer/enable.ts @@ -1,11 +1,11 @@ -import { Actions, EnableAction } from '../../actions'; +import {EnableAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function enableReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== EnableAction.TYPE) { + if (action.type !== EnableAction.type) { return state; } diff --git a/src/control/reducer/focus.spec.ts b/src/control/reducer/focus.spec.ts index 9a40021a..d2e35980 100644 --- a/src/control/reducer/focus.spec.ts +++ b/src/control/reducer/focus.spec.ts @@ -10,14 +10,14 @@ describe('form control focusReducer', () => { it('should skip any actionof the wrong type', () => expect(focusReducer(INITIAL_STATE, { type: '' } as any)).toBe(INITIAL_STATE)); it('should update state if unfocused', () => { - const resultState = focusReducer(INITIAL_STATE, new FocusAction(FORM_CONTROL_ID)); + const resultState = focusReducer(INITIAL_STATE, FocusAction(FORM_CONTROL_ID)); expect(resultState.isFocused).toEqual(true); expect(resultState.isUnfocused).toEqual(false); }); it('should not update state if focused', () => { const state = { ...INITIAL_STATE, isFocused: true, isUnfocused: false }; - const resultState = focusReducer(state, new FocusAction(FORM_CONTROL_ID)); + const resultState = focusReducer(state, FocusAction(FORM_CONTROL_ID)); expect(resultState).toBe(state); }); }); diff --git a/src/control/reducer/focus.ts b/src/control/reducer/focus.ts index cb2c9268..39da3e43 100644 --- a/src/control/reducer/focus.ts +++ b/src/control/reducer/focus.ts @@ -1,11 +1,11 @@ -import { Actions, FocusAction } from '../../actions'; +import { FocusAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function focusReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== FocusAction.TYPE) { + if (action.type !== FocusAction.type) { return state; } diff --git a/src/control/reducer/mark-as-dirty.spec.ts b/src/control/reducer/mark-as-dirty.spec.ts index 8dea8927..39fcce9f 100644 --- a/src/control/reducer/mark-as-dirty.spec.ts +++ b/src/control/reducer/mark-as-dirty.spec.ts @@ -11,14 +11,14 @@ describe('form control markAsDirtyReducer', () => { expect(markAsDirtyReducer(INITIAL_STATE, { type: '' } as any)).toBe(INITIAL_STATE)); it('should update state if pristine', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(true); expect(resultState.isPristine).toEqual(false); }); it('should not update state if dirty', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = markAsDirtyReducer(state, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(state, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).toBe(state); }); }); diff --git a/src/control/reducer/mark-as-dirty.ts b/src/control/reducer/mark-as-dirty.ts index 1bbf9621..f184bcc9 100644 --- a/src/control/reducer/mark-as-dirty.ts +++ b/src/control/reducer/mark-as-dirty.ts @@ -1,11 +1,11 @@ -import { Actions, MarkAsDirtyAction } from '../../actions'; +import { MarkAsDirtyAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function markAsDirtyReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== MarkAsDirtyAction.TYPE) { + if (action.type !== MarkAsDirtyAction.type) { return state; } diff --git a/src/control/reducer/mark-as-pristine.spec.ts b/src/control/reducer/mark-as-pristine.spec.ts index b7feaaec..bac50298 100644 --- a/src/control/reducer/mark-as-pristine.spec.ts +++ b/src/control/reducer/mark-as-pristine.spec.ts @@ -12,13 +12,13 @@ describe('form control maskAsPristineReducer', () => { it('should update state if dirty', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); }); it('should not update state if pristine', () => { - const resultState = markAsPristineReducer(INITIAL_STATE, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(INITIAL_STATE, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); }); diff --git a/src/control/reducer/mark-as-pristine.ts b/src/control/reducer/mark-as-pristine.ts index ab8cccee..226e269f 100644 --- a/src/control/reducer/mark-as-pristine.ts +++ b/src/control/reducer/mark-as-pristine.ts @@ -1,11 +1,11 @@ -import { Actions, MarkAsPristineAction } from '../../actions'; +import {MarkAsPristineAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function markAsPristineReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== MarkAsPristineAction.TYPE) { + if (action.type !== MarkAsPristineAction.type) { return state; } diff --git a/src/control/reducer/mark-as-submitted.spec.ts b/src/control/reducer/mark-as-submitted.spec.ts index 55d3dcb3..edb700db 100644 --- a/src/control/reducer/mark-as-submitted.spec.ts +++ b/src/control/reducer/mark-as-submitted.spec.ts @@ -11,14 +11,14 @@ describe('form control markAsSubmittedReducer', () => { expect(markAsSubmittedReducer(INITIAL_STATE, { type: '' } as any)).toBe(INITIAL_STATE)); it('should update state if unsubmitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.isSubmitted).toEqual(true); expect(resultState.isUnsubmitted).toEqual(false); }); it('should not update state if submitted', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = markAsSubmittedReducer(state, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(state, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).toBe(state); }); }); diff --git a/src/control/reducer/mark-as-submitted.ts b/src/control/reducer/mark-as-submitted.ts index a9a1ef81..67732b29 100644 --- a/src/control/reducer/mark-as-submitted.ts +++ b/src/control/reducer/mark-as-submitted.ts @@ -1,11 +1,11 @@ -import { Actions, MarkAsSubmittedAction } from '../../actions'; +import { MarkAsSubmittedAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function markAsSubmittedReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== MarkAsSubmittedAction.TYPE) { + if (action.type !== MarkAsSubmittedAction.type) { return state; } diff --git a/src/control/reducer/mark-as-touched.spec.ts b/src/control/reducer/mark-as-touched.spec.ts index ed85fba9..c80fcc06 100644 --- a/src/control/reducer/mark-as-touched.spec.ts +++ b/src/control/reducer/mark-as-touched.spec.ts @@ -11,14 +11,14 @@ describe('form control markAsTouchedReducer', () => { expect(markAsTouchedReducer(INITIAL_STATE, { type: '' } as any)).toBe(INITIAL_STATE)); it('should update state if untouched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.isTouched).toEqual(true); expect(resultState.isUntouched).toEqual(false); }); it('should not update state if touched', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = markAsTouchedReducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).toBe(state); }); }); diff --git a/src/control/reducer/mark-as-touched.ts b/src/control/reducer/mark-as-touched.ts index 96908d6a..ccb64b70 100644 --- a/src/control/reducer/mark-as-touched.ts +++ b/src/control/reducer/mark-as-touched.ts @@ -1,11 +1,11 @@ -import { Actions, MarkAsTouchedAction } from '../../actions'; +import { MarkAsTouchedAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function markAsTouchedReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== MarkAsTouchedAction.TYPE) { + if (action.type !== MarkAsTouchedAction.type) { return state; } diff --git a/src/control/reducer/mark-as-unsubmitted.spec.ts b/src/control/reducer/mark-as-unsubmitted.spec.ts index 348dc44d..7a6c34e3 100644 --- a/src/control/reducer/mark-as-unsubmitted.spec.ts +++ b/src/control/reducer/mark-as-unsubmitted.spec.ts @@ -13,13 +13,13 @@ describe('form control markAsUnsubmittedReducer', () => { describe(MarkAsUnsubmittedAction.name, () => { it('should update state if submitted', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.isSubmitted).toEqual(false); expect(resultState.isUnsubmitted).toEqual(true); }); it('should not update state if unsubmitted', () => { - const resultState = markAsUnsubmittedReducer(INITIAL_STATE, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(INITIAL_STATE, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); }); diff --git a/src/control/reducer/mark-as-unsubmitted.ts b/src/control/reducer/mark-as-unsubmitted.ts index 2fd12d34..08fba830 100644 --- a/src/control/reducer/mark-as-unsubmitted.ts +++ b/src/control/reducer/mark-as-unsubmitted.ts @@ -1,11 +1,11 @@ -import { Actions, MarkAsUnsubmittedAction } from '../../actions'; +import { MarkAsUnsubmittedAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function markAsUnsubmittedReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== MarkAsUnsubmittedAction.TYPE) { + if (action.type !== MarkAsUnsubmittedAction.type) { return state; } diff --git a/src/control/reducer/mark-as-untouched.spec.ts b/src/control/reducer/mark-as-untouched.spec.ts index a9149adb..1afb7037 100644 --- a/src/control/reducer/mark-as-untouched.spec.ts +++ b/src/control/reducer/mark-as-untouched.spec.ts @@ -12,13 +12,13 @@ describe('form control markAsUntouchedReducer', () => { it('should update state if touched', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.isTouched).toEqual(false); expect(resultState.isUntouched).toEqual(true); }); it('should not update state if untouched', () => { - const resultState = markAsUntouchedReducer(INITIAL_STATE, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(INITIAL_STATE, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); }); diff --git a/src/control/reducer/mark-as-untouched.ts b/src/control/reducer/mark-as-untouched.ts index bd4f3f4c..2bfa7ea1 100644 --- a/src/control/reducer/mark-as-untouched.ts +++ b/src/control/reducer/mark-as-untouched.ts @@ -1,11 +1,11 @@ -import { Actions, MarkAsUntouchedAction } from '../../actions'; +import { MarkAsUntouchedAction, NgrxFormActionTypes} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function markAsUntouchedReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== MarkAsUntouchedAction.TYPE) { + if (action.type !== MarkAsUntouchedAction.type) { return state; } diff --git a/src/control/reducer/reset.spec.ts b/src/control/reducer/reset.spec.ts index 62821d18..57b230f1 100644 --- a/src/control/reducer/reset.spec.ts +++ b/src/control/reducer/reset.spec.ts @@ -12,7 +12,7 @@ describe(`form control ${resetReducer.name}`, () => { it('should update state if dirty', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -23,7 +23,7 @@ describe(`form control ${resetReducer.name}`, () => { it('should update state if touched', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -34,7 +34,7 @@ describe(`form control ${resetReducer.name}`, () => { it('should update state if submitted', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -44,7 +44,7 @@ describe(`form control ${resetReducer.name}`, () => { }); it('should not update state if pristine and untouched and unsubmitted', () => { - const resultState = resetReducer(INITIAL_STATE, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(INITIAL_STATE, ResetAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); }); diff --git a/src/control/reducer/reset.ts b/src/control/reducer/reset.ts index fcc0613a..7d5139dd 100644 --- a/src/control/reducer/reset.ts +++ b/src/control/reducer/reset.ts @@ -1,11 +1,11 @@ -import { Actions, ResetAction } from '../../actions'; +import { NgrxFormActionTypes, ResetAction} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function resetReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== ResetAction.TYPE) { + if (action.type !== ResetAction.type) { return state; } diff --git a/src/control/reducer/set-async-error.spec.ts b/src/control/reducer/set-async-error.spec.ts index 0a861e86..4e4dbd92 100644 --- a/src/control/reducer/set-async-error.spec.ts +++ b/src/control/reducer/set-async-error.spec.ts @@ -13,7 +13,7 @@ describe(`form control ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors).toEqual({ [`$${name}`]: value }); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -23,7 +23,7 @@ describe(`form control ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); @@ -33,7 +33,7 @@ describe(`form control ${setAsyncErrorReducer.name}`, () => { const name2 = 'min'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name, name2], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([name2]); expect(resultState.isValidationPending).toBe(true); }); @@ -42,7 +42,7 @@ describe(`form control ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: value }, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors[`$${name}`]).toBe(value); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -52,7 +52,7 @@ describe(`form control ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = { field: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: value }, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, { ...value })); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, { ...value })); expect(resultState.errors[`$${name}`]).toBe(value); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -62,7 +62,7 @@ describe(`form control ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState).toBe(state); }); @@ -70,7 +70,7 @@ describe(`form control ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: ['min'], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors).toEqual({ [`$${name}`]: value }); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); diff --git a/src/control/reducer/set-async-error.ts b/src/control/reducer/set-async-error.ts index 0e6db04e..6801affa 100644 --- a/src/control/reducer/set-async-error.ts +++ b/src/control/reducer/set-async-error.ts @@ -1,12 +1,12 @@ -import { Actions, SetAsyncErrorAction } from '../../actions'; +import {NgrxFormActionTypes, SetAsyncErrorAction} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; import { deepEquals } from '../../util'; export function setAsyncErrorReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== SetAsyncErrorAction.TYPE) { + if (action.type !== SetAsyncErrorAction.type) { return state; } diff --git a/src/control/reducer/set-errors.spec.ts b/src/control/reducer/set-errors.spec.ts index 871dbb37..a8ec7259 100644 --- a/src/control/reducer/set-errors.spec.ts +++ b/src/control/reducer/set-errors.spec.ts @@ -11,7 +11,7 @@ describe('form control setErrorsReducer', () => { it('should update state if there are errors', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState.errors).toBe(errors); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -21,7 +21,7 @@ describe('form control setErrorsReducer', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors }; const newErrors = {}; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, newErrors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, newErrors)); expect(resultState.errors).toBe(newErrors); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -29,25 +29,25 @@ describe('form control setErrorsReducer', () => { it('should not update state if errors are same', () => { const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { required: true } }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, state.errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, state.errors)); expect(resultState).toBe(state); }); it('should not update state if errors are equal', () => { const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { required: true } }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, { required: true })); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, { required: true })); expect(resultState).toBe(state); }); it('should not update state if control is disabled', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState).toBe(state); }); it('should not update state if errors are equal and empty', () => { - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, {})); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, {})); expect(resultState).toBe(INITIAL_STATE); }); @@ -55,14 +55,14 @@ describe('form control setErrorsReducer', () => { const syncErrors = { required: true }; const asyncErrors = { $required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: asyncErrors }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, syncErrors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, syncErrors)); expect(resultState.errors).toEqual({ ...asyncErrors, ...syncErrors }); }); it('should throw if trying to set invalid error value', () => { - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, null as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, 1 as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, [] as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, { $required: true }))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, null as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, 1 as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, [] as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, { $required: true }))).toThrowError(); }); }); diff --git a/src/control/reducer/set-errors.ts b/src/control/reducer/set-errors.ts index 4be1250b..947235ab 100644 --- a/src/control/reducer/set-errors.ts +++ b/src/control/reducer/set-errors.ts @@ -1,12 +1,12 @@ -import { Actions, SetErrorsAction } from '../../actions'; +import {NgrxFormActionTypes, SetErrorsAction} from '../../actions'; import { FormControlState, FormControlValueTypes, ValidationErrors } from '../../state'; import { deepEquals, isEmpty } from '../../util'; export function setErrorsReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== SetErrorsAction.TYPE) { + if (action.type !== SetErrorsAction.type) { return state; } diff --git a/src/control/reducer/set-user-defined-property.spec.ts b/src/control/reducer/set-user-defined-property.spec.ts index 1bc0e666..7bc26787 100644 --- a/src/control/reducer/set-user-defined-property.spec.ts +++ b/src/control/reducer/set-user-defined-property.spec.ts @@ -13,7 +13,7 @@ describe('form control setUserDefinedPropertyReducer', () => { it('should update state user defined properties if different', () => { const prop = 'prop'; const value = 12; - const resultState = setUserDefinedPropertyReducer(INITIAL_STATE, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(INITIAL_STATE,SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); expect(resultState.userDefinedProperties).toEqual({ [prop]: value, }); @@ -23,7 +23,7 @@ describe('form control setUserDefinedPropertyReducer', () => { const prop = 'prop'; const value = 12; const state = { ...INITIAL_STATE, userDefinedProperties: { [prop]: value } }; - const resultState = setUserDefinedPropertyReducer(state, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(state,SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); expect(resultState).toBe(state); }); @@ -33,7 +33,7 @@ describe('form control setUserDefinedPropertyReducer', () => { const value = 12; const value2 = 13; const state = { ...INITIAL_STATE, userDefinedProperties: { [prop]: value } }; - const resultState = setUserDefinedPropertyReducer(state, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop2, value2)); + const resultState = setUserDefinedPropertyReducer(state,SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop2, value2)); expect(resultState.userDefinedProperties).toEqual({ [prop]: value, [prop2]: value2, diff --git a/src/control/reducer/set-user-defined-property.ts b/src/control/reducer/set-user-defined-property.ts index d0f1217b..c7d57312 100644 --- a/src/control/reducer/set-user-defined-property.ts +++ b/src/control/reducer/set-user-defined-property.ts @@ -1,11 +1,11 @@ -import { Actions, SetUserDefinedPropertyAction } from '../../actions'; +import {NgrxFormActionTypes, SetUserDefinedPropertyAction} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function setUserDefinedPropertyReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== SetUserDefinedPropertyAction.TYPE) { + if (action.type !== SetUserDefinedPropertyAction.type) { return state; } diff --git a/src/control/reducer/set-value.spec.ts b/src/control/reducer/set-value.spec.ts index e909984c..841a4c25 100644 --- a/src/control/reducer/set-value.spec.ts +++ b/src/control/reducer/set-value.spec.ts @@ -12,50 +12,50 @@ describe('form control setValueReducer', () => { it('should update state value if different', () => { const value = 'A'; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); }); it('should not update state value if same', () => { const value = 'A'; const state = { ...INITIAL_STATE, value }; - const resultState = setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(state, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState).toBe(state); }); it('should not mark state as dirty', () => { const value = 'A'; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.isDirty).toEqual(false); }); it('should throw for date values', () => { const value = new Date(1970, 0, 1); const state = createFormControlState(FORM_CONTROL_ID, null); - expect(() => setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, value))).toThrowError(); + expect(() => setValueReducer(state, SetValueAction(FORM_CONTROL_ID, value))).toThrowError(); }); it('should throw if value is not supported', () => { const value = {}; - expect(() => setValueReducer(INITIAL_STATE, new SetValueAction<{}>(FORM_CONTROL_ID, value))).toThrowError(); + expect(() => setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value))).toThrowError(); }); it('should allow setting boxed object values', () => { const state = createFormControlState(FORM_CONTROL_ID, box({ inner: '' })); const value = box({ inner: 'A' }); - const resultState = setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(state, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); }); it('should allow setting boxed array values', () => { const state = createFormControlState(FORM_CONTROL_ID, box([''])); const value = box(['A']); - const resultState = setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(state, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); }); it('should throw if boxed value is not serializable', () => { const value = box({ inner: () => void 0 }); - expect(() => setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value as any))).toThrowError(); + expect(() => setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value as any))).toThrowError(); }); }); diff --git a/src/control/reducer/set-value.ts b/src/control/reducer/set-value.ts index b774d189..0a3e332c 100644 --- a/src/control/reducer/set-value.ts +++ b/src/control/reducer/set-value.ts @@ -1,11 +1,11 @@ -import { Actions, SetValueAction } from '../../actions'; +import {NgrxFormActionTypes, SetValueAction} from '../../actions'; import { FormControlState, FormControlValueTypes, verifyFormControlValueIsValid } from '../../state'; export function setValueReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== SetValueAction.TYPE) { + if (action.type !== SetValueAction.type) { return state; } diff --git a/src/control/reducer/start-async-validation.spec.ts b/src/control/reducer/start-async-validation.spec.ts index cdc7d9f4..e460b631 100644 --- a/src/control/reducer/start-async-validation.spec.ts +++ b/src/control/reducer/start-async-validation.spec.ts @@ -11,7 +11,7 @@ describe(`form control ${startAsyncValidationReducer.name}`, () => { it('should update state with pending validation', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([name]); expect(resultState.isValidationPending).toBe(true); }); @@ -20,7 +20,7 @@ describe(`form control ${startAsyncValidationReducer.name}`, () => { const name = 'required'; const existingName = 'min'; const state = { ...INITIAL_STATE, pendingValidations: [existingName], isValidationPending: true }; - const resultState = startAsyncValidationReducer(state, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(state, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([existingName, name]); expect(resultState.isValidationPending).toBe(true); }); @@ -28,7 +28,7 @@ describe(`form control ${startAsyncValidationReducer.name}`, () => { it('should not update state if validation is already pending', () => { const name = 'required'; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = startAsyncValidationReducer(state, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(state, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState).toBe(state); }); }); diff --git a/src/control/reducer/start-async-validation.ts b/src/control/reducer/start-async-validation.ts index 650d6764..5916b8ee 100644 --- a/src/control/reducer/start-async-validation.ts +++ b/src/control/reducer/start-async-validation.ts @@ -1,11 +1,11 @@ -import { Actions, StartAsyncValidationAction } from '../../actions'; +import {NgrxFormActionTypes, StartAsyncValidationAction} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function startAsyncValidationReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== StartAsyncValidationAction.TYPE) { + if (action.type !== StartAsyncValidationAction.type) { return state; } diff --git a/src/control/reducer/unfocus.spec.ts b/src/control/reducer/unfocus.spec.ts index 774286ae..d4ae8cf0 100644 --- a/src/control/reducer/unfocus.spec.ts +++ b/src/control/reducer/unfocus.spec.ts @@ -11,13 +11,13 @@ describe('form control unfocusReducer', () => { it('should update state if focused', () => { const state = { ...INITIAL_STATE, isFocused: true, isUnfocused: false }; - const resultState = unfocusReducer(state, new UnfocusAction(FORM_CONTROL_ID)); + const resultState = unfocusReducer(state, UnfocusAction(FORM_CONTROL_ID)); expect(resultState.isFocused).toEqual(false); expect(resultState.isUnfocused).toEqual(true); }); it('should not update state if unfocused', () => { - const resultState = unfocusReducer(INITIAL_STATE, new UnfocusAction(FORM_CONTROL_ID)); + const resultState = unfocusReducer(INITIAL_STATE, UnfocusAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); }); diff --git a/src/control/reducer/unfocus.ts b/src/control/reducer/unfocus.ts index c6d9bf34..419bee2b 100644 --- a/src/control/reducer/unfocus.ts +++ b/src/control/reducer/unfocus.ts @@ -1,11 +1,11 @@ -import { Actions, UnfocusAction } from '../../actions'; +import {NgrxFormActionTypes, UnfocusAction} from '../../actions'; import { FormControlState, FormControlValueTypes } from '../../state'; export function unfocusReducer( state: FormControlState, - action: Actions, + action: NgrxFormActionTypes, ): FormControlState { - if (action.type !== UnfocusAction.TYPE) { + if (action.type !== UnfocusAction.type) { return state; } diff --git a/src/group/directive.spec.ts b/src/group/directive.spec.ts index 077235f8..7e60cb11 100644 --- a/src/group/directive.spec.ts +++ b/src/group/directive.spec.ts @@ -36,7 +36,7 @@ describe(NgrxFormDirective.name, () => { it(`should dispatch a ${MarkAsSubmittedAction.name} if the form is submitted and the state is unsubmitted`, done => { actions$.pipe(take(1)).subscribe(a => { - expect(a).toEqual(new MarkAsSubmittedAction(INITIAL_STATE.id)); + expect(a).toEqual(MarkAsSubmittedAction(INITIAL_STATE.id)); done(); }); diff --git a/src/group/directive.ts b/src/group/directive.ts index c5a86b1a..598ffb37 100644 --- a/src/group/directive.ts +++ b/src/group/directive.ts @@ -1,7 +1,7 @@ import { Directive, HostListener, Inject, Input, OnInit, Optional } from '@angular/core'; import { ActionsSubject } from '@ngrx/store'; -import { Actions, MarkAsSubmittedAction } from '../actions'; +import {MarkAsSubmittedAction, NgrxFormActionTypes} from '../actions'; import { FormGroupState } from '../state'; // this interface just exists to prevent a direct reference to @@ -23,7 +23,7 @@ export class NgrxFormDirective implements OnInit { this.actionsSubject = actionsSubject; } - protected dispatchAction(action: Actions) { + protected dispatchAction(action: NgrxFormActionTypes) { if (this.actionsSubject !== null) { this.actionsSubject.next(action); } else { @@ -41,7 +41,7 @@ export class NgrxFormDirective implements OnInit { onSubmit(event: CustomEvent) { event.preventDefault(); if (this.state.isUnsubmitted) { - this.dispatchAction(new MarkAsSubmittedAction(this.state.id)); + this.dispatchAction(MarkAsSubmittedAction(this.state.id)); } } } diff --git a/src/group/local-state-directive.spec.ts b/src/group/local-state-directive.spec.ts index e6c4d1f5..9c5ed246 100644 --- a/src/group/local-state-directive.spec.ts +++ b/src/group/local-state-directive.spec.ts @@ -1,21 +1,20 @@ -import { Action } from '@ngrx/store'; import { Observable, ReplaySubject } from 'rxjs'; import { count, take } from 'rxjs/operators'; -import { MarkAsSubmittedAction } from '../actions'; +import { MarkAsSubmittedAction, NgrxFormActionTypes } from '../actions'; import { createFormGroupState } from '../state'; import { NgrxLocalFormDirective } from './local-state-directive'; describe(NgrxLocalFormDirective.name, () => { let directive: NgrxLocalFormDirective<{}>; - let actionsSubject: ReplaySubject; - let actions$: Observable; + let actionsSubject: ReplaySubject; + let actions$: Observable; const FORM_GROUP_ID = 'test ID'; const INITIAL_FORM_CONTROL_VALUE = {}; const INITIAL_STATE = createFormGroupState<{}>(FORM_GROUP_ID, INITIAL_FORM_CONTROL_VALUE); beforeEach(() => { - actionsSubject = new ReplaySubject(); + actionsSubject = new ReplaySubject(); actions$ = actionsSubject; directive = new NgrxLocalFormDirective<{}>(); directive.state = INITIAL_STATE; @@ -35,7 +34,7 @@ describe(NgrxLocalFormDirective.name, () => { it(`should dispatch a ${MarkAsSubmittedAction.name} to the event emitter if the form is submitted and the state is unsubmitted`, done => { directive.ngrxFormsAction.pipe(take(1)).subscribe(a => { - expect(a).toEqual(new MarkAsSubmittedAction(INITIAL_STATE.id)); + expect(a).toEqual(MarkAsSubmittedAction(INITIAL_STATE.id)); done(); }); diff --git a/src/group/local-state-directive.ts b/src/group/local-state-directive.ts index d7f2feb6..ff3a7532 100644 --- a/src/group/local-state-directive.ts +++ b/src/group/local-state-directive.ts @@ -1,6 +1,6 @@ import { Directive, EventEmitter, Output } from '@angular/core'; +import { NgrxFormActionTypes } from '../actions'; -import { Actions } from '../actions'; import { NgrxFormDirective } from './directive'; @Directive({ @@ -9,13 +9,13 @@ import { NgrxFormDirective } from './directive'; }) export class NgrxLocalFormDirective extends NgrxFormDirective { - @Output() ngrxFormsAction = new EventEmitter>(); + @Output() ngrxFormsAction = new EventEmitter(); // type fix me constructor() { super(null); } - protected dispatchAction(action: Actions) { + protected dispatchAction(action: NgrxFormActionTypes) { this.ngrxFormsAction.emit(action); } } diff --git a/src/group/reducer.spec.ts b/src/group/reducer.spec.ts index 7b4b3c39..20612e0f 100644 --- a/src/group/reducer.spec.ts +++ b/src/group/reducer.spec.ts @@ -40,12 +40,12 @@ describe('form group reducer', () => { }); it('should skip any action with non-equal control ID', () => { - const resultState = formGroupReducer(INITIAL_STATE, new SetValueAction(`A${FORM_CONTROL_ID}`, 'A') as any); + const resultState = formGroupReducer(INITIAL_STATE, SetValueAction(`A${FORM_CONTROL_ID}`, 'A') as any); expect(resultState).toBe(INITIAL_STATE); }); it(`should forward ${FocusAction.name}s to children`, () => { - const resultState = formGroupReducer(INITIAL_STATE, new FocusAction(FORM_CONTROL_INNER_ID) as any); + const resultState = formGroupReducer(INITIAL_STATE, FocusAction(FORM_CONTROL_INNER_ID) as any); expect(resultState.controls.inner.isFocused).toEqual(true); expect(resultState.controls.inner.isUnfocused).toEqual(false); }); @@ -61,58 +61,58 @@ describe('form group reducer', () => { }, }, }; - const resultState = formGroupReducer(state, new UnfocusAction(FORM_CONTROL_INNER_ID) as any); + const resultState = formGroupReducer(state, UnfocusAction(FORM_CONTROL_INNER_ID) as any); expect(resultState.controls.inner.isFocused).toEqual(false); expect(resultState.controls.inner.isUnfocused).toEqual(true); }); it(`should forward add ${AddArrayControlAction.name}s to children`, () => { - const resultState = formGroupReducer(INITIAL_STATE_FULL, new AddArrayControlAction(FORM_CONTROL_INNER5_ID, '')); + const resultState = formGroupReducer(INITIAL_STATE_FULL, AddArrayControlAction(FORM_CONTROL_INNER5_ID, '')); expect(resultState.controls.inner5!.controls[1]).toBeDefined(); }); it(`should forward remove ${RemoveArrayControlAction.name}s to children`, () => { - const resultState = formGroupReducer(INITIAL_STATE_FULL, new RemoveArrayControlAction(FORM_CONTROL_INNER5_ID, 0)); + const resultState = formGroupReducer(INITIAL_STATE_FULL, RemoveArrayControlAction(FORM_CONTROL_INNER5_ID, 0)); expect(resultState.controls.inner5!.controls[0]).toBeUndefined(); }); it('should not update state if no child was updated', () => { - const resultState = formGroupReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_INNER_ID, '') as any); + const resultState = formGroupReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_INNER_ID, '') as any); expect(resultState).toBe(INITIAL_STATE); }); it('should not update state value if no child value was updated', () => { - const resultState = formGroupReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_INNER_ID)); + const resultState = formGroupReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_INNER_ID)); expect(resultState.value).toBe(INITIAL_STATE.value); }); it('should not reset child states', () => { const value = 'A'; - const state = formGroupReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_INNER_ID, value) as any); - const resultState = formGroupReducer(state, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const state = formGroupReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_INNER_ID, value) as any); + const resultState = formGroupReducer(state, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.value).toBe(value); }); it('should not be stateful', () => { - formGroupReducer(INITIAL_STATE_FULL, new SetValueAction(FORM_CONTROL_ID, INITIAL_FORM_CONTROL_VALUE)); - expect(() => formGroupReducer(INITIAL_STATE_FULL, new MarkAsDirtyAction(FORM_CONTROL_ID))).not.toThrowError(); + formGroupReducer(INITIAL_STATE_FULL, SetValueAction(FORM_CONTROL_ID, INITIAL_FORM_CONTROL_VALUE)); + expect(() => formGroupReducer(INITIAL_STATE_FULL, MarkAsDirtyAction(FORM_CONTROL_ID))).not.toThrowError(); }); it('should preserve the order of properties when stringified', () => { const expected = JSON.stringify(INITIAL_STATE_FULL); - let state = formGroupReducer(INITIAL_STATE_FULL, new MarkAsDirtyAction(FORM_CONTROL_ID)); - state = formGroupReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + let state = formGroupReducer(INITIAL_STATE_FULL, MarkAsDirtyAction(FORM_CONTROL_ID)); + state = formGroupReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(JSON.stringify(state)).toEqual(expected); }); it('should throw if trying to set a date as value', () => { const state = createFormGroupState(FORM_CONTROL_ID, {}); - expect(() => formGroupReducer(state, new SetValueAction(FORM_CONTROL_ID, new Date()))).toThrowError(); + expect(() => formGroupReducer(state, SetValueAction(FORM_CONTROL_ID, new Date()))).toThrowError(); }); it('should throw if trying to set a date as a child value', () => { const state = createFormGroupState(FORM_CONTROL_ID, { inner: null }); - expect(() => formGroupReducer(state, new SetValueAction(FORM_CONTROL_INNER_ID, new Date()))).toThrowError(); + expect(() => formGroupReducer(state, SetValueAction(FORM_CONTROL_INNER_ID, new Date()))).toThrowError(); }); it('should throw if state is undefined', () => { @@ -120,12 +120,12 @@ describe('form group reducer', () => { }); it('should throw if state is not a group state', () => { - expect(() => formGroupReducer(INITIAL_STATE.controls.inner as any, new MarkAsDirtyAction(FORM_CONTROL_ID))).toThrowError(); + expect(() => formGroupReducer(INITIAL_STATE.controls.inner as any, MarkAsDirtyAction(FORM_CONTROL_ID))).toThrowError(); }); describe(SetValueAction.name, () => { it('should update state', () => { - const resultState = formGroupReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, { inner: 'A' })); + const resultState = formGroupReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, { inner: 'A' })); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -133,7 +133,7 @@ describe('form group reducer', () => { describe(SetErrorsAction.name, () => { it('should update state', () => { const errors = { required: true }; - const resultState = formGroupReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = formGroupReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -141,7 +141,7 @@ describe('form group reducer', () => { describe(StartAsyncValidationAction.name, () => { it('should update state', () => { const name = 'required'; - const resultState = formGroupReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = formGroupReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -151,7 +151,7 @@ describe('form group reducer', () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = formGroupReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = formGroupReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -168,14 +168,14 @@ describe('form group reducer', () => { isValidationPending: true, }; - const resultState = formGroupReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = formGroupReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsDirtyAction.name, () => { it('should update state', () => { - const resultState = formGroupReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -183,7 +183,7 @@ describe('form group reducer', () => { describe(MarkAsPristineAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = formGroupReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -191,21 +191,21 @@ describe('form group reducer', () => { describe(EnableAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = formGroupReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(DisableAction.name, () => { it('should update state', () => { - const resultState = formGroupReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsTouchedAction.name, () => { it('should update state', () => { - const resultState = formGroupReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -213,14 +213,14 @@ describe('form group reducer', () => { describe(MarkAsUntouchedAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = formGroupReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(MarkAsSubmittedAction.name, () => { it('should update state', () => { - const resultState = formGroupReducer(INITIAL_STATE, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(INITIAL_STATE, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); @@ -228,14 +228,14 @@ describe('form group reducer', () => { describe(MarkAsUnsubmittedAction.name, () => { it('should update state', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = formGroupReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = formGroupReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); }); describe(AddGroupControlAction.name, () => { it('should update state', () => { - const action = new AddGroupControlAction(FORM_CONTROL_ID, 'inner2', ''); + const action = AddGroupControlAction(FORM_CONTROL_ID, 'inner2', ''); const resultState = formGroupReducer(INITIAL_STATE, action); expect(resultState).not.toBe(INITIAL_STATE); }); @@ -243,7 +243,7 @@ describe('form group reducer', () => { describe(RemoveGroupControlAction.name, () => { it('should update state', () => { - const action = new RemoveGroupControlAction(FORM_CONTROL_ID, 'inner2'); + const action = RemoveGroupControlAction(FORM_CONTROL_ID, 'inner2'); const resultState = formGroupReducer(INITIAL_STATE_FULL, action); expect(resultState).not.toBe(INITIAL_STATE_FULL); }); @@ -251,7 +251,7 @@ describe('form group reducer', () => { describe(SetUserDefinedPropertyAction.name, () => { it('should update state', () => { - const action = new SetUserDefinedPropertyAction(FORM_CONTROL_ID, 'prop', 12); + const action =SetUserDefinedPropertyAction(FORM_CONTROL_ID, 'prop', 12); const resultState = formGroupReducer(INITIAL_STATE_FULL, action); expect(resultState).not.toBe(INITIAL_STATE); }); @@ -259,7 +259,7 @@ describe('form group reducer', () => { describe(ResetAction.name, () => { it('should update state', () => { - const action = new ResetAction(FORM_CONTROL_ID); + const action = ResetAction(FORM_CONTROL_ID); const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; const resultState = formGroupReducer(state, action); expect(resultState).not.toBe(INITIAL_STATE); diff --git a/src/group/reducer.ts b/src/group/reducer.ts index be84dd5e..3cda3c95 100644 --- a/src/group/reducer.ts +++ b/src/group/reducer.ts @@ -1,10 +1,9 @@ import { Action } from '@ngrx/store'; import { - Actions, AddArrayControlAction, FocusAction, - isNgrxFormsAction, + isNgrxFormsAction, NgrxFormActionTypes, RemoveArrayControlAction, UnfocusAction, } from '../actions'; @@ -28,7 +27,7 @@ import { setValueReducer } from './reducer/set-value'; import { startAsyncValidationReducer } from './reducer/start-async-validation'; import { childReducer } from './reducer/util'; -export function formGroupReducerInternal(state: FormGroupState, action: Actions) { +export function formGroupReducerInternal(state: FormGroupState, action: NgrxFormActionTypes) { if (!isGroupState(state)) { throw new Error('The state must be a group state'); } @@ -42,10 +41,10 @@ export function formGroupReducerInternal(state: FormGro } switch (action.type) { - case FocusAction.TYPE: - case UnfocusAction.TYPE: - case AddArrayControlAction.TYPE: - case RemoveArrayControlAction.TYPE: + case FocusAction.type: + case UnfocusAction.type: + case AddArrayControlAction.type: + case RemoveArrayControlAction.type: return childReducer(state, action); default: diff --git a/src/group/reducer/add-control.spec.ts b/src/group/reducer/add-control.spec.ts index be417ca7..bd36d917 100644 --- a/src/group/reducer/add-control.spec.ts +++ b/src/group/reducer/add-control.spec.ts @@ -6,7 +6,7 @@ import { FORM_CONTROL_ID, FormGroupValue, INITIAL_STATE } from './test-util'; describe(`form group ${addControlReducer.name}`, () => { it('should create child state for control child', () => { const value = 'B'; - const action = new AddGroupControlAction(FORM_CONTROL_ID, 'inner2', value); + const action = AddGroupControlAction(FORM_CONTROL_ID, 'inner2', value); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual({ inner: '', inner2: value }); expect(resultState.controls.inner2!.value).toEqual(value); @@ -14,7 +14,7 @@ describe(`form group ${addControlReducer.name}`, () => { it('should create child state for group child', () => { const value = { inner4: 'D' }; - const action = new AddGroupControlAction(FORM_CONTROL_ID, 'inner3', value); + const action = AddGroupControlAction(FORM_CONTROL_ID, 'inner3', value); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual({ inner: '', inner3: value }); expect(resultState.controls.inner3!.value).toBe(value); @@ -24,7 +24,7 @@ describe(`form group ${addControlReducer.name}`, () => { it('should create child state for array child', () => { const value = ['A']; - const action = new AddGroupControlAction(FORM_CONTROL_ID, 'inner5', value); + const action = AddGroupControlAction(FORM_CONTROL_ID, 'inner5', value); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.value).toEqual({ inner: '', inner5: value }); expect(resultState.controls.inner5!.value).toBe(value); @@ -34,20 +34,20 @@ describe(`form group ${addControlReducer.name}`, () => { it('should mark the state as dirty', () => { const value = ['A']; - const action = new AddGroupControlAction(FORM_CONTROL_ID, 'inner5', value); + const action = AddGroupControlAction(FORM_CONTROL_ID, 'inner5', value); const resultState = addControlReducer(INITIAL_STATE, action); expect(resultState.isDirty).toBe(true); }); it('should throw if trying to add existing control', () => { - const action = new AddGroupControlAction(FORM_CONTROL_ID, 'inner', ''); + const action = AddGroupControlAction(FORM_CONTROL_ID, 'inner', ''); expect(() => addControlReducer(INITIAL_STATE, action)).toThrowError(); }); it('should forward actions to children', () => { const state = createFormGroupState<{ inner: { inner2?: string } }>(FORM_CONTROL_ID, { inner: {} }); const value = 'B'; - const action = new AddGroupControlAction(state.controls.inner.id, 'inner2', value); + const action = AddGroupControlAction(state.controls.inner.id, 'inner2', value); const resultState = addControlReducer(state, action as any); expect(resultState.controls.inner.controls.inner2!.value).toEqual(value); }); diff --git a/src/group/reducer/add-control.ts b/src/group/reducer/add-control.ts index 6ee32b63..a866cbbf 100644 --- a/src/group/reducer/add-control.ts +++ b/src/group/reducer/add-control.ts @@ -1,12 +1,12 @@ -import { Actions, AddGroupControlAction } from '../../actions'; +import {AddGroupControlAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, createChildState, FormGroupState, KeyValue } from '../../state'; import { childReducer } from './util'; export function addControlReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== AddGroupControlAction.TYPE) { + if (action.type !== AddGroupControlAction.type) { return state; } diff --git a/src/group/reducer/clear-async-error.spec.ts b/src/group/reducer/clear-async-error.spec.ts index c56bb156..73939366 100644 --- a/src/group/reducer/clear-async-error.spec.ts +++ b/src/group/reducer/clear-async-error.spec.ts @@ -8,7 +8,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { it('should remove error from state', () => { const name = 'required'; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: true }, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -17,7 +17,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { it('should remove the validation from pending validations if validation is the last pending', () => { const name = 'required'; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: true }, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); @@ -34,7 +34,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([name2]); expect(resultState.isValidationPending).toBe(true); }); @@ -43,7 +43,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { const name = 'required'; const errors = { $min: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors, pendingValidations: [name], isValidationPending: true }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toBe(errors); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -60,7 +60,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState).toBe(state); }); @@ -75,7 +75,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { isValidationPending: true, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -101,7 +101,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _inner: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -130,7 +130,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _inner3: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -159,7 +159,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _inner5: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -194,7 +194,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.errors).toEqual({ _inner: errors1, _inner3: errors2 }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -225,7 +225,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name1)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name1)); expect(resultState.errors).toEqual({ _inner: { [`$${name2}`]: value2 } }); expect(resultState.isValidationPending).toEqual(false); }); @@ -255,7 +255,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_INNER_ID, name2)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_INNER_ID, name2)); expect(resultState.errors).toEqual({ [`$${name1}`]: value1 }); expect(resultState.isValidationPending).toEqual(false); }); @@ -274,7 +274,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -294,7 +294,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -314,7 +314,7 @@ describe(`form group ${clearAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = clearAsyncErrorReducer(state, new ClearAsyncErrorAction(FORM_CONTROL_ID, name)); + const resultState = clearAsyncErrorReducer(state, ClearAsyncErrorAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); diff --git a/src/group/reducer/clear-async-error.ts b/src/group/reducer/clear-async-error.ts index b1f239f6..46b6a779 100644 --- a/src/group/reducer/clear-async-error.ts +++ b/src/group/reducer/clear-async-error.ts @@ -1,12 +1,12 @@ -import { Actions, ClearAsyncErrorAction } from '../../actions'; +import {ClearAsyncErrorAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer } from './util'; export function clearAsyncErrorReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== ClearAsyncErrorAction.TYPE) { + if (action.type !== ClearAsyncErrorAction.type) { return state; } diff --git a/src/group/reducer/disable.spec.ts b/src/group/reducer/disable.spec.ts index faf00e86..bf45e185 100644 --- a/src/group/reducer/disable.spec.ts +++ b/src/group/reducer/disable.spec.ts @@ -4,21 +4,21 @@ import { FORM_CONTROL_ID, INITIAL_STATE, INITIAL_STATE_FULL } from './test-util' describe(`form group ${disableReducer.name}`, () => { it('should update state if enabled', () => { - const resultState = disableReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState.isEnabled).toEqual(false); expect(resultState.isDisabled).toEqual(true); }); it('should not update state if disabled', () => { const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState).toBe(state); }); it('should mark the state as valid and clear all errors', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState.isValid).toEqual(true); expect(resultState.isInvalid).toEqual(false); expect(resultState.errors).toEqual({}); @@ -26,31 +26,31 @@ describe(`form group ${disableReducer.name}`, () => { it('should clear all pending validations', () => { const state = { ...INITIAL_STATE, pendingValidations: ['required'], isValidationPending: true }; - const resultState = disableReducer(state, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(state, DisableAction(FORM_CONTROL_ID)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); it('should disable control children', () => { - const resultState = disableReducer(INITIAL_STATE, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE, DisableAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isEnabled).toBe(false); expect(resultState.controls.inner.isDisabled).toBe(true); }); it('should disable group children', () => { - const resultState = disableReducer(INITIAL_STATE_FULL, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE_FULL, DisableAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isEnabled).toBe(false); expect(resultState.controls.inner3!.isDisabled).toBe(true); }); it('should disable array children', () => { - const resultState = disableReducer(INITIAL_STATE_FULL, new DisableAction(FORM_CONTROL_ID)); + const resultState = disableReducer(INITIAL_STATE_FULL, DisableAction(FORM_CONTROL_ID)); expect(resultState.controls.inner5!.isEnabled).toBe(false); expect(resultState.controls.inner5!.isDisabled).toBe(true); }); it('should forward actions to children', () => { - const resultState = disableReducer(INITIAL_STATE, new DisableAction(INITIAL_STATE.controls.inner.id)); + const resultState = disableReducer(INITIAL_STATE, DisableAction(INITIAL_STATE.controls.inner.id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/group/reducer/disable.ts b/src/group/reducer/disable.ts index 6b61957b..f39e7e6d 100644 --- a/src/group/reducer/disable.ts +++ b/src/group/reducer/disable.ts @@ -1,12 +1,12 @@ -import { Actions, DisableAction } from '../../actions'; +import {DisableAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function disableReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== DisableAction.TYPE) { + if (action.type !== DisableAction.type) { return state; } @@ -20,7 +20,7 @@ export function disableReducer( return computeGroupState( state.id, - dispatchActionPerChild(state.controls, controlId => new DisableAction(controlId)), + dispatchActionPerChild(state.controls, controlId => DisableAction(controlId)), state.value, {}, [], diff --git a/src/group/reducer/enable.spec.ts b/src/group/reducer/enable.spec.ts index 103e11a8..89bd4bac 100644 --- a/src/group/reducer/enable.spec.ts +++ b/src/group/reducer/enable.spec.ts @@ -5,12 +5,12 @@ import { FORM_CONTROL_ID, INITIAL_STATE_FULL, setPropertiesRecursively } from '. describe(`form group ${enableReducer.name}`, () => { it('should enable itself and all children recursively', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isEnabled', false], ['isDisabled', true]]); - const resultState = enableReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL); }); it('should not update state if all children are enabled recursively', () => { - const resultState = enableReducer(INITIAL_STATE_FULL, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(INITIAL_STATE_FULL, EnableAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE_FULL); }); @@ -26,7 +26,7 @@ describe(`form group ${enableReducer.name}`, () => { }, }, }; - const resultState = enableReducer(state, new EnableAction(FORM_CONTROL_ID)); + const resultState = enableReducer(state, EnableAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL); }); @@ -42,7 +42,7 @@ describe(`form group ${enableReducer.name}`, () => { }, }, }; - const resultState = enableReducer(state, new EnableAction(state.controls.inner2.id)); + const resultState = enableReducer(state, EnableAction(state.controls.inner2.id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/group/reducer/enable.ts b/src/group/reducer/enable.ts index 541fa3e7..d8bc06d5 100644 --- a/src/group/reducer/enable.ts +++ b/src/group/reducer/enable.ts @@ -1,12 +1,12 @@ -import { Actions, EnableAction } from '../../actions'; +import {EnableAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function enableReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== EnableAction.TYPE) { + if (action.type !== EnableAction.type) { return state; } @@ -14,7 +14,7 @@ export function enableReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new EnableAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => EnableAction(controlId)); if (controls === state.controls) { return state; diff --git a/src/group/reducer/mark-as-dirty.spec.ts b/src/group/reducer/mark-as-dirty.spec.ts index 24a8bea7..af743daa 100644 --- a/src/group/reducer/mark-as-dirty.spec.ts +++ b/src/group/reducer/mark-as-dirty.spec.ts @@ -6,12 +6,12 @@ describe(`form group ${markAsDirtyReducer.name}`, () => { const INITIAL_STATE_FULL_DIRTY = setPropertiesRecursively(INITIAL_STATE_FULL, [['isDirty', true], ['isPristine', false]]); it('should mark itself and all children recursively as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE_FULL, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE_FULL, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL_DIRTY); }); it('should not update state if all children are marked as dirty recursively', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE_FULL_DIRTY, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE_FULL_DIRTY, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE_FULL_DIRTY); }); @@ -29,30 +29,30 @@ describe(`form group ${markAsDirtyReducer.name}`, () => { }, }, }; - const resultState = markAsDirtyReducer(state, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(state, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL_DIRTY); }); it('should mark control children as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isDirty).toEqual(true); expect(resultState.controls.inner.isPristine).toEqual(false); }); it('should mark group children as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE_FULL, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE_FULL, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isDirty).toEqual(true); expect(resultState.controls.inner3!.isPristine).toEqual(false); }); it('should mark array children as dirty', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE_FULL, new MarkAsDirtyAction(FORM_CONTROL_ID)); + const resultState = markAsDirtyReducer(INITIAL_STATE_FULL, MarkAsDirtyAction(FORM_CONTROL_ID)); expect(resultState.controls.inner5!.isDirty).toEqual(true); expect(resultState.controls.inner5!.isPristine).toEqual(false); }); it('should forward actions to children', () => { - const resultState = markAsDirtyReducer(INITIAL_STATE, new MarkAsDirtyAction(INITIAL_STATE.controls.inner.id)); + const resultState = markAsDirtyReducer(INITIAL_STATE, MarkAsDirtyAction(INITIAL_STATE.controls.inner.id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/group/reducer/mark-as-dirty.ts b/src/group/reducer/mark-as-dirty.ts index 9e7f0d47..111f90bc 100644 --- a/src/group/reducer/mark-as-dirty.ts +++ b/src/group/reducer/mark-as-dirty.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsDirtyAction } from '../../actions'; +import {MarkAsDirtyAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsDirtyReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== MarkAsDirtyAction.TYPE) { + if (action.type !== MarkAsDirtyAction.type) { return state; } @@ -14,7 +14,7 @@ export function markAsDirtyReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new MarkAsDirtyAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => MarkAsDirtyAction(controlId)); if (controls === state.controls) { return state; diff --git a/src/group/reducer/mark-as-pristine.spec.ts b/src/group/reducer/mark-as-pristine.spec.ts index 6f228de0..304d3c62 100644 --- a/src/group/reducer/mark-as-pristine.spec.ts +++ b/src/group/reducer/mark-as-pristine.spec.ts @@ -5,40 +5,40 @@ import { FORM_CONTROL_ID, INITIAL_STATE, INITIAL_STATE_FULL, setPropertiesRecurs describe(`form group ${markAsPristineReducer.name}`, () => { it('should update state if dirty', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); }); it('should not update state if pristine', () => { - const resultState = markAsPristineReducer(INITIAL_STATE, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(INITIAL_STATE, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should mark control children as pristine', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isDirty).toEqual(false); expect(resultState.controls.inner.isPristine).toEqual(true); }); it('should mark group children as pristine', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isDirty).toEqual(false); expect(resultState.controls.inner3!.isPristine).toEqual(true); }); it('should mark array children as pristine', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(FORM_CONTROL_ID)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(FORM_CONTROL_ID)); expect(resultState.controls.inner5!.isDirty).toEqual(false); expect(resultState.controls.inner5!.isPristine).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isDirty', true], ['isPristine', false]]); - const resultState = markAsPristineReducer(state, new MarkAsPristineAction(state.controls.inner.id)); + const resultState = markAsPristineReducer(state, MarkAsPristineAction(state.controls.inner.id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/group/reducer/mark-as-pristine.ts b/src/group/reducer/mark-as-pristine.ts index f6eb6207..6e6f5f59 100644 --- a/src/group/reducer/mark-as-pristine.ts +++ b/src/group/reducer/mark-as-pristine.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsPristineAction } from '../../actions'; +import {MarkAsPristineAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsPristineReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== MarkAsPristineAction.TYPE) { + if (action.type !== MarkAsPristineAction.type) { return state; } @@ -20,7 +20,7 @@ export function markAsPristineReducer( return computeGroupState( state.id, - dispatchActionPerChild(state.controls, controlId => new MarkAsPristineAction(controlId)), + dispatchActionPerChild(state.controls, controlId => MarkAsPristineAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/group/reducer/mark-as-submitted.spec.ts b/src/group/reducer/mark-as-submitted.spec.ts index d9eda0e5..76d71096 100644 --- a/src/group/reducer/mark-as-submitted.spec.ts +++ b/src/group/reducer/mark-as-submitted.spec.ts @@ -6,12 +6,12 @@ describe(`form group ${markAsSubmittedReducer.name}`, () => { const INITIAL_STATE_FULL_SUBMITTED = setPropertiesRecursively(INITIAL_STATE_FULL, [['isSubmitted', true], ['isUnsubmitted', false]]); it('should mark itself and all children recursively as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL_SUBMITTED); }); it('should not update state if all children are marked as submitted recursively', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL_SUBMITTED, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL_SUBMITTED, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE_FULL_SUBMITTED); }); @@ -29,30 +29,30 @@ describe(`form group ${markAsSubmittedReducer.name}`, () => { }, }, }; - const resultState = markAsSubmittedReducer(state, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(state, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL_SUBMITTED); }); it('should mark control children as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isSubmitted).toEqual(true); expect(resultState.controls.inner.isUnsubmitted).toEqual(false); }); it('should mark group children as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isSubmitted).toEqual(true); expect(resultState.controls.inner3!.isUnsubmitted).toEqual(false); }); it('should mark array children as submitted', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL, new MarkAsSubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsSubmittedReducer(INITIAL_STATE_FULL, MarkAsSubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner5!.isSubmitted).toEqual(true); expect(resultState.controls.inner5!.isUnsubmitted).toEqual(false); }); it('should forward actions to children', () => { - const resultState = markAsSubmittedReducer(INITIAL_STATE, new MarkAsSubmittedAction(INITIAL_STATE.controls.inner.id)); + const resultState = markAsSubmittedReducer(INITIAL_STATE, MarkAsSubmittedAction(INITIAL_STATE.controls.inner.id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/group/reducer/mark-as-submitted.ts b/src/group/reducer/mark-as-submitted.ts index aa3fd358..e34d87e8 100644 --- a/src/group/reducer/mark-as-submitted.ts +++ b/src/group/reducer/mark-as-submitted.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsSubmittedAction } from '../../actions'; +import {MarkAsSubmittedAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsSubmittedReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== MarkAsSubmittedAction.TYPE) { + if (action.type !== MarkAsSubmittedAction.type) { return state; } @@ -14,7 +14,7 @@ export function markAsSubmittedReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new MarkAsSubmittedAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => MarkAsSubmittedAction(controlId)); if (controls === state.controls) { return state; diff --git a/src/group/reducer/mark-as-touched.spec.ts b/src/group/reducer/mark-as-touched.spec.ts index c1cc80f6..67e7a6b6 100644 --- a/src/group/reducer/mark-as-touched.spec.ts +++ b/src/group/reducer/mark-as-touched.spec.ts @@ -6,12 +6,12 @@ describe(`form group ${markAsTouchedReducer.name}`, () => { const INITIAL_STATE_FULL_TOUCHED = setPropertiesRecursively(INITIAL_STATE_FULL, [['isTouched', true], ['isUntouched', false]]); it('should mark itself and all children recursively as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE_FULL, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE_FULL, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL_TOUCHED); }); it('should not update state if all children are marked as touched recursively', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE_FULL_TOUCHED, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE_FULL_TOUCHED, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE_FULL_TOUCHED); }); @@ -29,30 +29,30 @@ describe(`form group ${markAsTouchedReducer.name}`, () => { }, }, }; - const resultState = markAsTouchedReducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).toEqual(INITIAL_STATE_FULL_TOUCHED); }); it('should mark control children as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isTouched).toEqual(true); expect(resultState.controls.inner.isUntouched).toEqual(false); }); it('should mark group children as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE_FULL, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE_FULL, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isTouched).toEqual(true); expect(resultState.controls.inner3!.isUntouched).toEqual(false); }); it('should mark array children as touched', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE_FULL, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = markAsTouchedReducer(INITIAL_STATE_FULL, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner5!.isTouched).toEqual(true); expect(resultState.controls.inner5!.isUntouched).toEqual(false); }); it('should forward actions to children', () => { - const resultState = markAsTouchedReducer(INITIAL_STATE, new MarkAsTouchedAction(INITIAL_STATE.controls.inner.id)); + const resultState = markAsTouchedReducer(INITIAL_STATE, MarkAsTouchedAction(INITIAL_STATE.controls.inner.id)); expect(resultState).not.toBe(INITIAL_STATE); }); }); diff --git a/src/group/reducer/mark-as-touched.ts b/src/group/reducer/mark-as-touched.ts index 7e289e39..3425724b 100644 --- a/src/group/reducer/mark-as-touched.ts +++ b/src/group/reducer/mark-as-touched.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsTouchedAction } from '../../actions'; +import {MarkAsTouchedAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsTouchedReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== MarkAsTouchedAction.TYPE) { + if (action.type !== MarkAsTouchedAction.type) { return state; } @@ -14,7 +14,7 @@ export function markAsTouchedReducer( return childReducer(state, action); } - const controls = dispatchActionPerChild(state.controls, controlId => new MarkAsTouchedAction(controlId)); + const controls = dispatchActionPerChild(state.controls, controlId => MarkAsTouchedAction(controlId)); if (controls === state.controls) { return state; diff --git a/src/group/reducer/mark-as-unsubmitted.spec.ts b/src/group/reducer/mark-as-unsubmitted.spec.ts index dd3a4155..5def42f9 100644 --- a/src/group/reducer/mark-as-unsubmitted.spec.ts +++ b/src/group/reducer/mark-as-unsubmitted.spec.ts @@ -5,40 +5,40 @@ import { FORM_CONTROL_ID, INITIAL_STATE, INITIAL_STATE_FULL, setPropertiesRecurs describe(`form group ${markAsUnsubmittedReducer.name}`, () => { it('should update state if submitted', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.isSubmitted).toEqual(false); expect(resultState.isUnsubmitted).toEqual(true); }); it('should not update state if unsubmitted', () => { - const resultState = markAsUnsubmittedReducer(INITIAL_STATE, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(INITIAL_STATE, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should mark control children as unsubmitted', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isSubmitted).toEqual(false); expect(resultState.controls.inner.isUnsubmitted).toEqual(true); }); it('should mark group children as unsubmitted', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isSubmitted).toEqual(false); expect(resultState.controls.inner3!.isUnsubmitted).toEqual(true); }); it('should mark array children as unsubmitted', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(FORM_CONTROL_ID)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isSubmitted).toEqual(false); expect(resultState.controls.inner3!.isUnsubmitted).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isSubmitted', true], ['isUnsubmitted', false]]); - const resultState = markAsUnsubmittedReducer(state, new MarkAsUnsubmittedAction(state.controls.inner.id)); + const resultState = markAsUnsubmittedReducer(state, MarkAsUnsubmittedAction(state.controls.inner.id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/group/reducer/mark-as-unsubmitted.ts b/src/group/reducer/mark-as-unsubmitted.ts index c65e2c37..801e574c 100644 --- a/src/group/reducer/mark-as-unsubmitted.ts +++ b/src/group/reducer/mark-as-unsubmitted.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsUnsubmittedAction } from '../../actions'; +import {MarkAsUnsubmittedAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsUnsubmittedReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== MarkAsUnsubmittedAction.TYPE) { + if (action.type !== MarkAsUnsubmittedAction.type) { return state; } @@ -20,7 +20,7 @@ export function markAsUnsubmittedReducer( return computeGroupState( state.id, - dispatchActionPerChild(state.controls, controlId => new MarkAsUnsubmittedAction(controlId)), + dispatchActionPerChild(state.controls, controlId => MarkAsUnsubmittedAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/group/reducer/mark-as-untouched.spec.ts b/src/group/reducer/mark-as-untouched.spec.ts index 9d3560a0..ed03f656 100644 --- a/src/group/reducer/mark-as-untouched.spec.ts +++ b/src/group/reducer/mark-as-untouched.spec.ts @@ -5,40 +5,40 @@ import { FORM_CONTROL_ID, INITIAL_STATE, INITIAL_STATE_FULL, setPropertiesRecurs describe(`form group ${markAsUntouchedReducer.name}`, () => { it('should update state if touched', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.isTouched).toEqual(false); expect(resultState.isUntouched).toEqual(true); }); it('should not update state if untouched', () => { - const resultState = markAsUntouchedReducer(INITIAL_STATE, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(INITIAL_STATE, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should mark control children as untouched', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isTouched).toEqual(false); expect(resultState.controls.inner.isUntouched).toEqual(true); }); it('should mark group children as untouched', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isTouched).toEqual(false); expect(resultState.controls.inner3!.isUntouched).toEqual(true); }); it('should mark array children as untouched', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(FORM_CONTROL_ID)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(FORM_CONTROL_ID)); expect(resultState.controls.inner5!.isTouched).toEqual(false); expect(resultState.controls.inner5!.isUntouched).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isTouched', true], ['isUntouched', false]]); - const resultState = markAsUntouchedReducer(state, new MarkAsUntouchedAction(state.controls.inner.id)); + const resultState = markAsUntouchedReducer(state, MarkAsUntouchedAction(state.controls.inner.id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/group/reducer/mark-as-untouched.ts b/src/group/reducer/mark-as-untouched.ts index 4e6cddbc..8b454bdd 100644 --- a/src/group/reducer/mark-as-untouched.ts +++ b/src/group/reducer/mark-as-untouched.ts @@ -1,12 +1,12 @@ -import { Actions, MarkAsUntouchedAction } from '../../actions'; +import {MarkAsUntouchedAction, NgrxFormActionTypes} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function markAsUntouchedReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== MarkAsUntouchedAction.TYPE) { + if (action.type !== MarkAsUntouchedAction.type) { return state; } @@ -20,7 +20,7 @@ export function markAsUntouchedReducer( return computeGroupState( state.id, - dispatchActionPerChild(state.controls, controlId => new MarkAsUntouchedAction(controlId)), + dispatchActionPerChild(state.controls, controlId => MarkAsUntouchedAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/group/reducer/remove-control.spec.ts b/src/group/reducer/remove-control.spec.ts index 73f8e59f..6cd6c5ea 100644 --- a/src/group/reducer/remove-control.spec.ts +++ b/src/group/reducer/remove-control.spec.ts @@ -5,28 +5,28 @@ import { FORM_CONTROL_ID, FormGroupValue, INITIAL_STATE, INITIAL_STATE_FULL } fr describe(`form group ${removeControlReducer.name}`, () => { it('should remove child state', () => { - const action = new RemoveGroupControlAction(FORM_CONTROL_ID, 'inner2'); + const action = RemoveGroupControlAction(FORM_CONTROL_ID, 'inner2'); const resultState = removeControlReducer(INITIAL_STATE_FULL, action); expect(resultState.value).toEqual({ inner: '', inner3: { inner4: '' }, inner5: [''] }); expect(resultState.controls.inner2).toBeUndefined(); }); it('should remove child state for group children', () => { - const action = new RemoveGroupControlAction(FORM_CONTROL_ID, 'inner3'); + const action = RemoveGroupControlAction(FORM_CONTROL_ID, 'inner3'); const resultState = removeControlReducer(INITIAL_STATE_FULL, action); expect(resultState.value).toEqual({ inner: '', inner2: '', inner5: [''] }); expect(resultState.controls.inner3).toBeUndefined(); }); it('should remove child state for array children', () => { - const action = new RemoveGroupControlAction(FORM_CONTROL_ID, 'inner5'); + const action = RemoveGroupControlAction(FORM_CONTROL_ID, 'inner5'); const resultState = removeControlReducer(INITIAL_STATE_FULL, action); expect(resultState.value).toEqual({ inner: '', inner2: '', inner3: { inner4: '' } }); expect(resultState.controls.inner5).toBeUndefined(); }); it('should mark the state as dirty', () => { - const action = new RemoveGroupControlAction(FORM_CONTROL_ID, 'inner5'); + const action = RemoveGroupControlAction(FORM_CONTROL_ID, 'inner5'); const resultState = removeControlReducer(INITIAL_STATE_FULL, action); expect(resultState.isDirty).toBe(true); }); @@ -48,7 +48,7 @@ describe(`form group ${removeControlReducer.name}`, () => { }, }, }; - const action = new RemoveGroupControlAction(id, 'inner'); + const action = RemoveGroupControlAction(id, 'inner'); const resultState = removeControlReducer(state, action); expect(resultState.value).toEqual({}); expect(resultState.errors).toEqual({}); @@ -73,7 +73,7 @@ describe(`form group ${removeControlReducer.name}`, () => { }, }, }; - const action = new RemoveGroupControlAction(id, 'inner'); + const action = RemoveGroupControlAction(id, 'inner'); const resultState = removeControlReducer(state, action); expect(resultState.value).toEqual({}); expect(resultState.errors).toEqual(errors); @@ -81,13 +81,13 @@ describe(`form group ${removeControlReducer.name}`, () => { }); it('should throw if trying to remove non-existing control', () => { - const action = new RemoveGroupControlAction(FORM_CONTROL_ID, 'inner2'); + const action = RemoveGroupControlAction(FORM_CONTROL_ID, 'inner2'); expect(() => removeControlReducer(INITIAL_STATE, action)).toThrowError(); }); it('should forward actions to children', () => { const state = createFormGroupState(FORM_CONTROL_ID, { inner: { inner2: '' } }); - const action = new RemoveGroupControlAction(state.controls.inner.id, 'inner2'); + const action = RemoveGroupControlAction(state.controls.inner.id, 'inner2'); const resultState = removeControlReducer(state, action as any); expect(resultState.controls.inner.controls.inner2).toBeUndefined(); }); diff --git a/src/group/reducer/remove-control.ts b/src/group/reducer/remove-control.ts index 82b62e31..fd85bd70 100644 --- a/src/group/reducer/remove-control.ts +++ b/src/group/reducer/remove-control.ts @@ -1,12 +1,12 @@ -import { Actions, RemoveGroupControlAction } from '../../actions'; +import {NgrxFormActionTypes, RemoveGroupControlAction} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer } from './util'; export function removeControlReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== RemoveGroupControlAction.TYPE) { + if (action.type !== RemoveGroupControlAction.type) { return state; } @@ -18,7 +18,7 @@ export function removeControlReducer( throw new Error(`Group '${state.id}' does not have child control '${action.name}'!`); // `; } - const controls = Object.assign({}, state.controls); + const controls = Object.assign({}, state.controls); delete controls[action.name]; return computeGroupState( diff --git a/src/group/reducer/reset.spec.ts b/src/group/reducer/reset.spec.ts index ad8d4810..4a7c2b01 100644 --- a/src/group/reducer/reset.spec.ts +++ b/src/group/reducer/reset.spec.ts @@ -5,7 +5,7 @@ import { FORM_CONTROL_ID, INITIAL_STATE, INITIAL_STATE_FULL, setPropertiesRecurs describe(`form group ${resetReducer.name}`, () => { it('should update state if dirty', () => { const state = { ...INITIAL_STATE, isDirty: true, isPristine: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -16,7 +16,7 @@ describe(`form group ${resetReducer.name}`, () => { it('should update state if touched', () => { const state = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -27,7 +27,7 @@ describe(`form group ${resetReducer.name}`, () => { it('should update state if submitted', () => { const state = { ...INITIAL_STATE, isSubmitted: true, isUnsubmitted: false }; - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.isDirty).toEqual(false); expect(resultState.isPristine).toEqual(true); expect(resultState.isTouched).toEqual(false); @@ -37,34 +37,34 @@ describe(`form group ${resetReducer.name}`, () => { }); it('should not update state if pristine and untouched and unsubmitted', () => { - const resultState = resetReducer(INITIAL_STATE, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(INITIAL_STATE, ResetAction(FORM_CONTROL_ID)); expect(resultState).toBe(INITIAL_STATE); }); it('should reset control children', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.controls.inner.isDirty).toEqual(false); expect(resultState.controls.inner.isPristine).toEqual(true); }); it('should reset group children', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.controls.inner3!.isDirty).toEqual(false); expect(resultState.controls.inner3!.isPristine).toEqual(true); }); it('should reset array children', () => { const state = setPropertiesRecursively(INITIAL_STATE_FULL, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(FORM_CONTROL_ID)); + const resultState = resetReducer(state, ResetAction(FORM_CONTROL_ID)); expect(resultState.controls.inner5!.isDirty).toEqual(false); expect(resultState.controls.inner5!.isPristine).toEqual(true); }); it('should forward actions to children', () => { const state = setPropertiesRecursively(INITIAL_STATE, [['isDirty', true], ['isPristine', false]]); - const resultState = resetReducer(state, new ResetAction(state.controls.inner.id)); + const resultState = resetReducer(state, ResetAction(state.controls.inner.id)); expect(resultState).not.toBe(state); }); }); diff --git a/src/group/reducer/reset.ts b/src/group/reducer/reset.ts index a7dc5d1e..31e02d1b 100644 --- a/src/group/reducer/reset.ts +++ b/src/group/reducer/reset.ts @@ -1,12 +1,12 @@ -import { Actions, ResetAction } from '../../actions'; +import {NgrxFormActionTypes, ResetAction} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer, dispatchActionPerChild } from './util'; export function resetReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== ResetAction.TYPE) { + if (action.type !== ResetAction.type) { return state; } @@ -20,7 +20,7 @@ export function resetReducer( return computeGroupState( state.id, - dispatchActionPerChild(state.controls, controlId => new ResetAction(controlId)), + dispatchActionPerChild(state.controls, controlId => ResetAction(controlId)), state.value, state.errors, state.pendingValidations, diff --git a/src/group/reducer/set-async-error.spec.ts b/src/group/reducer/set-async-error.spec.ts index 074d5654..eb7dce63 100644 --- a/src/group/reducer/set-async-error.spec.ts +++ b/src/group/reducer/set-async-error.spec.ts @@ -9,7 +9,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors).toEqual({ [`$${name}`]: value }); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -19,7 +19,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); }); @@ -29,7 +29,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { const name2 = 'min'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: [name, name2], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([name2]); expect(resultState.isValidationPending).toBe(true); }); @@ -38,7 +38,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: value }, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors[`$${name}`]).toBe(value); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -48,7 +48,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = { field: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { [`$${name}`]: value }, pendingValidations: [name], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, { ...value })); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, { ...value })); expect(resultState.errors[`$${name}`]).toBe(value); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toBe(false); @@ -58,7 +58,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState).toBe(state); }); @@ -66,7 +66,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { const name = 'required'; const value = true; const state = { ...INITIAL_STATE, pendingValidations: ['min'], isValidationPending: true }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.errors).toEqual({ [`$${name}`]: value }); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -86,7 +86,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_INNER_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_INNER_ID, name, value)); expect(resultState.errors).toEqual({ _inner: { [`$${name}`]: value } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -108,7 +108,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_INNER3_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_INNER3_ID, name, value)); expect(resultState.errors).toEqual({ _inner3: { [`$${name}`]: value } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -130,7 +130,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_INNER5_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_INNER5_ID, name, value)); expect(resultState.errors).toEqual({ _inner5: { [`$${name}`]: value } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -158,8 +158,8 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - let resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_INNER_ID, name1, value1)); - resultState = setAsyncErrorReducer(resultState, new SetAsyncErrorAction(FORM_CONTROL_INNER3_ID, name2, value2)); + let resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_INNER_ID, name1, value1)); + resultState = setAsyncErrorReducer(resultState, SetAsyncErrorAction(FORM_CONTROL_INNER3_ID, name2, value2)); expect(resultState.errors).toEqual({ _inner: { [`$${name1}`]: value1 }, _inner3: { [`$${name2}`]: value2 } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -189,7 +189,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name1, value1)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name1, value1)); expect(resultState.errors).toEqual({ [`$${name1}`]: value1, _inner: { [`$${name2}`]: value2 } }); }); @@ -212,7 +212,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_INNER_ID, name2, value2)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_INNER_ID, name2, value2)); expect(resultState.errors).toEqual({ [`$${name1}`]: value1, _inner: { [`$${name2}`]: value2 } }); }); @@ -231,7 +231,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -252,7 +252,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); @@ -273,7 +273,7 @@ describe(`form group ${setAsyncErrorReducer.name}`, () => { }, }, }; - const resultState = setAsyncErrorReducer(state, new SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); + const resultState = setAsyncErrorReducer(state, SetAsyncErrorAction(FORM_CONTROL_ID, name, value)); expect(resultState.pendingValidations).toEqual([]); expect(resultState.isValidationPending).toEqual(true); }); diff --git a/src/group/reducer/set-async-error.ts b/src/group/reducer/set-async-error.ts index f6c93f3e..7d277d64 100644 --- a/src/group/reducer/set-async-error.ts +++ b/src/group/reducer/set-async-error.ts @@ -1,13 +1,13 @@ -import { Actions, SetAsyncErrorAction } from '../../actions'; +import {NgrxFormActionTypes, SetAsyncErrorAction} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { deepEquals } from '../../util'; import { childReducer } from './util'; export function setAsyncErrorReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== SetAsyncErrorAction.TYPE) { + if (action.type !== SetAsyncErrorAction.type) { return state; } diff --git a/src/group/reducer/set-errors.spec.ts b/src/group/reducer/set-errors.spec.ts index 63669ab5..dd7d40bb 100644 --- a/src/group/reducer/set-errors.spec.ts +++ b/src/group/reducer/set-errors.spec.ts @@ -15,7 +15,7 @@ import { describe(`form group ${setErrorsReducer.name}`, () => { it('should update state if there are errors', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState.errors).toEqual(errors); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -24,7 +24,7 @@ describe(`form group ${setErrorsReducer.name}`, () => { it('should update state if there are no errors', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, {})); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, {})); expect(resultState.errors).toEqual({}); expect(resultState.isValid).toBe(true); expect(resultState.isInvalid).toBe(false); @@ -32,32 +32,32 @@ describe(`form group ${setErrorsReducer.name}`, () => { it('should not update state if errors are same', () => { const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { required: true } }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, state.errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, state.errors)); expect(resultState).toBe(state); }); it('should not update state if errors are equal', () => { const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: { required: true } }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, { required: true })); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, { required: true })); expect(resultState).toBe(state); }); it('should not update state if control is disabled', () => { const errors = { required: true }; const state = { ...INITIAL_STATE, isEnabled: false, isDisabled: true }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState).toBe(state); }); it('should not update state if errors are equal and empty', () => { - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, {})); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, {})); expect(resultState).toBe(INITIAL_STATE); }); it('should update state if group is empty', () => { const errors = { required: true }; const state = createFormGroupState('test ID', {}); - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, errors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, errors)); expect(resultState.errors).toEqual(errors); expect(resultState.isValid).toBe(false); expect(resultState.isInvalid).toBe(true); @@ -67,21 +67,21 @@ describe(`form group ${setErrorsReducer.name}`, () => { const syncErrors = { required: true }; const asyncErrors = { $required: true }; const state = { ...INITIAL_STATE, isValid: false, isInvalid: true, errors: asyncErrors }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, syncErrors)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, syncErrors)); expect(resultState.errors).toEqual({ ...asyncErrors, ...syncErrors }); }); it('should throw if trying to set invalid error value', () => { - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, null as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, 1 as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, [] as any))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, { $required: true }))).toThrowError(); - expect(() => setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_ID, { _inner: true }))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, null as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, 1 as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, [] as any))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, { $required: true }))).toThrowError(); + expect(() => setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_ID, { _inner: true }))).toThrowError(); }); it('should aggregate child errors', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE, new SetErrorsAction(FORM_CONTROL_INNER_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE, SetErrorsAction(FORM_CONTROL_INNER_ID, errors)); expect(resultState.errors).toEqual({ _inner: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -89,7 +89,7 @@ describe(`form group ${setErrorsReducer.name}`, () => { it('should aggregate child errors for group children', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE_FULL, new SetErrorsAction(FORM_CONTROL_INNER3_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE_FULL, SetErrorsAction(FORM_CONTROL_INNER3_ID, errors)); expect(resultState.errors).toEqual({ _inner3: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -97,7 +97,7 @@ describe(`form group ${setErrorsReducer.name}`, () => { it('should aggregate child errors for array children', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE_FULL, new SetErrorsAction(FORM_CONTROL_INNER5_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE_FULL, SetErrorsAction(FORM_CONTROL_INNER5_ID, errors)); expect(resultState.errors).toEqual({ _inner5: errors }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -105,7 +105,7 @@ describe(`form group ${setErrorsReducer.name}`, () => { it('should aggregate nested child errors for group', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE_FULL, new SetErrorsAction(FORM_CONTROL_INNER4_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE_FULL, SetErrorsAction(FORM_CONTROL_INNER4_ID, errors)); expect(resultState.errors).toEqual({ _inner3: { _inner4: errors } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -113,7 +113,7 @@ describe(`form group ${setErrorsReducer.name}`, () => { it('should aggregate nested child errors for array', () => { const errors = { required: true }; - const resultState = setErrorsReducer(INITIAL_STATE_FULL, new SetErrorsAction(FORM_CONTROL_INNER5_0_ID, errors)); + const resultState = setErrorsReducer(INITIAL_STATE_FULL, SetErrorsAction(FORM_CONTROL_INNER5_0_ID, errors)); expect(resultState.errors).toEqual({ _inner5: { _0: errors } }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -122,8 +122,8 @@ describe(`form group ${setErrorsReducer.name}`, () => { it('should aggregate multiple child errors', () => { const errors1 = { required: true }; const errors2 = { min: 0 }; - let resultState = setErrorsReducer(INITIAL_STATE_FULL, new SetErrorsAction(FORM_CONTROL_INNER_ID, errors1)); - resultState = setErrorsReducer(resultState, new SetErrorsAction(FORM_CONTROL_INNER3_ID, errors2)); + let resultState = setErrorsReducer(INITIAL_STATE_FULL, SetErrorsAction(FORM_CONTROL_INNER_ID, errors1)); + resultState = setErrorsReducer(resultState, SetErrorsAction(FORM_CONTROL_INNER3_ID, errors2)); expect(resultState.errors).toEqual({ _inner: errors1, _inner3: errors2 }); expect(resultState.isValid).toEqual(false); expect(resultState.isInvalid).toEqual(true); @@ -148,7 +148,7 @@ describe(`form group ${setErrorsReducer.name}`, () => { }, }, }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_ID, errors1)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_ID, errors1)); expect(resultState.errors).toEqual({ ...errors1, _inner: errors2 }); }); @@ -161,7 +161,7 @@ describe(`form group ${setErrorsReducer.name}`, () => { errors: errors1, }; const errors2 = { min: 0 }; - const resultState = setErrorsReducer(state, new SetErrorsAction(FORM_CONTROL_INNER_ID, errors2)); + const resultState = setErrorsReducer(state, SetErrorsAction(FORM_CONTROL_INNER_ID, errors2)); expect(resultState.errors).toEqual({ ...errors1, _inner: errors2 }); }); }); diff --git a/src/group/reducer/set-errors.ts b/src/group/reducer/set-errors.ts index 3c955678..bad9c344 100644 --- a/src/group/reducer/set-errors.ts +++ b/src/group/reducer/set-errors.ts @@ -1,13 +1,13 @@ -import { Actions, SetErrorsAction } from '../../actions'; +import {NgrxFormActionTypes, SetErrorsAction} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue, ValidationErrors } from '../../state'; import { deepEquals } from '../../util'; import { childReducer } from './util'; export function setErrorsReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== SetErrorsAction.TYPE) { + if (action.type !== SetErrorsAction.type) { return state; } diff --git a/src/group/reducer/set-user-defined-property.spec.ts b/src/group/reducer/set-user-defined-property.spec.ts index 5e3da2f5..28357b43 100644 --- a/src/group/reducer/set-user-defined-property.spec.ts +++ b/src/group/reducer/set-user-defined-property.spec.ts @@ -9,7 +9,7 @@ describe(`form group ${setUserDefinedPropertyReducer.name}`, () => { it('should update state user defined properties if different', () => { const prop = 'prop'; const value = 12; - const resultState = setUserDefinedPropertyReducer(INITIAL_STATE, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(INITIAL_STATE,SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); expect(resultState.userDefinedProperties).toEqual({ [prop]: value, }); @@ -19,14 +19,14 @@ describe(`form group ${setUserDefinedPropertyReducer.name}`, () => { const prop = 'prop'; const value = 12; const state = { ...INITIAL_STATE, userDefinedProperties: { [prop]: value } }; - const resultState = setUserDefinedPropertyReducer(state, new SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(state,SetUserDefinedPropertyAction(FORM_CONTROL_ID, prop, value)); expect(resultState).toBe(state); }); it('should update state user defined properties for children', () => { const prop = 'prop'; const value = 12; - const resultState = setUserDefinedPropertyReducer(INITIAL_STATE, new SetUserDefinedPropertyAction(FORM_CONTROL_INNER_ID, prop, value)); + const resultState = setUserDefinedPropertyReducer(INITIAL_STATE,SetUserDefinedPropertyAction(FORM_CONTROL_INNER_ID, prop, value)); expect(resultState.controls.inner.userDefinedProperties).toEqual({ [prop]: value, }); diff --git a/src/group/reducer/set-user-defined-property.ts b/src/group/reducer/set-user-defined-property.ts index 4e0c25b2..cfc28842 100644 --- a/src/group/reducer/set-user-defined-property.ts +++ b/src/group/reducer/set-user-defined-property.ts @@ -1,12 +1,12 @@ -import { Actions, SetUserDefinedPropertyAction } from '../../actions'; +import {NgrxFormActionTypes, SetUserDefinedPropertyAction} from '../../actions'; import { FormGroupState, KeyValue } from '../../state'; import { childReducer } from './util'; export function setUserDefinedPropertyReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== SetUserDefinedPropertyAction.TYPE) { + if (action.type !== SetUserDefinedPropertyAction.type) { return state; } diff --git a/src/group/reducer/set-value.spec.ts b/src/group/reducer/set-value.spec.ts index a4565a9e..ca8865bc 100644 --- a/src/group/reducer/set-value.spec.ts +++ b/src/group/reducer/set-value.spec.ts @@ -15,62 +15,62 @@ import { describe(`form group ${setValueReducer.name}`, () => { it('should update state value if different', () => { const value = { inner: 'A' }; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); }); it('should not update state value if same', () => { const value = { inner: 'A' }; const state = { ...INITIAL_STATE, value }; - const resultState = setValueReducer(state, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(state, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState).toBe(state); }); it('should not mark state as dirty', () => { const value = { inner: 'A' }; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.isDirty).toEqual(false); }); it('should update child state value', () => { const value = { inner: 'A' }; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.controls.inner.value).toEqual(value.inner); }); it('should create child states on demand', () => { const value = { inner: 'A', inner2: 'B' }; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls.inner2!.value).toEqual(value.inner2); }); it('should create child states on demand for group children', () => { const value = { inner: 'A', inner3: { inner4: 'C' } }; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls.inner3!.value).toEqual(value.inner3); }); it('should create child states on demand for array children', () => { const value = { inner: 'A', inner5: ['C'] }; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls.inner5!.value).toEqual(value.inner5); }); it('should create child states on demand for null children', () => { const value = { inner: 'A', inner2: null as any as string }; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); expect(resultState.value).toEqual(value); expect(resultState.controls.inner2!.value).toEqual(value.inner2); }); it('should remove child states on demand', () => { const value = { inner: 'A', inner2: 'B' }; - let resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_ID, value)); + let resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_ID, value)); const value2 = { inner: 'A' }; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_ID, value2)); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_ID, value2)); expect(resultState.value).toEqual(value2); expect(resultState.controls.inner2).toBeUndefined(); }); @@ -79,20 +79,20 @@ describe(`form group ${setValueReducer.name}`, () => { interface FormValue { inner?: number; } const id = 'ID'; const state = createFormGroupState(id, { inner: 5 }); - const resultState = setValueReducer(state, new SetValueAction<{}>(id, {})); + const resultState = setValueReducer(state, SetValueAction(id, {})); expect(resultState.value).toEqual({}); expect(resultState.controls.inner).toBeUndefined(); }); it('should aggregate child values', () => { const value = 'A'; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_INNER_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_INNER_ID, value) as any); expect(resultState.value).toEqual({ inner: 'A' }); }); it('should not mark state as dirty if child value is updated', () => { const value = 'A'; - const resultState = setValueReducer(INITIAL_STATE, new SetValueAction(FORM_CONTROL_INNER_ID, value) as any); + const resultState = setValueReducer(INITIAL_STATE, SetValueAction(FORM_CONTROL_INNER_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls.inner.isDirty).toEqual(false); }); @@ -100,30 +100,30 @@ describe(`form group ${setValueReducer.name}`, () => { it('should aggregate child values for group children', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), ); const value = { inner4: 'D' }; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER3_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER3_ID, value) as any); expect(resultState.value.inner3).toEqual(value); }); it('should aggregate child values for array children', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), ); const value = ['D']; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER5_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER5_ID, value) as any); expect(resultState.value.inner5).toEqual(value); }); it('should not mark state as dirty if group child value is updated', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), ); const value = { inner4: 'D' }; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER3_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER3_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls.inner3!.isDirty).toEqual(false); }); @@ -131,10 +131,10 @@ describe(`form group ${setValueReducer.name}`, () => { it('should not mark state as dirty if array child value is updated', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), ); const value = ['D']; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER5_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER5_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls.inner5!.isDirty).toEqual(false); }); @@ -142,30 +142,30 @@ describe(`form group ${setValueReducer.name}`, () => { it('should aggregate nested child values in groups', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), ); const value = 'D'; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER4_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER4_ID, value) as any); expect(resultState.value.inner3!.inner4).toEqual(value); }); it('should aggregate nested child values in arrays', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), ); const value = 'D'; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER5_0_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER5_0_ID, value) as any); expect(resultState.value.inner5![0]).toEqual(value); }); it('should not mark state as dirty if nested child value in group is updated', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner3: { inner4: 'C' } }), ); const value = 'D'; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER4_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER4_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls.inner3!.controls.inner4.isDirty).toEqual(false); }); @@ -173,10 +173,10 @@ describe(`form group ${setValueReducer.name}`, () => { it('should not mark state as dirty if nested child value in array is updated', () => { let resultState = setValueReducer( INITIAL_STATE, - new SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), + SetValueAction(FORM_CONTROL_ID, { inner: 'A', inner5: ['C'] }), ); const value = 'D'; - resultState = setValueReducer(resultState, new SetValueAction(FORM_CONTROL_INNER5_0_ID, value) as any); + resultState = setValueReducer(resultState, SetValueAction(FORM_CONTROL_INNER5_0_ID, value) as any); expect(resultState.isDirty).toEqual(false); expect(resultState.controls.inner5!.controls[0].isDirty).toEqual(false); }); @@ -198,7 +198,7 @@ describe(`form group ${setValueReducer.name}`, () => { }, }, }; - const resultState = setValueReducer(state, new SetValueAction<{}>(id, {})); + const resultState = setValueReducer(state, SetValueAction(id, {})); expect(resultState.value).toEqual({}); expect(resultState.errors).toEqual({}); expect(resultState.controls.inner).toBeUndefined(); @@ -222,7 +222,7 @@ describe(`form group ${setValueReducer.name}`, () => { }, }, }; - const resultState = setValueReducer(state, new SetValueAction<{}>(id, {})); + const resultState = setValueReducer(state, SetValueAction(id, {})); expect(resultState.value).toEqual({}); expect(resultState.errors).toEqual(errors); expect(resultState.controls.inner).toBeUndefined(); diff --git a/src/group/reducer/set-value.ts b/src/group/reducer/set-value.ts index a843b047..b9071637 100644 --- a/src/group/reducer/set-value.ts +++ b/src/group/reducer/set-value.ts @@ -1,13 +1,13 @@ -import { Actions, SetValueAction } from '../../actions'; +import {NgrxFormActionTypes, SetValueAction} from '../../actions'; import { formStateReducer } from '../../reducer'; import { computeGroupState, createChildState, FormGroupControls, FormGroupState, KeyValue } from '../../state'; import { childReducer } from './util'; export function setValueReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== SetValueAction.TYPE) { + if (action.type !== SetValueAction.type) { return state; } @@ -31,7 +31,7 @@ export function setValueReducer( if (!state.controls[key]) { Object.assign(c, { [key]: createChildState(`${state.id}.${key}`, value[key]) }); } else { - Object.assign(c, { [key]: formStateReducer(state.controls[key], new SetValueAction(state.controls[key].id, value[key])) }); + Object.assign(c, { [key]: formStateReducer(state.controls[key], SetValueAction(state.controls[key].id, value[key])) }); } return c; }, {} as FormGroupControls); diff --git a/src/group/reducer/start-async-validation.spec.ts b/src/group/reducer/start-async-validation.spec.ts index 3b96a3d1..3e039216 100644 --- a/src/group/reducer/start-async-validation.spec.ts +++ b/src/group/reducer/start-async-validation.spec.ts @@ -14,7 +14,7 @@ describe(`form group ${startAsyncValidationReducer.name}`, () => { it('should update state with pending validation', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([name]); expect(resultState.isValidationPending).toBe(true); }); @@ -23,7 +23,7 @@ describe(`form group ${startAsyncValidationReducer.name}`, () => { const name = 'required'; const existingName = 'min'; const state = { ...INITIAL_STATE, pendingValidations: [existingName], isValidationPending: true }; - const resultState = startAsyncValidationReducer(state, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(state, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState.pendingValidations).toEqual([existingName, name]); expect(resultState.isValidationPending).toBe(true); }); @@ -31,32 +31,32 @@ describe(`form group ${startAsyncValidationReducer.name}`, () => { it('should not update state if validation is already pending', () => { const name = 'required'; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = startAsyncValidationReducer(state, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(state, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState).toBe(state); }); it('should not update state if validation is already pending', () => { const name = 'required'; const state = { ...INITIAL_STATE, pendingValidations: [name], isValidationPending: true }; - const resultState = startAsyncValidationReducer(state, new StartAsyncValidationAction(FORM_CONTROL_ID, name)); + const resultState = startAsyncValidationReducer(state, StartAsyncValidationAction(FORM_CONTROL_ID, name)); expect(resultState).toBe(state); }); it('should mark state as having validation pending if control child is marked as having validation pending', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE, new StartAsyncValidationAction(FORM_CONTROL_INNER_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE, StartAsyncValidationAction(FORM_CONTROL_INNER_ID, name)); expect(resultState.isValidationPending).toEqual(true); }); it('should mark state as having validation pending if group child is marked as having validation pending', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE_FULL, new StartAsyncValidationAction(FORM_CONTROL_INNER3_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE_FULL, StartAsyncValidationAction(FORM_CONTROL_INNER3_ID, name)); expect(resultState.isValidationPending).toEqual(true); }); it('should mark state as having validation pending if array child is marked as having validation pending', () => { const name = 'required'; - const resultState = startAsyncValidationReducer(INITIAL_STATE_FULL, new StartAsyncValidationAction(FORM_CONTROL_INNER5_ID, name)); + const resultState = startAsyncValidationReducer(INITIAL_STATE_FULL, StartAsyncValidationAction(FORM_CONTROL_INNER5_ID, name)); expect(resultState.isValidationPending).toEqual(true); }); }); diff --git a/src/group/reducer/start-async-validation.ts b/src/group/reducer/start-async-validation.ts index b805e7ab..b36fb945 100644 --- a/src/group/reducer/start-async-validation.ts +++ b/src/group/reducer/start-async-validation.ts @@ -1,12 +1,12 @@ -import { Actions, StartAsyncValidationAction } from '../../actions'; +import {NgrxFormActionTypes, StartAsyncValidationAction} from '../../actions'; import { computeGroupState, FormGroupState, KeyValue } from '../../state'; import { childReducer } from './util'; export function startAsyncValidationReducer( state: FormGroupState, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupState { - if (action.type !== StartAsyncValidationAction.TYPE) { + if (action.type !== StartAsyncValidationAction.type) { return state; } diff --git a/src/group/reducer/util.ts b/src/group/reducer/util.ts index 0f80a9d5..bba52e87 100644 --- a/src/group/reducer/util.ts +++ b/src/group/reducer/util.ts @@ -1,10 +1,10 @@ -import { Actions } from '../../actions'; +import { NgrxFormActionTypes} from '../../actions'; import { formStateReducer } from '../../reducer'; import { computeGroupState, FormGroupControls, FormGroupState, FormState, KeyValue } from '../../state'; export function dispatchActionPerChild( controls: FormGroupControls, - actionCreator: (controlId: string) => Actions, + actionCreator: (controlId: string) => NgrxFormActionTypes, ) { let hasChanged = false; const newControls = Object.keys(controls) @@ -18,7 +18,7 @@ export function dispatchActionPerChild( function callChildReducers( controls: FormGroupControls, - action: Actions, + action: NgrxFormActionTypes, ): FormGroupControls { let hasChanged = false; const newControls = Object.keys(controls) @@ -30,7 +30,7 @@ function callChildReducers( return hasChanged ? newControls : controls; } -export function childReducer(state: FormGroupState, action: Actions) { +export function childReducer(state: FormGroupState, action: NgrxFormActionTypes) { const controls = callChildReducers(state.controls, action); if (state.controls === controls) { diff --git a/src/ngrx-forms.spec.ts b/src/ngrx-forms.spec.ts index a4fb6c11..0bf5efe5 100644 --- a/src/ngrx-forms.spec.ts +++ b/src/ngrx-forms.spec.ts @@ -1,7 +1,6 @@ import { addArrayControl, addGroupControl, - ALL_NGRX_FORMS_ACTION_TYPES, box, clearAsyncError, compose, @@ -64,7 +63,6 @@ import { } from './ngrx-forms'; describe('ngrx-forms', () => { - it(`should export ALL_NGRX_FORMS_ACTION_TYPES`, () => expect(ALL_NGRX_FORMS_ACTION_TYPES).toBeDefined()); it(`should export ${compose.name}`, () => expect(compose).toBeDefined()); it(`should export ${isArrayState.name}`, () => expect(isArrayState).toBeDefined()); it(`should export ${isGroupState.name}`, () => expect(isGroupState).toBeDefined()); diff --git a/src/reducer.spec.ts b/src/reducer.spec.ts index 0ab0f577..ba2e8350 100644 --- a/src/reducer.spec.ts +++ b/src/reducer.spec.ts @@ -1,4 +1,4 @@ -import { Action, createReducer } from '@ngrx/store'; +import {Action, createReducer, on} from '@ngrx/store'; import { MarkAsDirtyAction, MarkAsTouchedAction, SetValueAction } from './actions'; import { formArrayReducer } from './array/reducer'; import { formControlReducer } from './control/reducer'; @@ -10,17 +10,17 @@ import { updateGroup } from './update-function/update-group'; describe(formStateReducer.name, () => { it('should apply the action to controls', () => { - const resultState = formStateReducer(INITIAL_STATE.controls.inner, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + const resultState = formStateReducer(INITIAL_STATE.controls.inner, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); expect(resultState).not.toBe(INITIAL_STATE.controls.inner); }); it('should apply the action to groups', () => { - const resultState = formStateReducer(INITIAL_STATE, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = formStateReducer(INITIAL_STATE, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState).not.toBe(INITIAL_STATE); }); it('should apply the action to arrays', () => { - const resultState = formStateReducer(INITIAL_STATE.controls.inner5, new MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); + const resultState = formStateReducer(INITIAL_STATE.controls.inner5, MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); expect(resultState).not.toBe(INITIAL_STATE.controls.inner5); }); @@ -38,7 +38,7 @@ describe(createFormStateReducerWithUpdate.name, () => { const value = 'A'; const resultState = createFormStateReducerWithUpdate(s => ({ ...s, value }))( INITIAL_STATE.controls.inner, - new MarkAsTouchedAction(FORM_CONTROL_INNER_ID), + MarkAsTouchedAction(FORM_CONTROL_INNER_ID), ); expect(resultState.isTouched).toBe(true); expect(resultState.value).toBe(value); @@ -48,7 +48,7 @@ describe(createFormStateReducerWithUpdate.name, () => { const userDefinedProperties = { value: 'A' }; const resultState = createFormStateReducerWithUpdate(s => ({ ...s, userDefinedProperties }))( INITIAL_STATE, - new MarkAsTouchedAction(FORM_CONTROL_ID), + MarkAsTouchedAction(FORM_CONTROL_ID), ); expect(resultState.isTouched).toBe(true); expect(resultState.userDefinedProperties).toEqual(userDefinedProperties); @@ -58,7 +58,7 @@ describe(createFormStateReducerWithUpdate.name, () => { const userDefinedProperties = { value: 'A' }; const resultState = createFormStateReducerWithUpdate(s => ({ ...s, userDefinedProperties }))( INITIAL_STATE.controls.inner5, - new MarkAsTouchedAction(FORM_CONTROL_INNER5_ID), + MarkAsTouchedAction(FORM_CONTROL_INNER5_ID), ); expect(resultState.isTouched).toBe(true); expect(resultState.userDefinedProperties).toEqual(userDefinedProperties); @@ -71,7 +71,7 @@ describe(createFormStateReducerWithUpdate.name, () => { s => ({ ...s, value: `${s.value}${value}` }), )( INITIAL_STATE.controls.inner, - new MarkAsTouchedAction(FORM_CONTROL_INNER_ID), + MarkAsTouchedAction(FORM_CONTROL_INNER_ID), ); expect(resultState.isTouched).toBe(true); expect(resultState.value).toBe(`${value}${value}`); @@ -84,7 +84,7 @@ describe(createFormStateReducerWithUpdate.name, () => { s => ({ ...s, value: `${s.value}${value}` }), ])( INITIAL_STATE.controls.inner, - new MarkAsTouchedAction(FORM_CONTROL_INNER_ID), + MarkAsTouchedAction(FORM_CONTROL_INNER_ID), ); expect(resultState.isTouched).toBe(true); expect(resultState.value).toBe(`${value}${value}`); @@ -94,7 +94,7 @@ describe(createFormStateReducerWithUpdate.name, () => { const expected = { ...INITIAL_STATE.controls.inner, value: 'A' }; const resultState = createFormStateReducerWithUpdate(() => expected)( INITIAL_STATE.controls.inner, - new MarkAsTouchedAction(FORM_CONTROL_INNER_ID), + MarkAsTouchedAction(FORM_CONTROL_INNER_ID), ); expect(resultState).toBe(expected); }); @@ -115,7 +115,7 @@ describe(createFormStateReducerWithUpdate.name, () => { inner: () => expectedInner1, }, ), - )(INITIAL_STATE, new SetValueAction(FORM_CONTROL_INNER_ID, 'D')); + )(INITIAL_STATE, SetValueAction(FORM_CONTROL_INNER_ID, 'D')); expect(resultState.controls.inner).toBe(expectedInner1); expect(resultState.controls.inner3).toBe(expectedInner3); }); @@ -138,7 +138,7 @@ describe(onNgrxForms.name, () => { form: INITIAL_STATE.controls.inner, }; - const resultState = onNgrxForms().reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + const resultState = onNgrxForms().reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); expect(resultState.form.id).toBe(INITIAL_STATE.controls.inner.id); expect(resultState.form).not.toBe(INITIAL_STATE.controls.inner); }); @@ -146,7 +146,7 @@ describe(onNgrxForms.name, () => { it('should call the reducer for top-level controls', () => { const state = INITIAL_STATE.controls.inner; - const resultState = onNgrxForms().reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + const resultState = onNgrxForms().reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); expect(resultState.id).toBe(INITIAL_STATE.controls.inner.id); expect(resultState).not.toBe(INITIAL_STATE.controls.inner); }); @@ -157,14 +157,14 @@ describe(onNgrxForms.name, () => { form: INITIAL_STATE, }; - const resultState = onNgrxForms().reducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = onNgrxForms().reducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.form).not.toBe(INITIAL_STATE); }); it('should call the reducer for top-level groups', () => { const state = INITIAL_STATE; - const resultState = onNgrxForms().reducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = onNgrxForms().reducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.id).toBe(INITIAL_STATE.id); expect(resultState).not.toBe(INITIAL_STATE); }); @@ -175,14 +175,14 @@ describe(onNgrxForms.name, () => { form: INITIAL_STATE.controls.inner5, }; - const resultState = onNgrxForms().reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); + const resultState = onNgrxForms().reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); expect(resultState.form).not.toBe(INITIAL_STATE.controls.inner5); }); it('should call the reducer for top-level arrays', () => { const state = INITIAL_STATE.controls.inner5; - const resultState = onNgrxForms().reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); + const resultState = onNgrxForms().reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); expect(resultState.id).toBe(INITIAL_STATE.controls.inner5.id); expect(resultState).not.toBe(INITIAL_STATE.controls.inner5); }); @@ -200,13 +200,13 @@ describe(onNgrxForms.name, () => { onNgrxForms(), ); - let resultState = reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + let resultState = reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); expect(resultState.control).not.toBe(INITIAL_STATE.controls.inner); - resultState = reducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + resultState = reducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.group).not.toBe(INITIAL_STATE); - resultState = reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); + resultState = reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); expect(resultState.array).not.toBe(INITIAL_STATE.controls.inner5); }); @@ -218,7 +218,7 @@ describe(onNgrxForms.name, () => { onNgrxForms(), ); - const resultState = reducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + const resultState = reducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.id).toBe(INITIAL_STATE.id); expect(resultState).not.toBe(INITIAL_STATE); }); @@ -234,44 +234,44 @@ describe(onNgrxFormsAction.name, () => { const reducer = createReducer( state, - onNgrxFormsAction(MarkAsTouchedAction, s => ({ ...s })), + on(MarkAsTouchedAction, s => ({ ...s })), ); it('should call the reducer for the correct action type', () => { - const resultState = reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + const resultState = reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); expect(resultState).not.toBe(state); }); it('should not call the reducer for the wrong action type', () => { - const resultState = reducer(state, new MarkAsDirtyAction(FORM_CONTROL_INNER_ID)); + const resultState = reducer(state, MarkAsDirtyAction(FORM_CONTROL_INNER_ID)); expect(resultState).toBe(state); }); it('should provide the action of the right type to the reducer', () => { const reducer = createReducer( state, - onNgrxFormsAction(MarkAsTouchedAction, (state, action) => { - expect(action instanceof MarkAsTouchedAction).toBe(true); + on(MarkAsTouchedAction, (state, action) => { + expect(action.type).toEqual(MarkAsTouchedAction.type); expect(action.controlId).toBe(FORM_CONTROL_INNER_ID); return state; }), ); - reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); }); it('should call the reducer in conjuction with onNgrxForms', () => { const reducer = createReducer( state, onNgrxForms(), - onNgrxFormsAction(MarkAsTouchedAction, (state, action) => { - expect(action instanceof MarkAsTouchedAction).toBe(true); + on(MarkAsTouchedAction, (state, action) => { + expect(action.type).toEqual(MarkAsTouchedAction.type) expect(action.controlId).toBe(FORM_CONTROL_INNER_ID); return state; }), ); - const resultState = reducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + const resultState = reducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); expect(resultState.control.isTouched).toBe(true); }); }); @@ -412,13 +412,13 @@ describe(wrapReducerWithFormStateUpdate.name, () => { const wrappedReducer = wrapReducerWithFormStateUpdate(reducer, s => s.control, s => ({ ...s })); - let resultState = wrappedReducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); + let resultState = wrappedReducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER_ID)); expect(resultState.control).not.toBe(INITIAL_STATE.controls.inner); - resultState = wrappedReducer(state, new MarkAsTouchedAction(FORM_CONTROL_ID)); + resultState = wrappedReducer(state, MarkAsTouchedAction(FORM_CONTROL_ID)); expect(resultState.group).not.toBe(INITIAL_STATE); - resultState = wrappedReducer(state, new MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); + resultState = wrappedReducer(state, MarkAsTouchedAction(FORM_CONTROL_INNER5_ID)); expect(resultState.array).not.toBe(INITIAL_STATE.controls.inner5); }); }); diff --git a/src/reducer.ts b/src/reducer.ts index 810bdc70..d1c5ad22 100644 --- a/src/reducer.ts +++ b/src/reducer.ts @@ -1,11 +1,10 @@ import { Action, ActionReducer } from '@ngrx/store'; - -import { Actions, ALL_NGRX_FORMS_ACTION_TYPES } from './actions'; import { formArrayReducer } from './array/reducer'; import { formControlReducer } from './control/reducer'; import { formGroupReducer } from './group/reducer'; import { AbstractControlState, FormArrayState, FormControlState, FormState, isArrayState, isFormState, isGroupState } from './state'; import { ProjectFn } from './update-function/util'; +import {ALL_NGRX_FORMS_ACTION_TYPES, NgrxFormActionTypes} from "./actions"; export function formStateReducer( state: FormState | AbstractControlState | undefined, @@ -109,7 +108,7 @@ export function onNgrxForms(): { reducer: ActionReducer; t } export interface ActionConstructor { - new(...args: any[]): Actions; + new(...args: any[]): NgrxFormActionTypes; readonly TYPE: string; } diff --git a/src/update-function/add-array-control.ts b/src/update-function/add-array-control.ts index 671dfbc4..0f20d528 100644 --- a/src/update-function/add-array-control.ts +++ b/src/update-function/add-array-control.ts @@ -17,7 +17,7 @@ export function addArrayControl(state: FormArrayState, value: TV export function addArrayControl(valueOrState: TValue | FormArrayState, indexOrValue: number | TValue | undefined, index?: number) { if (isArrayState(valueOrState)) { - return formArrayReducer(valueOrState, new AddArrayControlAction(valueOrState.id, indexOrValue as TValue, index)); + return formArrayReducer(valueOrState, AddArrayControlAction(valueOrState.id, indexOrValue as TValue, index)); } return (s: FormArrayState) => addArrayControl(ensureState(s), valueOrState as TValue, indexOrValue as number); diff --git a/src/update-function/add-group-control.ts b/src/update-function/add-group-control.ts index 08db915c..0617b502 100644 --- a/src/update-function/add-group-control.ts +++ b/src/update-function/add-group-control.ts @@ -28,7 +28,7 @@ export function addGroupControl(nameOrState.id, valueOrName as TControlKey, value!)); + return formGroupReducer(nameOrState, AddGroupControlAction(nameOrState.id, valueOrName as TValue[TControlKey], value!)); } return (s: FormGroupState) => addGroupControl(ensureState(s), nameOrState as TControlKey, valueOrName as TValue[TControlKey]); diff --git a/src/update-function/clear-async-error.ts b/src/update-function/clear-async-error.ts index 022c1e9a..921bc0b1 100644 --- a/src/update-function/clear-async-error.ts +++ b/src/update-function/clear-async-error.ts @@ -16,7 +16,7 @@ export function clearAsyncError(state: AbstractControlState, nam export function clearAsyncError(nameOrState: string | AbstractControlState, name?: string) { if (isFormState(nameOrState)) { - return abstractControlReducer(nameOrState, new ClearAsyncErrorAction(nameOrState.id, name!)); + return abstractControlReducer(nameOrState, ClearAsyncErrorAction(nameOrState.id, name!)); } return (s: AbstractControlState) => clearAsyncError(ensureState(s), nameOrState); diff --git a/src/update-function/disable.ts b/src/update-function/disable.ts index 76f25b29..7f85f1c4 100644 --- a/src/update-function/disable.ts +++ b/src/update-function/disable.ts @@ -32,5 +32,5 @@ export function disable(state: FormGroupState): FormGroupState(state: AbstractControlState): FormState; export function disable(state: AbstractControlState) { - return abstractControlReducer(state, new DisableAction(state.id)); + return abstractControlReducer(state, DisableAction(state.id)); } diff --git a/src/update-function/enable.ts b/src/update-function/enable.ts index 41793912..86b0c1e6 100644 --- a/src/update-function/enable.ts +++ b/src/update-function/enable.ts @@ -24,5 +24,5 @@ export function enable(state: FormGroupState): FormGroupState(state: AbstractControlState): FormState; export function enable(state: AbstractControlState) { - return abstractControlReducer(state, new EnableAction(state.id)); + return abstractControlReducer(state, EnableAction(state.id)); } diff --git a/src/update-function/focus.ts b/src/update-function/focus.ts index 416f4827..e6be6b46 100644 --- a/src/update-function/focus.ts +++ b/src/update-function/focus.ts @@ -7,5 +7,5 @@ import { FormControlState, FormControlValueTypes } from '../state'; * will also `.focus()` the form element). */ export function focus(state: FormControlState) { - return formControlReducer(state, new FocusAction(state.id)); + return formControlReducer(state, FocusAction(state.id)); } diff --git a/src/update-function/mark-as-dirty.ts b/src/update-function/mark-as-dirty.ts index acf08ef9..acfc65d9 100644 --- a/src/update-function/mark-as-dirty.ts +++ b/src/update-function/mark-as-dirty.ts @@ -24,5 +24,5 @@ export function markAsDirty(state: FormGroupState): FormGroupSta export function markAsDirty(state: AbstractControlState): FormState; export function markAsDirty(state: AbstractControlState) { - return abstractControlReducer(state, new MarkAsDirtyAction(state.id)); + return abstractControlReducer(state, MarkAsDirtyAction(state.id)); } diff --git a/src/update-function/mark-as-pristine.ts b/src/update-function/mark-as-pristine.ts index 921bc3e9..2802ae40 100644 --- a/src/update-function/mark-as-pristine.ts +++ b/src/update-function/mark-as-pristine.ts @@ -24,5 +24,5 @@ export function markAsPristine(state: FormGroupState): FormGroup export function markAsPristine(state: AbstractControlState): FormState; export function markAsPristine(state: AbstractControlState) { - return abstractControlReducer(state, new MarkAsPristineAction(state.id)); + return abstractControlReducer(state, MarkAsPristineAction(state.id)); } diff --git a/src/update-function/mark-as-submitted.ts b/src/update-function/mark-as-submitted.ts index b96eb1c4..1c77c364 100644 --- a/src/update-function/mark-as-submitted.ts +++ b/src/update-function/mark-as-submitted.ts @@ -24,5 +24,5 @@ export function markAsSubmitted(state: FormGroupState): FormGrou export function markAsSubmitted(state: AbstractControlState): FormState; export function markAsSubmitted(state: AbstractControlState) { - return abstractControlReducer(state, new MarkAsSubmittedAction(state.id)); + return abstractControlReducer(state, MarkAsSubmittedAction(state.id)); } diff --git a/src/update-function/mark-as-touched.ts b/src/update-function/mark-as-touched.ts index ea4b1756..45e47605 100644 --- a/src/update-function/mark-as-touched.ts +++ b/src/update-function/mark-as-touched.ts @@ -24,5 +24,5 @@ export function markAsTouched(state: FormGroupState): FormGroupS export function markAsTouched(state: AbstractControlState): FormState; export function markAsTouched(state: AbstractControlState) { - return abstractControlReducer(state, new MarkAsTouchedAction(state.id)); + return abstractControlReducer(state, MarkAsTouchedAction(state.id)); } diff --git a/src/update-function/mark-as-unsubmitted.ts b/src/update-function/mark-as-unsubmitted.ts index 98abf154..4a2ccfae 100644 --- a/src/update-function/mark-as-unsubmitted.ts +++ b/src/update-function/mark-as-unsubmitted.ts @@ -24,5 +24,5 @@ export function markAsUnsubmitted(state: FormGroupState): FormGr export function markAsUnsubmitted(state: AbstractControlState): FormState; export function markAsUnsubmitted(state: AbstractControlState) { - return abstractControlReducer(state, new MarkAsUnsubmittedAction(state.id)); + return abstractControlReducer(state, MarkAsUnsubmittedAction(state.id)); } diff --git a/src/update-function/mark-as-untouched.ts b/src/update-function/mark-as-untouched.ts index 9ed114ad..79dea8d7 100644 --- a/src/update-function/mark-as-untouched.ts +++ b/src/update-function/mark-as-untouched.ts @@ -24,5 +24,5 @@ export function markAsUntouched(state: FormGroupState): FormGrou export function markAsUntouched(state: AbstractControlState): FormState; export function markAsUntouched(state: AbstractControlState) { - return abstractControlReducer(state, new MarkAsUntouchedAction(state.id)); + return abstractControlReducer(state, MarkAsUntouchedAction(state.id)); } diff --git a/src/update-function/move-array-control.ts b/src/update-function/move-array-control.ts index f863f0be..9f681d32 100644 --- a/src/update-function/move-array-control.ts +++ b/src/update-function/move-array-control.ts @@ -17,7 +17,7 @@ export function moveArrayControl(state: FormArrayState, fromInde export function moveArrayControl(indexOrState: number | FormArrayState, fromIndex: number, toIndex?: number) { if (isArrayState(indexOrState)) { - return formArrayReducer(indexOrState, new MoveArrayControlAction(indexOrState.id, fromIndex, toIndex!)); + return formArrayReducer(indexOrState, MoveArrayControlAction(indexOrState.id, fromIndex, toIndex!)); } return (s: FormArrayState) => moveArrayControl(ensureState(s), indexOrState as number, fromIndex); diff --git a/src/update-function/remove-array-control.ts b/src/update-function/remove-array-control.ts index 86452247..c48d21f8 100644 --- a/src/update-function/remove-array-control.ts +++ b/src/update-function/remove-array-control.ts @@ -17,7 +17,7 @@ export function removeArrayControl(state: FormArrayState, index: export function removeArrayControl(indexOrState: number | FormArrayState, index?: number) { if (isArrayState(indexOrState)) { - return formArrayReducer(indexOrState, new RemoveArrayControlAction(indexOrState.id, index!)); + return formArrayReducer(indexOrState, RemoveArrayControlAction(indexOrState.id, index!)); } return (s: FormArrayState) => removeArrayControl(ensureState(s), indexOrState as number); diff --git a/src/update-function/remove-group-control.ts b/src/update-function/remove-group-control.ts index beae8586..55277857 100644 --- a/src/update-function/remove-group-control.ts +++ b/src/update-function/remove-group-control.ts @@ -13,12 +13,12 @@ export function removeGroupControl(name: keyof TValue): * This update function takes a group form state and a name and removes the * child control with the given name from the state. */ -export function removeGroupControl(state: FormGroupState, name: keyof TValue): FormGroupState; +export function removeGroupControl(state: FormGroupState, name: string): FormGroupState; -export function removeGroupControl(nameOrState: keyof TValue | FormGroupState, name?: keyof TValue) { +export function removeGroupControl(nameOrState: keyof TValue | FormGroupState, name?: string) { if (isGroupState(nameOrState)) { - return formGroupReducer(nameOrState, new RemoveGroupControlAction(nameOrState.id, name!)); + return formGroupReducer(nameOrState, RemoveGroupControlAction(nameOrState.id, name!)); } - return (s: FormGroupState) => removeGroupControl(ensureState(s), nameOrState as keyof TValue); + return (s: FormGroupState) => removeGroupControl(ensureState(s), nameOrState as string); } diff --git a/src/update-function/reset.ts b/src/update-function/reset.ts index fd8e0552..6cbf5122 100644 --- a/src/update-function/reset.ts +++ b/src/update-function/reset.ts @@ -28,5 +28,5 @@ export function reset(state: FormGroupState): FormGroupState(state: AbstractControlState): FormState; export function reset(state: AbstractControlState) { - return abstractControlReducer(state, new ResetAction(state.id)); + return abstractControlReducer(state, ResetAction(state.id)); } diff --git a/src/update-function/set-async-error.ts b/src/update-function/set-async-error.ts index ac86b82c..091edfc7 100644 --- a/src/update-function/set-async-error.ts +++ b/src/update-function/set-async-error.ts @@ -19,7 +19,7 @@ export function setAsyncError(state: AbstractControlState, name: export function setAsyncError(nameOrState: string | AbstractControlState, nameOrValue?: string | any, value?: any) { if (isFormState(nameOrState)) { - return abstractControlReducer(nameOrState, new SetAsyncErrorAction(nameOrState.id, nameOrValue, value)); + return abstractControlReducer(nameOrState, SetAsyncErrorAction(nameOrState.id, nameOrValue, value)); } return (s: AbstractControlState) => setAsyncError(ensureState(s), nameOrState, nameOrValue); diff --git a/src/update-function/set-errors.ts b/src/update-function/set-errors.ts index 27324b9e..2f2d19f2 100644 --- a/src/update-function/set-errors.ts +++ b/src/update-function/set-errors.ts @@ -43,7 +43,7 @@ export function setErrors( const errorsArray = Array.isArray(errorsOrErrorsArray) ? errorsOrErrorsArray : [errorsOrErrorsArray!]; const errors = errorsArray.concat(...rest).reduce((agg, err) => Object.assign(agg, err), {} as ValidationErrors); - return formStateReducer(errorsOrErrorsArrayOrState, new SetErrorsAction(errorsOrErrorsArrayOrState.id, errors)); + return formStateReducer(errorsOrErrorsArrayOrState, SetErrorsAction(errorsOrErrorsArrayOrState.id, errors)); } let errorsArray = Array.isArray(errorsOrErrorsArrayOrState) ? errorsOrErrorsArrayOrState : [errorsOrErrorsArrayOrState]; diff --git a/src/update-function/set-user-defined-property.ts b/src/update-function/set-user-defined-property.ts index e2493fec..9454509c 100644 --- a/src/update-function/set-user-defined-property.ts +++ b/src/update-function/set-user-defined-property.ts @@ -17,7 +17,7 @@ export function setUserDefinedProperty(state: AbstractControlState(nameOrState: string | FormState, valueOrName: any | string, value?: any) { if (isFormState(nameOrState)) { - return formStateReducer(nameOrState, new SetUserDefinedPropertyAction(nameOrState.id, valueOrName, value)); + return formStateReducer(nameOrState,SetUserDefinedPropertyAction(nameOrState.id, valueOrName, value)); } return (s: AbstractControlState) => setUserDefinedProperty(ensureState(s), nameOrState, valueOrName); diff --git a/src/update-function/set-value.ts b/src/update-function/set-value.ts index 63e3550f..e7b0384a 100644 --- a/src/update-function/set-value.ts +++ b/src/update-function/set-value.ts @@ -20,7 +20,7 @@ export function setValue(state: AbstractControlState, value: TVa export function setValue(valueOrState: TValue | AbstractControlState, value?: TValue) { if (isFormState(valueOrState)) { - return abstractControlReducer(valueOrState, new SetValueAction(valueOrState.id, value)); + return abstractControlReducer(valueOrState, SetValueAction(valueOrState.id, value)); } return (s: AbstractControlState) => setValue(ensureState(s), valueOrState); diff --git a/src/update-function/start-async-validation.ts b/src/update-function/start-async-validation.ts index 6de53bd7..bc2cd3a0 100644 --- a/src/update-function/start-async-validation.ts +++ b/src/update-function/start-async-validation.ts @@ -16,7 +16,7 @@ export function startAsyncValidation(state: AbstractControlState export function startAsyncValidation(nameOrState: string | AbstractControlState, name?: string) { if (isFormState(nameOrState)) { - return abstractControlReducer(nameOrState, new StartAsyncValidationAction(nameOrState.id, name!)); + return abstractControlReducer(nameOrState, StartAsyncValidationAction(nameOrState.id, name!)); } return (s: AbstractControlState) => startAsyncValidation(ensureState(s), nameOrState); diff --git a/src/update-function/swap-array-control.ts b/src/update-function/swap-array-control.ts index 48844418..8d7ee389 100644 --- a/src/update-function/swap-array-control.ts +++ b/src/update-function/swap-array-control.ts @@ -17,7 +17,7 @@ export function swapArrayControl(state: FormArrayState, fromInde export function swapArrayControl(indexOrState: number | FormArrayState, fromIndex: number, toIndex?: number) { if (isArrayState(indexOrState)) { - return formArrayReducer(indexOrState, new SwapArrayControlAction(indexOrState.id, fromIndex, toIndex!)); + return formArrayReducer(indexOrState, SwapArrayControlAction(indexOrState.id, fromIndex, toIndex!)); } return (s: FormArrayState) => swapArrayControl(ensureState(s), indexOrState as number, fromIndex); diff --git a/src/update-function/unfocus.ts b/src/update-function/unfocus.ts index 72b834c9..c8f6122b 100644 --- a/src/update-function/unfocus.ts +++ b/src/update-function/unfocus.ts @@ -7,5 +7,5 @@ import { FormControlState, FormControlValueTypes } from '../state'; * will also `.blur()` the form element). */ export function unfocus(state: FormControlState) { - return formControlReducer(state, new UnfocusAction(state.id)); + return formControlReducer(state, UnfocusAction(state.id)); } diff --git a/src/update-function/validate.ts b/src/update-function/validate.ts index 178a91fd..4fd350ae 100644 --- a/src/update-function/validate.ts +++ b/src/update-function/validate.ts @@ -54,7 +54,7 @@ export function validate( const functionArr = Array.isArray(functionOrFunctionArr) ? functionOrFunctionArr : [functionOrFunctionArr!]; const errors = functionArr.concat(...rest) .reduce((agg, validationFn) => Object.assign(agg, validationFn(stateOrFunctionOrFunctionArray.value)), {} as ValidationErrors); - return formStateReducer(stateOrFunctionOrFunctionArray, new SetErrorsAction(stateOrFunctionOrFunctionArray.id, errors)); + return formStateReducer(stateOrFunctionOrFunctionArray, SetErrorsAction(stateOrFunctionOrFunctionArray.id, errors)); } let updateFnArr = Array.isArray(stateOrFunctionOrFunctionArray) ? stateOrFunctionOrFunctionArray : [stateOrFunctionOrFunctionArray];