valtech-components 4.0.1017 → 4.0.1019

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.
@@ -70,7 +70,7 @@ import fixWebmDuration from 'fix-webm-duration';
70
70
  * Current version of valtech-components.
71
71
  * This is automatically updated during the publish process.
72
72
  */
73
- const VERSION = '4.0.1017';
73
+ const VERSION = '4.0.1019';
74
74
 
75
75
  function evaluateValtechAccess(rule, context, features = {}, visitedFeatures = new Set()) {
76
76
  if (rule == null)
@@ -37643,28 +37643,26 @@ class FormComponent {
37643
37643
  const formControls = {};
37644
37644
  this.props.sections.forEach(section => {
37645
37645
  section.fields.forEach(field => {
37646
- // Honra `field.value` al construir el FormGroup para que controles tipo
37647
- // HANDLE (que consumen el control directo via [formControl]) reciban el
37648
- // valor inicial sin que el caller tenga que patchValue post-mount.
37649
- // El helper applyDefaultValueToControl (val-text-input etc.) sigue
37650
- // funcionando — escribe sobre un control ya inicializado, idempotente.
37651
- const initialValue = field.value ??
37652
- (field.type === this.types.MULTI_SELECT_SIMPLE ? [] : field.type === this.types.TOGGLE ? false : null);
37653
37646
  if (field.type === this.types.NUMBER_FROM_TO) {
37654
37647
  // Crear dos controles para campos NUMBER_FROM_TO
37655
- formControls[`${field.name}_from`] = [initialValue, field.validators || []];
37656
- formControls[`${field.name}_to`] = [initialValue, field.validators || []];
37648
+ formControls[`${field.name}_from`] = [this.initialValueForField(field), field.validators || []];
37649
+ formControls[`${field.name}_to`] = [this.initialValueForField(field), field.validators || []];
37657
37650
  }
37658
37651
  else if (field.type === this.types.ATTACHMENT) {
37659
37652
  formControls[field.name] = [[], field.validators || []];
37660
37653
  }
37661
37654
  else {
37662
- formControls[field.name] = [initialValue, field.validators || []];
37655
+ formControls[field.name] = [this.initialValueForField(field), field.validators || []];
37663
37656
  }
37664
37657
  });
37665
37658
  });
37666
37659
  return formControls;
37667
37660
  }
37661
+ initialValueForField(field) {
37662
+ // Honra `field.value` para que controles que consumen FormControl directo
37663
+ // reciban valor inicial aunque el caller no haga patchValue post-mount.
37664
+ return field.value ?? (field.type === this.types.MULTI_SELECT_SIMPLE ? [] : field.type === this.types.TOGGLE ? false : null);
37665
+ }
37668
37666
  /**
37669
37667
  * Reconstruye el `FormGroup` desde cero, con los valores iniciales de `props`
37670
37668
  * actuales (no los que el usuario haya tecleado desde entonces).
@@ -37786,6 +37784,8 @@ class FormComponent {
37786
37784
  }
37787
37785
  });
37788
37786
  });
37787
+ this.value.set(this.form.getRawValue());
37788
+ this.valid.set(this.form.valid);
37789
37789
  }
37790
37790
  /**
37791
37791
  * Actualiza el cache de actions basado en el estado actual del form.
@@ -37844,7 +37844,28 @@ class FormComponent {
37844
37844
  }
37845
37845
  }
37846
37846
  getControl(field) {
37847
- return this.Form.get(field);
37847
+ return this.ensureControl(field);
37848
+ }
37849
+ ensureControl(fieldName) {
37850
+ let control = this.Form.get(fieldName);
37851
+ if (!control) {
37852
+ const field = this.findFieldForControl(fieldName);
37853
+ control = this.fb.control(field ? this.initialValueForField(field) : null, field?.validators || []);
37854
+ this.Form.addControl(fieldName, control);
37855
+ }
37856
+ return control;
37857
+ }
37858
+ findFieldForControl(fieldName) {
37859
+ for (const section of this.props.sections) {
37860
+ for (const field of section.fields) {
37861
+ if (field.name === fieldName)
37862
+ return field;
37863
+ if (field.type === this.types.NUMBER_FROM_TO && (`${field.name}_from` === fieldName || `${field.name}_to` === fieldName)) {
37864
+ return field;
37865
+ }
37866
+ }
37867
+ }
37868
+ return undefined;
37848
37869
  }
37849
37870
  /**
37850
37871
  * Ids estables (label + error) para un field. Memoizados por referencia para
@@ -42049,6 +42070,19 @@ class SurveyBuilderComponent {
42049
42070
  withResolvedSection(field) {
42050
42071
  const label = (field.sectionLabel ?? '').trim();
42051
42072
  const id = this.normalizeSectionId(field.sectionId);
42073
+ if (this.isWizard()) {
42074
+ const sectionLabel = label || this.sectionNameControl(id).value.trim() || this.sectionNames()[id] || '';
42075
+ const sectionSubtitle = (field.sectionSubtitle ?? '').trim() ||
42076
+ this.sectionSubtitleControl(id).value.trim() ||
42077
+ this.sectionSubtitles()[id] ||
42078
+ '';
42079
+ return {
42080
+ ...field,
42081
+ sectionId: id,
42082
+ sectionLabel: sectionLabel || undefined,
42083
+ sectionSubtitle: sectionSubtitle || undefined,
42084
+ };
42085
+ }
42052
42086
  if (!this.isWizard() && id === '__default__' && label) {
42053
42087
  return { ...field, sectionId: this.formBuilder.toToken(label), sectionLabel: label };
42054
42088
  }