valtech-components 2.0.394 → 2.0.396

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.
@@ -8249,9 +8249,16 @@ class FormComponent {
8249
8249
  this.onSelectChange = new EventEmitter();
8250
8250
  this.types = InputType;
8251
8251
  this.subscriptions = [];
8252
+ // Cache processed field properties
8253
+ this.processedSections = [];
8252
8254
  this.previousValues = new Map();
8253
8255
  }
8254
8256
  ngOnInit() {
8257
+ this.createForm();
8258
+ this.processAllSections();
8259
+ this.setupChangeTracking();
8260
+ }
8261
+ createForm() {
8255
8262
  const formControls = {};
8256
8263
  this.props.sections.forEach(section => {
8257
8264
  section.fields.forEach(field => {
@@ -8266,6 +8273,58 @@ class FormComponent {
8266
8273
  });
8267
8274
  });
8268
8275
  this.form = this.fb.group(formControls);
8276
+ }
8277
+ processAllSections() {
8278
+ console.log('[FormComponent] Processing all sections - ONE TIME ONLY');
8279
+ this.processedSections = this.props.sections.map(section => ({
8280
+ name: section.name,
8281
+ fields: section.fields.map(field => this.processField(field))
8282
+ }));
8283
+ }
8284
+ processField(field) {
8285
+ // Generate token if not provided
8286
+ if (!field.token) {
8287
+ field.token = `input-${field.type}-${field.name}`;
8288
+ }
8289
+ // Debug: verificar opciones para select fields - SOLO UNA VEZ
8290
+ if (field.type === this.types.SEARCH_SELECT || field.type === this.types.MULTI_SELECT || field.type === this.types.MULTI_SELECT_SIMPLE) {
8291
+ console.log(`[FormComponent] Processing field ${field.name} options:`, {
8292
+ type: field.type,
8293
+ optionsCount: field.options?.length || 0,
8294
+ options: field.options?.slice(0, 2) || []
8295
+ });
8296
+ }
8297
+ if (field.type === this.types.NUMBER_FROM_TO) {
8298
+ const fromControl = this.getControl(`${field.name}_from`);
8299
+ const toControl = this.getControl(`${field.name}_to`);
8300
+ if (field.state === ComponentStates.DISABLED) {
8301
+ fromControl.disable();
8302
+ toControl.disable();
8303
+ }
8304
+ else {
8305
+ fromControl.enable();
8306
+ toControl.enable();
8307
+ }
8308
+ // Modify original field object to maintain reactivity
8309
+ field.fromControl = fromControl;
8310
+ field.toControl = toControl;
8311
+ field.control = undefined; // Remove control for NUMBER_FROM_TO fields
8312
+ return field;
8313
+ }
8314
+ else {
8315
+ const control = this.getControl(field.name);
8316
+ if (field.state === ComponentStates.DISABLED) {
8317
+ control.disable();
8318
+ }
8319
+ else {
8320
+ control.enable();
8321
+ }
8322
+ // Modify original field object to maintain reactivity
8323
+ field.control = control;
8324
+ return field;
8325
+ }
8326
+ }
8327
+ setupChangeTracking() {
8269
8328
  this.props.sections.forEach(section => {
8270
8329
  section.fields
8271
8330
  .filter(x => x.type === this.types.SELECT || x.type === this.types.TEXT || x.type === this.types.SEARCH_SELECT || x.type === this.types.MULTI_SELECT || x.type === this.types.MULTI_SELECT_SIMPLE)
@@ -8311,50 +8370,13 @@ class FormComponent {
8311
8370
  getControl(field) {
8312
8371
  return this.Form.get(field);
8313
8372
  }
8373
+ /**
8374
+ * @deprecated This method is now only used internally.
8375
+ * Use processedSections property instead to avoid multiple calls.
8376
+ */
8314
8377
  getFieldProp(field) {
8315
- field.token;
8316
- if (!field.token) {
8317
- field.token = `input-${field.type}-${field.name}`;
8318
- }
8319
- // Debug: verificar opciones para select fields
8320
- if (field.type === this.types.SEARCH_SELECT || field.type === this.types.MULTI_SELECT || field.type === this.types.MULTI_SELECT_SIMPLE) {
8321
- console.log(`[FormComponent] ${field.name} options:`, {
8322
- type: field.type,
8323
- optionsCount: field.options?.length || 0,
8324
- options: field.options?.slice(0, 2) || []
8325
- });
8326
- }
8327
- if (field.type === this.types.NUMBER_FROM_TO) {
8328
- const fromControl = this.getControl(`${field.name}_from`);
8329
- const toControl = this.getControl(`${field.name}_to`);
8330
- if (field.state === ComponentStates.DISABLED) {
8331
- fromControl.disable();
8332
- toControl.disable();
8333
- }
8334
- else {
8335
- fromControl.enable();
8336
- toControl.enable();
8337
- }
8338
- return {
8339
- ...field,
8340
- fromControl,
8341
- toControl,
8342
- control: undefined, // Remove control for NUMBER_FROM_TO fields
8343
- };
8344
- }
8345
- else {
8346
- const control = this.getControl(field.name);
8347
- if (field.state === ComponentStates.DISABLED) {
8348
- control.disable();
8349
- }
8350
- else {
8351
- control.enable();
8352
- }
8353
- return {
8354
- ...field,
8355
- control,
8356
- };
8357
- }
8378
+ console.warn('[FormComponent] getFieldProp is deprecated and should not be called directly');
8379
+ return this.processField(field);
8358
8380
  }
8359
8381
  get isAtEndOfForm() {
8360
8382
  return isAtEnd(this.elementRef);
@@ -8411,59 +8433,59 @@ class FormComponent {
8411
8433
  size: 'large',
8412
8434
  }"
8413
8435
  ></val-display>
8414
- <div class="section" *ngFor="let s of props.sections">
8436
+ <div class="section" *ngFor="let s of processedSections">
8415
8437
  <val-title [props]="{ content: s.name, size: 'large', color: '', bold: false }"></val-title>
8416
8438
  <div class="input" *ngFor="let f of s.fields">
8417
8439
  <val-title [props]="{ content: f.label, size: 'small', color: 'dark', bold: false }"></val-title>
8418
8440
  <ng-container *ngIf="f.type === types.TEXT">
8419
- <val-text-input [props]="getFieldProp(f)"></val-text-input>
8441
+ <val-text-input [props]="f"></val-text-input>
8420
8442
  </ng-container>
8421
8443
  <ng-container *ngIf="f.type === types.CHECK">
8422
8444
  <val-check-input></val-check-input>
8423
8445
  </ng-container>
8424
8446
  <ng-container *ngIf="f.type === types.COMMENT">
8425
- <val-comment-input [props]="getFieldProp(f)"></val-comment-input>
8447
+ <val-comment-input [props]="f"></val-comment-input>
8426
8448
  </ng-container>
8427
8449
  <ng-container *ngIf="f.type === types.DATE">
8428
- <val-date-input [props]="getFieldProp(f)"></val-date-input>
8450
+ <val-date-input [props]="f"></val-date-input>
8429
8451
  </ng-container>
8430
8452
  <ng-container *ngIf="f.type === types.EMAIL">
8431
- <val-email-input [props]="getFieldProp(f)"></val-email-input>
8453
+ <val-email-input [props]="f"></val-email-input>
8432
8454
  </ng-container>
8433
8455
  <ng-container *ngIf="f.type === types.FILE">
8434
- <val-file-input [props]="getFieldProp(f)"></val-file-input>
8456
+ <val-file-input [props]="f"></val-file-input>
8435
8457
  </ng-container>
8436
8458
  <ng-container *ngIf="f.type === types.HOUR">
8437
- <val-hour-input [props]="getFieldProp(f)"></val-hour-input>
8459
+ <val-hour-input [props]="f"></val-hour-input>
8438
8460
  </ng-container>
8439
8461
  <ng-container *ngIf="f.type === types.NUMBER">
8440
- <val-number-input [props]="getFieldProp(f)"></val-number-input>
8462
+ <val-number-input [props]="f"></val-number-input>
8441
8463
  </ng-container>
8442
8464
  <ng-container *ngIf="f.type === types.NUMBER_FROM_TO">
8443
- <val-number-from-to [props]="getFieldProp(f)"></val-number-from-to>
8465
+ <val-number-from-to [props]="f"></val-number-from-to>
8444
8466
  </ng-container>
8445
8467
  <ng-container *ngIf="f.type === types.PASSWORD">
8446
- <val-password-input [props]="getFieldProp(f)"></val-password-input>
8468
+ <val-password-input [props]="f"></val-password-input>
8447
8469
  </ng-container>
8448
8470
  <ng-container *ngIf="f.type === types.PIN_CODE">
8449
- <val-pin-input [props]="getFieldProp(f)"></val-pin-input>
8471
+ <val-pin-input [props]="f"></val-pin-input>
8450
8472
  </ng-container>
8451
8473
  <ng-container *ngIf="f.type === types.RADIO">
8452
- <val-radio-input [props]="getFieldProp(f)"></val-radio-input>
8474
+ <val-radio-input [props]="f"></val-radio-input>
8453
8475
  </ng-container>
8454
8476
  <ng-container *ngIf="f.type === types.SELECT">
8455
- <val-select-input [props]="getFieldProp(f)"></val-select-input>
8477
+ <val-select-input [props]="f"></val-select-input>
8456
8478
  </ng-container>
8457
8479
  <ng-container *ngIf="f.type === types.SEARCH_SELECT">
8458
- <val-select-search [props]="getFieldProp(f)"></val-select-search>
8480
+ <val-select-search [props]="f"></val-select-search>
8459
8481
  </ng-container>
8460
8482
  <ng-container *ngIf="f.type === types.MULTI_SELECT">
8461
- <val-multi-select-search [props]="getFieldProp(f)"></val-multi-select-search>
8483
+ <val-multi-select-search [props]="f"></val-multi-select-search>
8462
8484
  </ng-container>
8463
8485
  <ng-container *ngIf="f.type === types.MULTI_SELECT_SIMPLE">
8464
- <val-multi-select-simple [props]="getFieldProp(f)"></val-multi-select-simple>
8486
+ <val-multi-select-simple [props]="f"></val-multi-select-simple>
8465
8487
  </ng-container>
8466
- <val-hint [props]="getFieldProp(f)"></val-hint>
8488
+ <val-hint [props]="f"></val-hint>
8467
8489
  </div>
8468
8490
  <val-divider [props]="{ fill: 'solid', size: 'medium', color: 'medium' }"></val-divider>
8469
8491
  <ng-content></ng-content>
@@ -8513,59 +8535,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
8513
8535
  size: 'large',
8514
8536
  }"
8515
8537
  ></val-display>
8516
- <div class="section" *ngFor="let s of props.sections">
8538
+ <div class="section" *ngFor="let s of processedSections">
8517
8539
  <val-title [props]="{ content: s.name, size: 'large', color: '', bold: false }"></val-title>
8518
8540
  <div class="input" *ngFor="let f of s.fields">
8519
8541
  <val-title [props]="{ content: f.label, size: 'small', color: 'dark', bold: false }"></val-title>
8520
8542
  <ng-container *ngIf="f.type === types.TEXT">
8521
- <val-text-input [props]="getFieldProp(f)"></val-text-input>
8543
+ <val-text-input [props]="f"></val-text-input>
8522
8544
  </ng-container>
8523
8545
  <ng-container *ngIf="f.type === types.CHECK">
8524
8546
  <val-check-input></val-check-input>
8525
8547
  </ng-container>
8526
8548
  <ng-container *ngIf="f.type === types.COMMENT">
8527
- <val-comment-input [props]="getFieldProp(f)"></val-comment-input>
8549
+ <val-comment-input [props]="f"></val-comment-input>
8528
8550
  </ng-container>
8529
8551
  <ng-container *ngIf="f.type === types.DATE">
8530
- <val-date-input [props]="getFieldProp(f)"></val-date-input>
8552
+ <val-date-input [props]="f"></val-date-input>
8531
8553
  </ng-container>
8532
8554
  <ng-container *ngIf="f.type === types.EMAIL">
8533
- <val-email-input [props]="getFieldProp(f)"></val-email-input>
8555
+ <val-email-input [props]="f"></val-email-input>
8534
8556
  </ng-container>
8535
8557
  <ng-container *ngIf="f.type === types.FILE">
8536
- <val-file-input [props]="getFieldProp(f)"></val-file-input>
8558
+ <val-file-input [props]="f"></val-file-input>
8537
8559
  </ng-container>
8538
8560
  <ng-container *ngIf="f.type === types.HOUR">
8539
- <val-hour-input [props]="getFieldProp(f)"></val-hour-input>
8561
+ <val-hour-input [props]="f"></val-hour-input>
8540
8562
  </ng-container>
8541
8563
  <ng-container *ngIf="f.type === types.NUMBER">
8542
- <val-number-input [props]="getFieldProp(f)"></val-number-input>
8564
+ <val-number-input [props]="f"></val-number-input>
8543
8565
  </ng-container>
8544
8566
  <ng-container *ngIf="f.type === types.NUMBER_FROM_TO">
8545
- <val-number-from-to [props]="getFieldProp(f)"></val-number-from-to>
8567
+ <val-number-from-to [props]="f"></val-number-from-to>
8546
8568
  </ng-container>
8547
8569
  <ng-container *ngIf="f.type === types.PASSWORD">
8548
- <val-password-input [props]="getFieldProp(f)"></val-password-input>
8570
+ <val-password-input [props]="f"></val-password-input>
8549
8571
  </ng-container>
8550
8572
  <ng-container *ngIf="f.type === types.PIN_CODE">
8551
- <val-pin-input [props]="getFieldProp(f)"></val-pin-input>
8573
+ <val-pin-input [props]="f"></val-pin-input>
8552
8574
  </ng-container>
8553
8575
  <ng-container *ngIf="f.type === types.RADIO">
8554
- <val-radio-input [props]="getFieldProp(f)"></val-radio-input>
8576
+ <val-radio-input [props]="f"></val-radio-input>
8555
8577
  </ng-container>
8556
8578
  <ng-container *ngIf="f.type === types.SELECT">
8557
- <val-select-input [props]="getFieldProp(f)"></val-select-input>
8579
+ <val-select-input [props]="f"></val-select-input>
8558
8580
  </ng-container>
8559
8581
  <ng-container *ngIf="f.type === types.SEARCH_SELECT">
8560
- <val-select-search [props]="getFieldProp(f)"></val-select-search>
8582
+ <val-select-search [props]="f"></val-select-search>
8561
8583
  </ng-container>
8562
8584
  <ng-container *ngIf="f.type === types.MULTI_SELECT">
8563
- <val-multi-select-search [props]="getFieldProp(f)"></val-multi-select-search>
8585
+ <val-multi-select-search [props]="f"></val-multi-select-search>
8564
8586
  </ng-container>
8565
8587
  <ng-container *ngIf="f.type === types.MULTI_SELECT_SIMPLE">
8566
- <val-multi-select-simple [props]="getFieldProp(f)"></val-multi-select-simple>
8588
+ <val-multi-select-simple [props]="f"></val-multi-select-simple>
8567
8589
  </ng-container>
8568
- <val-hint [props]="getFieldProp(f)"></val-hint>
8590
+ <val-hint [props]="f"></val-hint>
8569
8591
  </div>
8570
8592
  <val-divider [props]="{ fill: 'solid', size: 'medium', color: 'medium' }"></val-divider>
8571
8593
  <ng-content></ng-content>