@fuentis/phoenix-ui 0.0.9-alpha.525 → 0.0.9-alpha.527

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.
@@ -3903,11 +3903,8 @@ class MetaFormAbstract {
3903
3903
  if (changes['metaFormControls'] ||
3904
3904
  changes['metaFormValues'] ||
3905
3905
  changes['disableForm']) {
3906
- if (!this.metaForm) {
3907
- // Fallback: if caller forgets to pass metaForm, create one.
3908
- this.metaForm = this.fb.group({});
3909
- this.rewireFormSubscription();
3910
- }
3906
+ if (!this.metaForm)
3907
+ return;
3911
3908
  this.syncForm();
3912
3909
  }
3913
3910
  }
@@ -3919,8 +3916,7 @@ class MetaFormAbstract {
3919
3916
  if (controls)
3920
3917
  this.metaFormControls = controls;
3921
3918
  if (!this.metaForm) {
3922
- this.metaForm = this.fb.group({});
3923
- this.rewireFormSubscription();
3919
+ throw new Error('[MetaFormAbstract] metaForm input is required. Parent must pass [metaForm].');
3924
3920
  }
3925
3921
  this.syncForm();
3926
3922
  }
@@ -3933,23 +3929,26 @@ class MetaFormAbstract {
3933
3929
  * - binds dependencies (safe rebind)
3934
3930
  * - recomputes validity
3935
3931
  */
3932
+ // MetaFormAbstract (samo bitne izmene – kompletno je kompatibilno sa tvojim kodom)
3936
3933
  syncForm() {
3937
3934
  const flatControls = this.flattenControls(this.metaFormControls);
3938
3935
  const values = this.metaFormValues ?? null;
3939
- // 1) Ensure form controls exist + validators are applied
3936
+ // 1) Ensure controls + apply validators
3940
3937
  this.ensureControls(flatControls);
3941
3938
  // 2) Patch initial values WITHOUT firing valueChanges
3942
3939
  if (values) {
3943
3940
  this.metaForm.patchValue(values, { emitEvent: false });
3944
3941
  }
3945
- // 3) Enable/disable entire form if requested
3942
+ // 3) Enable/disable entire form without emitting
3946
3943
  if (this.disableForm)
3947
3944
  this.metaForm.disable({ emitEvent: false });
3948
3945
  else
3949
3946
  this.metaForm.enable({ emitEvent: false });
3950
- // 4) Bind dependencies if needed (rebind when metadata changes)
3947
+ // 4) Bind dependencies (safe rebind)
3951
3948
  this.bindDependenciesIfNeeded(flatControls);
3952
- // 5) Notify that the form is ready
3949
+ // 5) Compute validity NOW (sync) but DO NOT emit (critical!)
3950
+ this.metaForm.updateValueAndValidity({ emitEvent: false });
3951
+ // 6) Notify that build is complete (signal to parent)
3953
3952
  this.metaService.setFormBuildCompletition(true);
3954
3953
  }
3955
3954
  /**
@@ -4060,11 +4059,10 @@ class MetaFormAbstract {
4060
4059
  if (!hasServerUnique)
4061
4060
  return;
4062
4061
  const { uniqueEntry, unique, ...rest } = errors;
4063
- ctrl.setErrors(Object.keys(rest).length ? rest : null, {
4064
- emitEvent: false,
4065
- });
4066
- // Recompute the parent form validity so UI can enable Save immediately.
4067
- this.metaForm.updateValueAndValidity({ emitEvent: false });
4062
+ // Clear only server errors, keep other validators
4063
+ ctrl.setErrors(Object.keys(rest).length ? rest : null, { emitEvent: false });
4064
+ // IMPORTANT: after changing errors, re-run validity WITH EMIT
4065
+ this.metaForm.updateValueAndValidity({ emitEvent: true });
4068
4066
  });
4069
4067
  this.clearServerErrorSubs.set(key, sub);
4070
4068
  }