@ngx-formly/core 6.1.6 → 6.1.8
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 +17 -3
- 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 +19 -5
- package/esm2020/lib/utils.mjs +12 -3
- package/fesm2015/ngx-formly-core.mjs +47 -10
- package/fesm2015/ngx-formly-core.mjs.map +1 -1
- package/fesm2020/ngx-formly-core.mjs +46 -10
- 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';
|
|
@@ -237,8 +237,17 @@ function observe(o, paths, setFn) {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
return {
|
|
240
|
-
setValue(
|
|
241
|
-
state.value
|
|
240
|
+
setValue(currentValue) {
|
|
241
|
+
if (currentValue === state.value) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const previousValue = state.value;
|
|
245
|
+
state.value = currentValue;
|
|
246
|
+
state.onChange.forEach((changeFn) => {
|
|
247
|
+
if (changeFn !== setFn) {
|
|
248
|
+
changeFn({ previousValue, currentValue, firstChange: false });
|
|
249
|
+
}
|
|
250
|
+
});
|
|
242
251
|
},
|
|
243
252
|
unsubscribe() {
|
|
244
253
|
state.onChange = state.onChange.filter((changeFn) => changeFn !== setFn);
|
|
@@ -876,6 +885,12 @@ class FormlyField {
|
|
|
876
885
|
}
|
|
877
886
|
resetRefs(field) {
|
|
878
887
|
if (field) {
|
|
888
|
+
if (field._localFields) {
|
|
889
|
+
field._localFields = [];
|
|
890
|
+
}
|
|
891
|
+
else {
|
|
892
|
+
defineHiddenProp(this.field, '_localFields', []);
|
|
893
|
+
}
|
|
879
894
|
if (field._componentRefs) {
|
|
880
895
|
field._componentRefs = field._componentRefs.filter((ref) => this.componentRefs.indexOf(ref) === -1);
|
|
881
896
|
}
|
|
@@ -911,7 +926,7 @@ class FormlyField {
|
|
|
911
926
|
expressionObserver.unsubscribe();
|
|
912
927
|
});
|
|
913
928
|
}
|
|
914
|
-
for (const path of [['template'], ['fieldGroupClassName'], ['validation', 'show']]) {
|
|
929
|
+
for (const path of [['focus'], ['template'], ['fieldGroupClassName'], ['validation', 'show']]) {
|
|
915
930
|
const fieldObserver = observe(field, path, ({ firstChange }) => !firstChange && field.options.detectChanges(field));
|
|
916
931
|
subscribes.push(() => fieldObserver.unsubscribe());
|
|
917
932
|
}
|
|
@@ -947,7 +962,15 @@ class FormlyField {
|
|
|
947
962
|
});
|
|
948
963
|
subscribes.push(() => sub.unsubscribe());
|
|
949
964
|
}
|
|
950
|
-
|
|
965
|
+
let templateFieldsSubs = [];
|
|
966
|
+
observe(field, ['_localFields'], ({ currentValue }) => {
|
|
967
|
+
templateFieldsSubs.forEach((unsubscribe) => unsubscribe());
|
|
968
|
+
templateFieldsSubs = (currentValue || []).map((f) => this.fieldChanges(f));
|
|
969
|
+
});
|
|
970
|
+
return () => {
|
|
971
|
+
subscribes.forEach((unsubscribe) => unsubscribe());
|
|
972
|
+
templateFieldsSubs.forEach((unsubscribe) => unsubscribe());
|
|
973
|
+
};
|
|
951
974
|
}
|
|
952
975
|
}
|
|
953
976
|
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 +1288,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1265
1288
|
}] } });
|
|
1266
1289
|
|
|
1267
1290
|
class FieldType {
|
|
1291
|
+
constructor() {
|
|
1292
|
+
this.field = {};
|
|
1293
|
+
}
|
|
1294
|
+
set controls(controls) {
|
|
1295
|
+
const f = this.field;
|
|
1296
|
+
f._localFields = controls
|
|
1297
|
+
.map((c) => c.control._fields || [])
|
|
1298
|
+
.flat()
|
|
1299
|
+
.filter((f) => f.formControl !== this.field.formControl);
|
|
1300
|
+
}
|
|
1268
1301
|
get model() {
|
|
1269
1302
|
return this.field.model;
|
|
1270
1303
|
}
|
|
@@ -1294,14 +1327,17 @@ class FieldType {
|
|
|
1294
1327
|
return this.field.id;
|
|
1295
1328
|
}
|
|
1296
1329
|
get formState() {
|
|
1297
|
-
return this.options
|
|
1330
|
+
return this.options?.formState || {};
|
|
1298
1331
|
}
|
|
1299
1332
|
}
|
|
1300
1333
|
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 });
|
|
1334
|
+
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
1335
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FieldType, decorators: [{
|
|
1303
1336
|
type: Directive
|
|
1304
|
-
}], propDecorators: {
|
|
1337
|
+
}], propDecorators: { controls: [{
|
|
1338
|
+
type: ViewChildren,
|
|
1339
|
+
args: [NgControl]
|
|
1340
|
+
}], field: [{
|
|
1305
1341
|
type: Input
|
|
1306
1342
|
}] } });
|
|
1307
1343
|
|
|
@@ -1391,7 +1427,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1391
1427
|
|
|
1392
1428
|
class FieldArrayType extends FieldType {
|
|
1393
1429
|
onPopulate(field) {
|
|
1394
|
-
if (
|
|
1430
|
+
if (hasKey(field)) {
|
|
1395
1431
|
const control = findControl(field);
|
|
1396
1432
|
registerControl(field, control ? control : new FormArray([], { updateOn: field.modelOptions.updateOn }));
|
|
1397
1433
|
}
|