@ngx-formly/core 6.1.6 → 6.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/components/formly.field.mjs +16 -2
- package/esm2020/lib/models/fieldconfig.cache.mjs +1 -1
- package/esm2020/lib/templates/field-array.type.mjs +2 -2
- package/esm2020/lib/templates/field.type.mjs +15 -4
- package/fesm2015/ngx-formly-core.mjs +30 -6
- package/fesm2015/ngx-formly-core.mjs.map +1 -1
- package/fesm2020/ngx-formly-core.mjs +30 -6
- package/fesm2020/ngx-formly-core.mjs.map +1 -1
- package/lib/models/fieldconfig.cache.d.ts +1 -0
- package/lib/templates/field.type.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Type, TemplateRef, ComponentRef, ChangeDetectorRef, InjectionToken, Injectable, Optional, Directive, Input, ViewContainerRef, Component, ViewChild, EventEmitter, ChangeDetectionStrategy, Output, ContentChildren, Inject, NgModule } from '@angular/core';
|
|
2
|
+
import { Type, TemplateRef, ComponentRef, ChangeDetectorRef, InjectionToken, Injectable, Optional, Directive, Input, ViewContainerRef, Component, ViewChild, EventEmitter, ChangeDetectionStrategy, Output, ContentChildren, Inject, ViewChildren, NgModule } from '@angular/core';
|
|
3
3
|
import * as i2 from '@angular/forms';
|
|
4
|
-
import { AbstractControl, FormGroup, FormArray, FormControl, Validators } from '@angular/forms';
|
|
4
|
+
import { AbstractControl, FormGroup, FormArray, FormControl, NgControl, Validators } from '@angular/forms';
|
|
5
5
|
import { isObservable, merge, of, Observable, Subject } from 'rxjs';
|
|
6
6
|
import { distinctUntilChanged, startWith, debounceTime, filter, switchMap, take, tap, map } from 'rxjs/operators';
|
|
7
7
|
import * as i2$1 from '@angular/common';
|
|
@@ -876,6 +876,12 @@ class FormlyField {
|
|
|
876
876
|
}
|
|
877
877
|
resetRefs(field) {
|
|
878
878
|
if (field) {
|
|
879
|
+
if (field._localFields) {
|
|
880
|
+
field._localFields = [];
|
|
881
|
+
}
|
|
882
|
+
else {
|
|
883
|
+
defineHiddenProp(this.field, '_localFields', []);
|
|
884
|
+
}
|
|
879
885
|
if (field._componentRefs) {
|
|
880
886
|
field._componentRefs = field._componentRefs.filter((ref) => this.componentRefs.indexOf(ref) === -1);
|
|
881
887
|
}
|
|
@@ -947,7 +953,15 @@ class FormlyField {
|
|
|
947
953
|
});
|
|
948
954
|
subscribes.push(() => sub.unsubscribe());
|
|
949
955
|
}
|
|
950
|
-
|
|
956
|
+
let templateFieldsSubs = [];
|
|
957
|
+
observe(field, ['_localFields'], ({ currentValue }) => {
|
|
958
|
+
templateFieldsSubs.forEach((unsubscribe) => unsubscribe());
|
|
959
|
+
templateFieldsSubs = (currentValue || []).map((f) => this.fieldChanges(f));
|
|
960
|
+
});
|
|
961
|
+
return () => {
|
|
962
|
+
subscribes.forEach((unsubscribe) => unsubscribe());
|
|
963
|
+
templateFieldsSubs.forEach((unsubscribe) => unsubscribe());
|
|
964
|
+
};
|
|
951
965
|
}
|
|
952
966
|
}
|
|
953
967
|
FormlyField.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyField, deps: [{ token: FormlyConfig }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: FormlyFieldTemplates, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -1265,6 +1279,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1265
1279
|
}] } });
|
|
1266
1280
|
|
|
1267
1281
|
class FieldType {
|
|
1282
|
+
set controls(controls) {
|
|
1283
|
+
const f = this.field;
|
|
1284
|
+
f._localFields = controls
|
|
1285
|
+
.map((c) => c.control._fields || [])
|
|
1286
|
+
.flat()
|
|
1287
|
+
.filter((f) => f.formControl !== this.field.formControl);
|
|
1288
|
+
}
|
|
1268
1289
|
get model() {
|
|
1269
1290
|
return this.field.model;
|
|
1270
1291
|
}
|
|
@@ -1298,10 +1319,13 @@ class FieldType {
|
|
|
1298
1319
|
}
|
|
1299
1320
|
}
|
|
1300
1321
|
FieldType.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FieldType, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1301
|
-
FieldType.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: FieldType, inputs: { field: "field" }, ngImport: i0 });
|
|
1322
|
+
FieldType.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: FieldType, inputs: { field: "field" }, viewQueries: [{ propertyName: "controls", predicate: NgControl, descendants: true }], ngImport: i0 });
|
|
1302
1323
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FieldType, decorators: [{
|
|
1303
1324
|
type: Directive
|
|
1304
|
-
}], propDecorators: {
|
|
1325
|
+
}], propDecorators: { controls: [{
|
|
1326
|
+
type: ViewChildren,
|
|
1327
|
+
args: [NgControl]
|
|
1328
|
+
}], field: [{
|
|
1305
1329
|
type: Input
|
|
1306
1330
|
}] } });
|
|
1307
1331
|
|
|
@@ -1391,7 +1415,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1391
1415
|
|
|
1392
1416
|
class FieldArrayType extends FieldType {
|
|
1393
1417
|
onPopulate(field) {
|
|
1394
|
-
if (
|
|
1418
|
+
if (hasKey(field)) {
|
|
1395
1419
|
const control = findControl(field);
|
|
1396
1420
|
registerControl(field, control ? control : new FormArray([], { updateOn: field.modelOptions.updateOn }));
|
|
1397
1421
|
}
|