@rxap/forms 13.0.3 → 13.0.5
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/directives/form.directive.mjs +14 -4
- package/esm2020/lib/form-array.mjs +12 -11
- package/esm2020/lib/types.mjs +1 -1
- package/fesm2015/rxap-forms.mjs +24 -13
- package/fesm2015/rxap-forms.mjs.map +1 -1
- package/fesm2020/rxap-forms.mjs +24 -13
- package/fesm2020/rxap-forms.mjs.map +1 -1
- package/lib/types.d.ts +1 -7
- package/package.json +1 -1
package/fesm2020/rxap-forms.mjs
CHANGED
|
@@ -241,18 +241,19 @@ class RxapFormArray extends FormArray {
|
|
|
241
241
|
// `undefined` as a value.
|
|
242
242
|
if (value == null /* both `null` and `undefined` */)
|
|
243
243
|
return;
|
|
244
|
-
|
|
244
|
+
if (options?.strict) {
|
|
245
|
+
if (this.length > value.length) {
|
|
246
|
+
for (let index = this.length - 1; index >= value.length; index--) {
|
|
247
|
+
this.removeAt(index);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
245
251
|
value.forEach((newValue, index) => {
|
|
246
|
-
if (
|
|
247
|
-
this.
|
|
252
|
+
if (this.at(index)) {
|
|
253
|
+
this.at(index).patchValue(newValue, { ...(options ?? {}), onlySelf: true });
|
|
248
254
|
}
|
|
249
|
-
else {
|
|
250
|
-
|
|
251
|
-
this.at(index).patchValue(newValue, { ...(options ?? {}), onlySelf: true });
|
|
252
|
-
}
|
|
253
|
-
else if (options?.coerce) {
|
|
254
|
-
this.insertAt(index, value[index]);
|
|
255
|
-
}
|
|
255
|
+
else if (options?.coerce) {
|
|
256
|
+
this.insertAt(index, value[index]);
|
|
256
257
|
}
|
|
257
258
|
});
|
|
258
259
|
this.updateValueAndValidity(options);
|
|
@@ -1241,10 +1242,14 @@ class FormDirective extends FormGroupDirective {
|
|
|
1241
1242
|
}
|
|
1242
1243
|
}
|
|
1243
1244
|
ngOnInit() {
|
|
1244
|
-
if (!this.
|
|
1245
|
+
if (!this._formDefinition) {
|
|
1245
1246
|
// TODO : replace with rxap error
|
|
1246
1247
|
throw new Error('The form definition instance is not defined');
|
|
1247
1248
|
}
|
|
1249
|
+
if (!this.form) {
|
|
1250
|
+
// TODO : replace with rxap error
|
|
1251
|
+
throw new Error('The form instance is not defined');
|
|
1252
|
+
}
|
|
1248
1253
|
this.loadInitialState(this.form);
|
|
1249
1254
|
function HasNgOnInitMethod(obj) {
|
|
1250
1255
|
return obj && typeof obj.ngOnInit === 'function';
|
|
@@ -1256,8 +1261,14 @@ class FormDirective extends FormGroupDirective {
|
|
|
1256
1261
|
const debounce = typeof this._formDefinition.rxapMetadata.autoSubmit === 'number'
|
|
1257
1262
|
? this._formDefinition.rxapMetadata.autoSubmit
|
|
1258
1263
|
: 5000;
|
|
1259
|
-
this._autoSubmitSubscription = this
|
|
1260
|
-
.
|
|
1264
|
+
this._autoSubmitSubscription = this
|
|
1265
|
+
.form
|
|
1266
|
+
.valueChanges
|
|
1267
|
+
.pipe(debounceTime(debounce), filter(() => this.form.valid), tap((value) => {
|
|
1268
|
+
if (isDevMode()) {
|
|
1269
|
+
console.debug(`Auto submit form '${this._formDefinition.rxapMetadata.id}'`, value);
|
|
1270
|
+
}
|
|
1271
|
+
}), tap(() => this.submit()))
|
|
1261
1272
|
.subscribe();
|
|
1262
1273
|
}
|
|
1263
1274
|
}
|