@ziadshalaby/ngx-zs-component 3.1.1 → 3.1.2

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.
@@ -1264,12 +1264,14 @@ class Form {
1264
1264
  // ==============================================
1265
1265
  // Form State & Validation
1266
1266
  // ==============================================
1267
- allFilled = computed(() => {
1268
- return Object.values(this.fields).every(f => {
1269
- const v = f();
1270
- return v.value !== null && v.value !== '' && v.valid === true;
1267
+ allFilled(allowEmptyFields = []) {
1268
+ return Object.keys(this.fields).every((key) => {
1269
+ if (allowEmptyFields.includes(key))
1270
+ return true;
1271
+ const val = this.fields[key]()?.value;
1272
+ return val !== null && val !== undefined && val !== '';
1271
1273
  });
1272
- }, ...(ngDevMode ? [{ debugName: "allFilled" }] : []));
1274
+ }
1273
1275
  markAllTouched() {
1274
1276
  this.touched.set(true);
1275
1277
  }
@@ -1294,12 +1296,11 @@ class Form {
1294
1296
  }
1295
1297
  return result;
1296
1298
  }
1297
- submit(callback, submitWhenAllNotFilled = false) {
1299
+ submit(callback, allowEmptyFields = []) {
1298
1300
  this.markAllTouched();
1299
- const allFilled = this.allFilled();
1300
- const validations = this.getValidations();
1301
- const allValid = Object.values(validations).every(Boolean);
1302
- if ((!submitWhenAllNotFilled && !allFilled) || !allValid)
1301
+ const allValid = Object.values(this.getValidations()).every(Boolean);
1302
+ const allFilled = this.allFilled(allowEmptyFields);
1303
+ if (!allFilled || !allValid)
1303
1304
  return;
1304
1305
  callback(this.getValues());
1305
1306
  }