@ngx-formly/core 6.2.0 → 6.2.1
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 +2 -2
- package/esm2020/lib/extensions/field-form/field-form.mjs +15 -2
- package/esm2020/lib/extensions/field-validation/field-validation.mjs +3 -8
- package/esm2020/lib/services/formly.builder.mjs +7 -8
- package/esm2020/lib/templates/field.type.mjs +4 -4
- package/esm2020/lib/templates/field.wrapper.mjs +2 -1
- package/fesm2015/ngx-formly-core.mjs +29 -20
- package/fesm2015/ngx-formly-core.mjs.map +1 -1
- package/fesm2020/ngx-formly-core.mjs +27 -19
- package/fesm2020/ngx-formly-core.mjs.map +1 -1
- package/lib/extensions/field-form/field-form.d.ts +1 -0
- package/lib/extensions/field-validation/field-validation.d.ts +0 -1
- package/lib/templates/field.type.d.ts +1 -1
- package/lib/templates/field.wrapper.d.ts +3 -1
- package/package.json +1 -1
|
@@ -529,17 +529,16 @@ class FormlyFormBuilder {
|
|
|
529
529
|
}
|
|
530
530
|
if (!field.parent) {
|
|
531
531
|
this._setOptions(field);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
532
|
+
}
|
|
533
|
+
disableTreeValidityCall(field.form, () => {
|
|
534
|
+
var _a, _b;
|
|
535
|
+
this._build(field);
|
|
536
|
+
if (!field.parent) {
|
|
535
537
|
const options = field.options;
|
|
536
538
|
(_a = options.checkExpressions) === null || _a === void 0 ? void 0 : _a.call(options, field, true);
|
|
537
539
|
(_b = options.detectChanges) === null || _b === void 0 ? void 0 : _b.call(options, field);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
this._build(field);
|
|
542
|
-
}
|
|
540
|
+
}
|
|
541
|
+
});
|
|
543
542
|
}
|
|
544
543
|
_build(field) {
|
|
545
544
|
var _a;
|
|
@@ -819,6 +818,7 @@ class FormlyField {
|
|
|
819
818
|
triggerHook(name, changes) {
|
|
820
819
|
var _a, _b;
|
|
821
820
|
if (name === 'onInit' || (name === 'onChanges' && changes.field && !changes.field.firstChange)) {
|
|
821
|
+
this.valueChangesUnsubscribe();
|
|
822
822
|
this.valueChangesUnsubscribe = this.fieldChanges(this.field);
|
|
823
823
|
}
|
|
824
824
|
if ((_b = (_a = this.field) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b[name]) {
|
|
@@ -906,7 +906,6 @@ class FormlyField {
|
|
|
906
906
|
this.componentRefs = [];
|
|
907
907
|
}
|
|
908
908
|
fieldChanges(field) {
|
|
909
|
-
this.valueChangesUnsubscribe();
|
|
910
909
|
if (!field) {
|
|
911
910
|
return () => { };
|
|
912
911
|
}
|
|
@@ -1311,7 +1310,7 @@ class FieldType {
|
|
|
1311
1310
|
constructor() {
|
|
1312
1311
|
this.field = {};
|
|
1313
1312
|
}
|
|
1314
|
-
set
|
|
1313
|
+
set _formlyControls(controls) {
|
|
1315
1314
|
const f = this.field;
|
|
1316
1315
|
f._localFields = controls
|
|
1317
1316
|
.map((c) => c.control._fields || [])
|
|
@@ -1352,10 +1351,10 @@ class FieldType {
|
|
|
1352
1351
|
}
|
|
1353
1352
|
}
|
|
1354
1353
|
FieldType.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FieldType, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1355
|
-
FieldType.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: FieldType, inputs: { field: "field" }, viewQueries: [{ propertyName: "
|
|
1354
|
+
FieldType.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: FieldType, inputs: { field: "field" }, viewQueries: [{ propertyName: "_formlyControls", predicate: NgControl, descendants: true }], ngImport: i0 });
|
|
1356
1355
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FieldType, decorators: [{
|
|
1357
1356
|
type: Directive
|
|
1358
|
-
}], propDecorators: {
|
|
1357
|
+
}], propDecorators: { _formlyControls: [{
|
|
1359
1358
|
type: ViewChildren,
|
|
1360
1359
|
args: [NgControl]
|
|
1361
1360
|
}], field: [{
|
|
@@ -1506,6 +1505,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1506
1505
|
}] });
|
|
1507
1506
|
|
|
1508
1507
|
class FieldWrapper extends FieldType {
|
|
1508
|
+
set _formlyControls(_) { }
|
|
1509
1509
|
set _staticContent(content) {
|
|
1510
1510
|
this.fieldComponent = content;
|
|
1511
1511
|
}
|
|
@@ -1916,19 +1916,14 @@ class FieldValidationExtension {
|
|
|
1916
1916
|
return (control) => {
|
|
1917
1917
|
const errors = validatorOption.validation(control, field, validatorOption.options);
|
|
1918
1918
|
if (isPromise(errors)) {
|
|
1919
|
-
return errors.then((v) => this.
|
|
1919
|
+
return errors.then((v) => this.handleResult(field, validatorName ? !!v : v, validatorOption));
|
|
1920
1920
|
}
|
|
1921
1921
|
if (isObservable(errors)) {
|
|
1922
|
-
return errors.pipe(map((v) => this.
|
|
1922
|
+
return errors.pipe(map((v) => this.handleResult(field, validatorName ? !!v : v, validatorOption)));
|
|
1923
1923
|
}
|
|
1924
1924
|
return this.handleResult(field, validatorName ? !!errors : errors, validatorOption);
|
|
1925
1925
|
};
|
|
1926
1926
|
}
|
|
1927
|
-
handleAsyncResult(field, errors, options) {
|
|
1928
|
-
// workaround for https://github.com/angular/angular/issues/13200
|
|
1929
|
-
field.options.detectChanges(field);
|
|
1930
|
-
return this.handleResult(field, errors, options);
|
|
1931
|
-
}
|
|
1932
1927
|
handleResult(field, errors, { name, options }) {
|
|
1933
1928
|
var _a, _b;
|
|
1934
1929
|
if (typeof errors === 'boolean') {
|
|
@@ -2028,11 +2023,14 @@ class FieldFormExtension {
|
|
|
2028
2023
|
markForCheck = true;
|
|
2029
2024
|
}
|
|
2030
2025
|
}
|
|
2031
|
-
if (null === c.validator
|
|
2026
|
+
if (null === c.validator && this.hasValidators(field, '_validators')) {
|
|
2032
2027
|
c.setValidators(() => {
|
|
2033
2028
|
const v = Validators.compose(this.mergeValidators(field, '_validators'));
|
|
2034
2029
|
return v ? v(c) : null;
|
|
2035
2030
|
});
|
|
2031
|
+
markForCheck = true;
|
|
2032
|
+
}
|
|
2033
|
+
if (null === c.asyncValidator && this.hasValidators(field, '_asyncValidators')) {
|
|
2036
2034
|
c.setAsyncValidators(() => {
|
|
2037
2035
|
const v = Validators.composeAsync(this.mergeValidators(field, '_asyncValidators'));
|
|
2038
2036
|
return v ? v(c) : of(null);
|
|
@@ -2054,6 +2052,17 @@ class FieldFormExtension {
|
|
|
2054
2052
|
}
|
|
2055
2053
|
return markForCheck;
|
|
2056
2054
|
}
|
|
2055
|
+
hasValidators(field, type) {
|
|
2056
|
+
var _a, _b;
|
|
2057
|
+
const c = field.formControl;
|
|
2058
|
+
if (((_a = c === null || c === void 0 ? void 0 : c._fields) === null || _a === void 0 ? void 0 : _a.length) > 1 && c._fields.some((f) => f[type].length > 0)) {
|
|
2059
|
+
return true;
|
|
2060
|
+
}
|
|
2061
|
+
else if (field[type].length > 0) {
|
|
2062
|
+
return true;
|
|
2063
|
+
}
|
|
2064
|
+
return (_b = field.fieldGroup) === null || _b === void 0 ? void 0 : _b.some((f) => (f === null || f === void 0 ? void 0 : f.fieldGroup) && !hasKey(f) && this.hasValidators(f, type));
|
|
2065
|
+
}
|
|
2057
2066
|
mergeValidators(field, type) {
|
|
2058
2067
|
var _a;
|
|
2059
2068
|
const validators = [];
|