@praxisui/dynamic-form 9.0.0-beta.76 → 9.0.0-beta.78

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.
@@ -14740,6 +14740,7 @@ class PraxisDynamicForm {
14740
14740
  if (this.entityHydrationPending) {
14741
14741
  return;
14742
14742
  }
14743
+ this.clearSubmitFieldErrors();
14743
14744
  // Hooks: beforeValidate
14744
14745
  try {
14745
14746
  await this.runHooks('beforeValidate');
@@ -14911,6 +14912,8 @@ class PraxisDynamicForm {
14911
14912
  catch { }
14912
14913
  // Mensagens de erro configuráveis
14913
14914
  try {
14915
+ const normalizedError = this.errorMessages.normalizeSubmitError(error);
14916
+ this.applySubmitFieldErrors(normalizedError.details);
14914
14917
  const msgs = this.config.messages;
14915
14918
  let errorMsg = msgs?.customActions?.submit?.error;
14916
14919
  if (!errorMsg) {
@@ -14920,7 +14923,7 @@ class PraxisDynamicForm {
14920
14923
  : msgs?.updateRegistryError;
14921
14924
  }
14922
14925
  if (!errorMsg) {
14923
- errorMsg = this.errorMessages.getSubmitErrorMessage(error);
14926
+ errorMsg = normalizedError.message;
14924
14927
  }
14925
14928
  this.submitError = errorMsg;
14926
14929
  this.snackBar.open(errorMsg, undefined, {
@@ -14932,6 +14935,55 @@ class PraxisDynamicForm {
14932
14935
  },
14933
14936
  });
14934
14937
  }
14938
+ applySubmitFieldErrors(details) {
14939
+ for (const detail of details) {
14940
+ const target = this.normalizeSubmitErrorTarget(detail.target);
14941
+ if (!target)
14942
+ continue;
14943
+ const control = this.form.get(target);
14944
+ if (!control)
14945
+ continue;
14946
+ if (control.errors?.['server'])
14947
+ continue;
14948
+ control.setErrors({
14949
+ ...(control.errors || {}),
14950
+ server: { code: detail.code, message: detail.message },
14951
+ });
14952
+ control.markAsTouched();
14953
+ }
14954
+ }
14955
+ clearSubmitFieldErrors() {
14956
+ const visit = (control) => {
14957
+ const currentErrors = control.errors;
14958
+ if (currentErrors?.['server']) {
14959
+ const nextErrors = { ...currentErrors };
14960
+ delete nextErrors['server'];
14961
+ control.setErrors(Object.keys(nextErrors).length ? nextErrors : null);
14962
+ }
14963
+ const children = control.controls;
14964
+ if (Array.isArray(children)) {
14965
+ children.forEach(visit);
14966
+ }
14967
+ else if (children && typeof children === 'object') {
14968
+ Object.values(children).forEach((child) => visit(child));
14969
+ }
14970
+ };
14971
+ visit(this.form);
14972
+ }
14973
+ normalizeSubmitErrorTarget(target) {
14974
+ const normalized = String(target || '').trim();
14975
+ if (!normalized)
14976
+ return null;
14977
+ if (normalized.startsWith('/')) {
14978
+ return normalized
14979
+ .split('/')
14980
+ .slice(1)
14981
+ .map((segment) => segment.replace(/~1/g, '/').replace(/~0/g, '~'))
14982
+ .filter(Boolean)
14983
+ .join('.');
14984
+ }
14985
+ return normalized;
14986
+ }
14935
14987
  navigateAfterSave(redirectAfterSave) {
14936
14988
  if (!this.router || typeof this.router.navigateByUrl !== 'function') {
14937
14989
  this.warnOnceLog('[PraxisDynamicForm] redirectAfterSave ignored because Router is unavailable.', { redirectAfterSave }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praxisui/dynamic-form",
3
- "version": "9.0.0-beta.76",
3
+ "version": "9.0.0-beta.78",
4
4
  "description": "Angular dynamic form engine for Praxis UI: metadata-driven forms, hooks, and services integrating @praxisui/* packages.",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^21.0.0",
@@ -9,13 +9,13 @@
9
9
  "@angular/forms": "^21.0.0",
10
10
  "@angular/material": "^21.0.0",
11
11
  "@angular/router": "^21.0.0",
12
- "@praxisui/ai": "^9.0.0-beta.76",
13
- "@praxisui/dynamic-fields": "^9.0.0-beta.76",
14
- "@praxisui/metadata-editor": "^9.0.0-beta.76",
15
- "@praxisui/rich-content": "^9.0.0-beta.76",
16
- "@praxisui/settings-panel": "^9.0.0-beta.76",
17
- "@praxisui/visual-builder": "^9.0.0-beta.76",
18
- "@praxisui/core": "^9.0.0-beta.76",
12
+ "@praxisui/ai": "^9.0.0-beta.78",
13
+ "@praxisui/dynamic-fields": "^9.0.0-beta.78",
14
+ "@praxisui/metadata-editor": "^9.0.0-beta.78",
15
+ "@praxisui/rich-content": "^9.0.0-beta.78",
16
+ "@praxisui/settings-panel": "^9.0.0-beta.78",
17
+ "@praxisui/visual-builder": "^9.0.0-beta.78",
18
+ "@praxisui/core": "^9.0.0-beta.78",
19
19
  "rxjs": "^7.8.0"
20
20
  },
21
21
  "dependencies": {
@@ -1180,6 +1180,9 @@ declare class PraxisDynamicForm implements OnInit, OnChanges, OnDestroy {
1180
1180
  private _executeAction;
1181
1181
  private getFormActionEventId;
1182
1182
  onSubmit(): Promise<void>;
1183
+ private applySubmitFieldErrors;
1184
+ private clearSubmitFieldErrors;
1185
+ private normalizeSubmitErrorTarget;
1183
1186
  private navigateAfterSave;
1184
1187
  private shouldConfirmCancelOnDirty;
1185
1188
  /**