- remove generic type constraints from directives to prevent errors during angular template type-checking (713497f), closes #225
- make
wrapReducerWithFormStateUpdatework properly if used on states that are form states themselves (9907718), closes #196
- export missing update functions
moveArrayControlandswapArrayControl(#193), thanks @jamie94bc for this fix
- allow
undefinedproperty values in boxed objects, thanks @alex-vg for reporting this bug (22b2667), closes #186
- allow
onNgrxFormsto work on form states directly instead of requiring form states to be direct children of reduced states (b81abb4)
- add new validation function
numberto validate a value is a number (useful in cases where the concrete type of a value is unknown) (#182), thanks @dzonatan for implementing this feature - ignore non-numeric values in
lessThan,lessThanOrEqualTo,greaterThan, andgreaterThanOrEqualTovalidation functions (#182), thanks @dzonatan for this change - export the
NGRX_UPDATE_ON_TYPEenum (#184), thanks @dzonatan for this change
- add support for local form states outside of the ngrx store (#166), closes #165, see the user guide for more details, thanks @mucaho for implementing this great feature
This major release contains only a bugfix which is a breaking change.
-
do not treat empty strings or arrays as an error in
minLengthvalidation function (#164), thanks @Sloff for reporting and fixing this bugIf you require these values to be treated as errors use
minLengthtogether withrequired(e.g.validate(required, minLength(2)))
- use project tsconfig.json with ng-packagr during build; this bug lead to incorrect type definitions (#163), thanks @tomvandezande for reporting and fixing this bug
This version is skipped due to an invalid package having been published.
- ensure form states are correctly updated from actions when using
onNgrxFormsActionwithonNgrxForms(ee5dccf)
-
add function
onNgrxFormsActionthat allows specifying a reducer for ngrx-forms actions withcreateReducerfrom ngrx 8 (5cdf9c6)It can be used as follows:
import { createReducer } from '@ngrx/store'; import { onNgrxForms, onNgrxFormsAction, SetValueAction, updateGroup, validate, wrapReducerWithFormStateUpdate, } from 'ngrx-forms'; import { required } from 'ngrx-forms/validation'; export interface LoginFormValue { username: string; password: string; stayLoggedIn: boolean; } export const initialLoginFormValue: LoginFormValue = { username: '', password: '', stayLoggedIn: false, }; export const validateLoginForm = updateGroup<LoginFormValue>({ username: validate(required), password: validate(required), }); const reducer = createReducer( { loginForm: createFormGroupState('loginForm', initialLoginFormValue), // your other properties... }, onNgrxForms(), // use this to call a reducer for a specific ngrx-forms action; // note that this must be placed after onNgrxForms onNgrxFormsAction(SetValueAction, (state, action) => { if (action.controlId === 'loginForm.username') { // react to username changing... // action is of type SetValueAction } return state; }), // your other reducers... );
-
add functions
onNgrxFormsandwrapReducerWithFormStateUpdateto allow better integration withcreateReducerfrom ngrx 8 (ac95be2), closes #147They can be used as follows:
import { createReducer } from '@ngrx/store'; import { onNgrxForms, updateGroup, validate, wrapReducerWithFormStateUpdate } from 'ngrx-forms'; import { required } from 'ngrx-forms/validation'; export interface LoginFormValue { username: string; password: string; stayLoggedIn: boolean; } export const initialLoginFormValue: LoginFormValue = { username: '', password: '', stayLoggedIn: false, }; export const validateLoginForm = updateGroup<LoginFormValue>({ username: validate(required), password: validate(required), }); const rawReducer = createReducer( { loginForm: createFormGroupState('loginForm', initialLoginFormValue), // your other properties... }, onNgrxForms(), // your other reducers... ); // wrapReducerWithFormStateUpdate calls the update function // after the given reducer; you can wrap this reducer again // if you have multiple forms in your state export const reducer = wrapReducerWithFormStateUpdate( rawReducer, // point to the form state to update s => s.loginForm, // this function is always called after the reducer validateLoginForm, );
-
add update functions for async validations (8985e99)
-
export constant
ALL_NGRX_FORMS_ACTION_TYPESthat is an array of all action types ngrx-forms provides (09aad36)
- allow setting async errors if the validation is not pending (3f5c6d0)
- allow clearing async errors on groups and arrays if the validation is not pending (ff13472)
- remove readonly modifier from array control state value (28e781c), thanks @dzonatan for reporting this bug, closes #155
- remove direct reference to
Eventsince that causes errors in NativeScript applications (1ac565a), thanks @bufke for reporting this bug, closes #153
- remove any references to
UIEventsince that causes errors in NativeScript applications (70cdbc2), thanks @bufke for reporting this bug, closes #153
This is a compatibility release for Angular 8 and TypeScript 3.4.
- update peer dependencies to require Angular
>=8.0.0 - update peer dependencies to require TypeScript
>=3.4.0
- refactor
FormStateandUnboxedconditional type definitions to be simpler, which can improve build times and IDE performance (e9f504b), (24b25db)
- switch to ng-packagr for building the library (2d126c5)
- add dtslint tests to ensure stability of
FormStateandUnboxedtypes (255c648)
- allow enabling empty disabled array states (8a33d12), thanks @nihique for reporting this bug, closes #149
This is a beta release in preparation for the release of Angular 8.
- allow enabling empty disabled array states (8a33d12), thanks @nihique for reporting this bug, closes #149
This is a beta release in preparation for the release of Angular 8.
- update peer dependencies to require Angular
>=8.0.0 - update peer dependencies to require TypeScript
>=3.4.0
- refactor
FormStateandUnboxedconditional type definitions to be simpler, which can improve build times and IDE performance (e9f504b), (24b25db)
- switch to ng-packagr for building the library (2d126c5)
- add dtslint tests to ensure stability of
FormStateandUnboxedtypes (255c648)
- add actions and update functions to swap or move array controls (42c2518), thanks @solnat and @tashoecraft for their contributions in #133)
- allow clearing async error without pending validation (6116081), thanks @magnattic for reporting this bug, closes #143
- allow boxed
undefinedvalues as form control values (ab5ff58), thanks @dzonatan for reporting this bug, closes #131
- add support for Angular 7, ngrx v7, and TypeScript 3.1.X (aad53c4), thanks @wbhob for his contribution in #130)
- allow boxed
undefinedvalues as form control values (4d6cc03), thanks @dzonatan for reporting this bug, closes #131
- fix wrong inferred value type for
equalToandnotEqualTovalidation functions when used withvalidateupdate function (0cc6ca3)
- add new option
neverforngrxUpdateOn(ea0b284), see documentation for more details, thanks @Mr-Eluzive for their contribution in #119), closes #118
- allow setting
nullandundefinedvalues with curried version ofsetValue(fe92a23), thanks @chrissena for reporting this bug, closes #116
- check if platform is browser in default view adapter to prevent error during server-side rendering (0646fb7), thanks @scott-wyatt for his contribution in #111), closes #110
- remove module augmentations for
requiredTrueandrequiredFalsevalidation errors since they conflict with therequiredmodule augmentation and are already covered by it (1ab557f), closes #92
This release requires TypeScript >=2.8.0 for the conditional type support. It also requires Angular >= 6.1.0 for compatibility with that TypeScript version.
- remove
castutility function since it is obsolete due to proper control type inference - change order of parameters for many update functions to more be consistent
addArrayControl: movestateparameter to first position for uncurried overload (ab094b8)removeArrayControl: movestateparameter to first position for uncurried overload (5a5aa17)addGroupControl: movestateparameter to first position for uncurried overload (b6da5ee)removeGroupControl: movestateparameter to first position for uncurried overload (a9035ce)setErrors: rework to support different parameter combinations for errors (i.e. single error object, array of error objects, and rest parameters) and movestateparameter to first position for uncurried overload (15ea555)setUserDefinedProperty: movestateparameter to first position for uncurried overload (520c384)setValue: movestateparameter to first position for uncurried overload (1a69795)validate: movestateparameter to first position for uncurried overload and add rest param overloads
- due to rework of
updateArray,updateGroup, andupdateRecursiveupdate functions it is now invalid to call any of these functions without parameters (which made no sense anyway) but it is still possible to call the functions with an empty array as parameter (which is useful in dynamic situations) - remove
payloadproperty from all actions and move corresponding properties into action itself (6f955e9) - replace
createFormGroupReducerWithUpdatewithcreateFormStateReducerWithUpdate(which takes any kind of form state, it also behaves differently in that it only applies the update if the form state changes as part of reducing the action, see the user guide for more details) (1b6114c) - mark all state properties as
readonlyto make it more clear the state is not meant to be modified directly (291e0da) - change form arrays and groups to preserve the values of
isDirty,isEnabled,isTouched, andisSubmittedwhen the state is changed instead of always recomputing the values of these properties based on the state's child states (e.g. the state is not automatically disabled when all its child states are disabled, it is not automatically marked as pristine if it was dirty and all its child states are marked as pristine or all children are removed, etc.) (9202d1e), closes #68 - mark arrays and groups as dirty when adding or removing controls (9202d1e)
- use conditional types to infer the type of child controls (see the documentation for more details)
- add support for using arrays and objects as control values via boxing (see the documentation for more details) (315ae4c)
- add
formStateReducerfunction, a reducer which can reduce any kind of form state and is correctly typed due to conditional type inference (48eaaeb) - rework
updateArrayto support different parameter combinations for update functions (i.e. single function, array of functions, and rest parameters) (f82abf8) - rework
updateGroupto support different parameter combinations for update function objects (i.e. single object, array of objects, and rest parameters) which reduces the probability of false type inference results (0bb1ca7) - rework
updateRecursiveto support different parameter combinations for update function objects (i.e. single object, array of objects, and rest parameters) (96121c3) - add
updateArrayWithFilterupdate function which works the same asupdateArrayexcept that it also takes a filter function that is applied to each array element to determine whether the update function should be applied (0b66a6f) - add
notEqualTovalidation function (851a1ed) - enhance all form state reducers to match type signature for
ActionReducer(they will still throw an error if the state isundefined) (f3b5fea) - add support for
undefinedvalues for all validation functions (6cce8d0, thanks @romankhrystynych for his contribution in #65), closes #64 - improve typing of
errorsproperty on form states by using module augmentation inside of validation module to add well defined error properties toValidationErrorsinterface (e202e65) - move documentation to Read the Docs
- add FAQ
- add some reducer tests for example application to showcase how ngrx-forms can be tested (5098f02), closes #58
- do not automatically set
idof form elements to state's ID for elements that already have anidset (3c8eabc), closes #86
- fix typing of action
typeandTYPEproperties to properly use literal string type (0cd07b6), closes #75, thanks @bufke for helping me find this
- recursively update nested controls IDs when adding controls to arrays (7b1de7c), closes #72 (thanks @solnat for this fix)
- ensure the
valueattribute ofoptionelements is properly set via[value]bindings when there is no associated form view adapter (bfaa388) (closes #67, thanks @kmiskiewicz for helping me find this)
- do not focus or blur form elements initially or on state changes when focus tracking is not enabled (f6a10d5) (thanks @bufke for helping me find this)
- make implicit browser platform dependency optional and disallow focus tracking on non-browser platforms (e7760bc) (thanks @bufke for helping me find this)
- allow action
typeto be undefined inside form state reducers (0a61def), closes #44 (thanks @lucax88x)
- add support for array values in
minLength,maxLength, andrequiredvalidation functions (c88353a), closes #40 (thanks @icepeng) - set CSS classes on form elements based on the status of the control (see the documentation for more details) (eddcbf4), closes #34
- empty groups and arrays are now always enabled instead of disabled and therefore errors can now be set on empty groups and arrays (note that this is only a minor breaking change and only applies in edge cases and therefore this fix is included in a new minor instead of a new major version) (749c1b5), closes #37
- fix missing union case in typing of
updateArrayupdate function that causes a compile error if used inside anupdateGroup(fa7dccc) - fix
updateGroupthrowing an error if an empty update object was provided in curried as well as uncurried version (bee4d54) - fix
createFormGroupStateproducing results inconsistent with how group states are recomputed from their children after an update (1c62d8c) - fix
createFormArrayStateproducing results inconsistent with how array states are recomputed from their children after an update (70fdc10)
- fix
selectcontrols not properly selectingoptionifoptionis added to the DOM after the value of the state was set to the value of the option (0c2c0cc), closes #23
- improve performance by ignoring irrelevant actions in reducers
- fix issue that causes user defined properties not being properly set for form controls in groups or arrays when setting them by dispatching actions (ba0c34f), closes #24
- properly handle case where the
addArrayControlupdate function is called with only a value but neither an index nor a state
- add support for arrays of form controls (19d4e49)
- add support for asynchronous validation (see the documentation for more details) (f208e61)
- add value converter for object to JSON conversion (2ba37ee) (thanks @tbroadley)
- add support for error composition by extending
validateupdate function to take a single validation function or an array of validation functions (ba976c5) - add
setErrorsupdate function (ee25ca8) - add
resetupdate function (d380e67) - add
updateRecursiveupdate function (see the documentation for a usage example) (31f9d5d) - add common set of validation functions (40308d4)
- add support for user defined properties on form controls and groups (d9778d2)
- introduce concept of
FormViewAdapterand rewrite all control value accessors from scratch as view adapters (see the documentation for more details) - extend example application to contain multiple examples
- added overloads for many update functions that make casting the state unnecessary in certain situations
- added lots of inline comments to the API making it easier to understand what certain functions do right in your IDE
- remove support for last keydown code tracking on form controls (this feature has been superseded by user defined properties which allow associating any kind of metadata with a control)
- rename
groupUpdateReducertocreateFormGroupReducerWithUpdatein order to make it clearer that the function itself is not a reducer - remove erroneously exposed function
createChildStatefrom public API - change
optionelementvaluebindings to work correctly for all primitive data types thereby removing the need forngValuebindings - trying to set an error with a key prefixed with
$will now throw an error since the$prefix is used to mark async errors - applying the
ngrxFormControlStatedirective to a form element will now set the element'sidattribute to the ID of the state (thereby overriding any already presentid) - the
isDirtyproperty for form controls is now not set automatically the first time the state's value changes, but instead it is set manually from theNgrxFormControlDirectivethe first time the underlyingFormViewAdapterorControlValueAccessorreports a new value; this means if you were e.g. using thesetValueupdate function in your reducer before this will now not mark the state asdirtyanymore - rename
addControlupdate function toaddGroupControl - rename
AddControlActiontoAddGroupControlAction(also renaming itstypefromngrx/forms/ADD_CONTROLtongrx/forms/ADD_GROUP_CONTROL) - rename
removeControlupdate function toremoveGroupControl - rename
RemoveControlActiontoRemoveGroupControlAction(also renaming itstypefromngrx/forms/REMOVE_CONTROLtongrx/forms/REMOVE_GROUP_CONTROL)
- fix issue that caused bundled library to be larger than required due to external dependencies being included in the bundle (drastically reducing its size)
- change
updateGroupsfunction to properly accept multiple update function objects as written in the documentation
- add support for controlling when the view value is pushed to the state via
ngrxUpdateOn - add support for value conversion via
ngrxValueConverter
- add support for
ngValueonoptionelements, thereby fixing non-string option values not working forselectelements (thanks @nathanmarks for finding this issue) - fix issue that prevents setting a value via state change if the same value was previously set via the view (thanks @nathanmarks for finding this issue)
- fix issue that caused control state value to not be properly set to form element if the ID of the control state changed but the state's value was the same as the last value the view reported for the previous state
- changed form control state directive to run its initialization code inside the
ngAfterViewInithook instead ofngOnInitto allow proper interaction with form elements that can have dynamically rendered children they depend on (e.g. dynamicoptions forselects) (thanks @nathanmarks for finding this issue)
- Initial version of the library