This repository was archived by the owner on Oct 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +21
-5
lines changed
Expand file tree Collapse file tree 4 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @nll/ngx" ,
3- "version" : " 0.7.1 " ,
3+ "version" : " 0.7.2 " ,
44 "private" : false ,
55 "peerDependencies" : {
66 "@nll/dux" : " ^2.1.0" ,
Original file line number Diff line number Diff line change 11export * from './io-form.module' ;
22export * from './io-form.pipe' ;
33export * from './ioToForm' ;
4+ export * from './io-form-group.class' ;
5+ export * from './io-form-array.class' ;
Original file line number Diff line number Diff line change 1+ import { FormGroup } from '@angular/forms' ;
2+
3+ export class IoFormGroup extends FormGroup {
4+ // Extend patchValue to safe things up
5+ patchValue (
6+ value : unknown ,
7+ options : { onlySelf ?: boolean ; emitEvent ?: boolean } = { }
8+ ) : void {
9+ if ( typeof value === 'object' && value !== null ) {
10+ super . patchValue ( value , options ) ;
11+ }
12+ }
13+ }
Original file line number Diff line number Diff line change 1- import { FormControl , FormGroup } from '@angular/forms' ;
1+ import { FormControl } from '@angular/forms' ;
22import { DateFromDatelikeType , EnumType , OptionFromOptionalType } from '@nll/utils-ts/lib/io' ;
33import * as t from 'io-ts' ;
44import { DateFromISOStringType , OptionFromNullableType } from 'io-ts-types' ;
55
66import { IoFormArray } from './io-form-array.class' ;
7+ import { IoFormGroup } from './io-form-group.class' ;
78
89export type Control =
910 | t . StringType
@@ -29,7 +30,7 @@ export type Container = Group | Array;
2930const UNKNOWN_TYPE_WARNING =
3031 'IoFormService encountered an unknown type codec, defaulting to FormControl for type' ;
3132
32- export const ioToForm = ( io : IO ) : FormGroup | IoFormArray | FormControl => {
33+ export const ioToForm = ( io : IO ) : IoFormGroup | IoFormArray | FormControl => {
3334 switch ( io . _tag ) {
3435 // FormControls
3536 case 'BooleanType' :
@@ -40,13 +41,13 @@ export const ioToForm = (io: IO): FormGroup | IoFormArray | FormControl => {
4041 case 'DateFromDatelikeType' :
4142 return new FormControl ( ) ;
4243
43- // FormGroups
44+ // IoFormGroups
4445 case 'InterfaceType' :
4546 let group = { } ;
4647 for ( let k in io . props ) {
4748 group [ k ] = ioToForm ( io . props [ k ] ) ;
4849 }
49- return new FormGroup ( group ) ;
50+ return new IoFormGroup ( group ) ;
5051
5152 // FormArrays
5253 case 'ArrayType' :
You can’t perform that action at this time.
0 commit comments