Skip to content

Commit ddedc50

Browse files
committed
6.7.0
Also fixes some errors/unused code caught by typescript 2.6
1 parent 77a58de commit ddedc50

File tree

5 files changed

+8
-55
lines changed

5 files changed

+8
-55
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# NOTE: For changelog information for v6.5.3 and above, please see the GitHub release notes.
2+
13
# 6.5.1 - Support typescript unused checks
24

35
* https://github.com/angular-redux/form/pull/32

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-redux/form",
3-
"version": "6.6.0",
3+
"version": "6.7.0",
44
"description": "Build Angular 2+ forms with Redux",
55
"dependencies": {
66
"immutable": "^3.8.1"

source/connect-array/connect-array.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
OnInit,
1414
} from '@angular/core';
1515
import {
16-
NG_VALUE_ACCESSOR,
1716
AbstractControl,
1817
FormArray,
1918
FormArrayName,
@@ -22,7 +21,6 @@ import {
2221
FormGroupDirective,
2322
NgModelGroup,
2423
ControlContainer,
25-
ControlValueAccessor,
2624
} from '@angular/forms';
2725

2826
import {
@@ -39,7 +37,7 @@ import {Unsubscribe} from 'redux';
3937
import {ConnectBase} from '../connect';
4038
import {FormStore} from '../form-store';
4139
import {State} from '../state';
42-
import {controlPath, selectValueAccessor} from '../shims';
40+
import {controlPath} from '../shims';
4341

4442
export class ConnectArrayTemplate {
4543
constructor(
@@ -61,15 +59,12 @@ export class ConnectArray extends ControlContainer implements OnInit {
6159

6260
private array = new FormArray([]);
6361

64-
private valueAccessor: ControlValueAccessor;
65-
6662
private key: string;
6763

6864
constructor(
6965
@Optional() @Host() @SkipSelf() private parent: ControlContainer,
7066
@Optional() @Self() @Inject(NG_VALIDATORS) private rawValidators: any[],
7167
@Optional() @Self() @Inject(NG_ASYNC_VALIDATORS) private rawAsyncValidators: any[],
72-
@Optional() @Self() @Inject(NG_VALUE_ACCESSOR) valueAccessors: any[],
7368
private connection: ConnectBase,
7469
private templateRef: TemplateRef<any>,
7570
private viewContainerRef: ViewContainerRef,
@@ -79,8 +74,6 @@ export class ConnectArray extends ControlContainer implements OnInit {
7974

8075
this.stateSubscription = this.store.subscribe(state => this.resetState(state));
8176

82-
this.valueAccessor = selectValueAccessor(<any> this, valueAccessors) || this.simpleAccessor();
83-
8477
this.registerInternals(this.array);
8578
}
8679

@@ -129,6 +122,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
129122
this.viewContainerRef.clear();
130123

131124
this.formDirective.form.removeControl(this.key);
125+
this.stateSubscription()
132126
}
133127

134128
private resetState(state: any) {
@@ -277,12 +271,4 @@ export class ConnectArray extends ControlContainer implements OnInit {
277271
`Cannot convert object of type ${typeof reference} / ${reference.toString()} to form element`);
278272
}
279273
}
280-
281-
private simpleAccessor() {
282-
return {
283-
writeValue: (value: any) => this.control.setValue(value),
284-
registerOnChange() {},
285-
registerOnTouched() {}
286-
};
287-
}
288274
}

source/shims.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import {
2-
NgControl,
32
ControlContainer,
43
ControlValueAccessor,
5-
DefaultValueAccessor,
64
CheckboxControlValueAccessor,
75
SelectControlValueAccessor,
86
SelectMultipleControlValueAccessor,
@@ -13,39 +11,6 @@ export function controlPath(name: string, parent: ControlContainer): string[] {
1311
return [...(parent.path || []), name];
1412
}
1513

16-
export function selectValueAccessor(
17-
dir: NgControl, valueAccessors: ControlValueAccessor[]): ControlValueAccessor | null {
18-
if (!valueAccessors) return null;
19-
20-
let defaultAccessor: ControlValueAccessor | null = null;
21-
let builtinAccessor: ControlValueAccessor | null = null;
22-
let customAccessor: ControlValueAccessor | null = null;
23-
valueAccessors.forEach((v: ControlValueAccessor) => {
24-
if (v.constructor === DefaultValueAccessor) {
25-
defaultAccessor = v;
26-
} else if (isBuiltInAccessor(v)) {
27-
if (builtinAccessor) {
28-
throw new Error(
29-
`More than one built-in value accessor matches form control with ${dir}`);
30-
}
31-
32-
builtinAccessor = v;
33-
} else {
34-
if (customAccessor) {
35-
throw new Error(
36-
`More than one custom value accessor matches form control with ${dir}`);
37-
}
38-
customAccessor = v;
39-
}
40-
});
41-
42-
if (customAccessor) return customAccessor;
43-
if (builtinAccessor) return builtinAccessor;
44-
if (defaultAccessor) return defaultAccessor;
45-
46-
throw new Error(`No valid value accessor for form control with, ${dir}`);
47-
}
48-
4914
const BUILTIN_ACCESSORS = [
5015
CheckboxControlValueAccessor,
5116
SelectControlValueAccessor,

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3418,9 +3418,9 @@ type-is@~1.6.14:
34183418
media-typer "0.3.0"
34193419
mime-types "~2.1.13"
34203420

3421-
typescript@latest:
3422-
version "2.4.1"
3423-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.1.tgz#c3ccb16ddaa0b2314de031e7e6fee89e5ba346bc"
3421+
typescript@^2.4.1:
3422+
version "2.6.2"
3423+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
34243424

34253425
uglify-js@^2.6, uglify-js@^2.7.5:
34263426
version "2.7.5"

0 commit comments

Comments
 (0)