valtech-components 2.0.394 → 2.0.395

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,60 @@ 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
+ return {
8309
+ ...field,
8310
+ fromControl,
8311
+ toControl,
8312
+ control: undefined, // Remove control for NUMBER_FROM_TO fields
8313
+ };
8314
+ }
8315
+ else {
8316
+ const control = this.getControl(field.name);
8317
+ if (field.state === ComponentStates.DISABLED) {
8318
+ control.disable();
8319
+ }
8320
+ else {
8321
+ control.enable();
8322
+ }
8323
+ return {
8324
+ ...field,
8325
+ control,
8326
+ };
8327
+ }
8328
+ }
8329
+ setupChangeTracking() {
8269
8330
  this.props.sections.forEach(section => {
8270
8331
  section.fields
8271
8332
  .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 +8372,13 @@ class FormComponent {
8311
8372
  getControl(field) {
8312
8373
  return this.Form.get(field);
8313
8374
  }
8375
+ /**
8376
+ * @deprecated This method is now only used internally.
8377
+ * Use processedSections property instead to avoid multiple calls.
8378
+ */
8314
8379
  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
- }
8380
+ console.warn('[FormComponent] getFieldProp is deprecated and should not be called directly');
8381
+ return this.processField(field);
8358
8382
  }
8359
8383
  get isAtEndOfForm() {
8360
8384
  return isAtEnd(this.elementRef);
@@ -8411,59 +8435,59 @@ class FormComponent {
8411
8435
  size: 'large',
8412
8436
  }"
8413
8437
  ></val-display>
8414
- <div class="section" *ngFor="let s of props.sections">
8438
+ <div class="section" *ngFor="let s of processedSections">
8415
8439
  <val-title [props]="{ content: s.name, size: 'large', color: '', bold: false }"></val-title>
8416
8440
  <div class="input" *ngFor="let f of s.fields">
8417
8441
  <val-title [props]="{ content: f.label, size: 'small', color: 'dark', bold: false }"></val-title>
8418
8442
  <ng-container *ngIf="f.type === types.TEXT">
8419
- <val-text-input [props]="getFieldProp(f)"></val-text-input>
8443
+ <val-text-input [props]="f"></val-text-input>
8420
8444
  </ng-container>
8421
8445
  <ng-container *ngIf="f.type === types.CHECK">
8422
8446
  <val-check-input></val-check-input>
8423
8447
  </ng-container>
8424
8448
  <ng-container *ngIf="f.type === types.COMMENT">
8425
- <val-comment-input [props]="getFieldProp(f)"></val-comment-input>
8449
+ <val-comment-input [props]="f"></val-comment-input>
8426
8450
  </ng-container>
8427
8451
  <ng-container *ngIf="f.type === types.DATE">
8428
- <val-date-input [props]="getFieldProp(f)"></val-date-input>
8452
+ <val-date-input [props]="f"></val-date-input>
8429
8453
  </ng-container>
8430
8454
  <ng-container *ngIf="f.type === types.EMAIL">
8431
- <val-email-input [props]="getFieldProp(f)"></val-email-input>
8455
+ <val-email-input [props]="f"></val-email-input>
8432
8456
  </ng-container>
8433
8457
  <ng-container *ngIf="f.type === types.FILE">
8434
- <val-file-input [props]="getFieldProp(f)"></val-file-input>
8458
+ <val-file-input [props]="f"></val-file-input>
8435
8459
  </ng-container>
8436
8460
  <ng-container *ngIf="f.type === types.HOUR">
8437
- <val-hour-input [props]="getFieldProp(f)"></val-hour-input>
8461
+ <val-hour-input [props]="f"></val-hour-input>
8438
8462
  </ng-container>
8439
8463
  <ng-container *ngIf="f.type === types.NUMBER">
8440
- <val-number-input [props]="getFieldProp(f)"></val-number-input>
8464
+ <val-number-input [props]="f"></val-number-input>
8441
8465
  </ng-container>
8442
8466
  <ng-container *ngIf="f.type === types.NUMBER_FROM_TO">
8443
- <val-number-from-to [props]="getFieldProp(f)"></val-number-from-to>
8467
+ <val-number-from-to [props]="f"></val-number-from-to>
8444
8468
  </ng-container>
8445
8469
  <ng-container *ngIf="f.type === types.PASSWORD">
8446
- <val-password-input [props]="getFieldProp(f)"></val-password-input>
8470
+ <val-password-input [props]="f"></val-password-input>
8447
8471
  </ng-container>
8448
8472
  <ng-container *ngIf="f.type === types.PIN_CODE">
8449
- <val-pin-input [props]="getFieldProp(f)"></val-pin-input>
8473
+ <val-pin-input [props]="f"></val-pin-input>
8450
8474
  </ng-container>
8451
8475
  <ng-container *ngIf="f.type === types.RADIO">
8452
- <val-radio-input [props]="getFieldProp(f)"></val-radio-input>
8476
+ <val-radio-input [props]="f"></val-radio-input>
8453
8477
  </ng-container>
8454
8478
  <ng-container *ngIf="f.type === types.SELECT">
8455
- <val-select-input [props]="getFieldProp(f)"></val-select-input>
8479
+ <val-select-input [props]="f"></val-select-input>
8456
8480
  </ng-container>
8457
8481
  <ng-container *ngIf="f.type === types.SEARCH_SELECT">
8458
- <val-select-search [props]="getFieldProp(f)"></val-select-search>
8482
+ <val-select-search [props]="f"></val-select-search>
8459
8483
  </ng-container>
8460
8484
  <ng-container *ngIf="f.type === types.MULTI_SELECT">
8461
- <val-multi-select-search [props]="getFieldProp(f)"></val-multi-select-search>
8485
+ <val-multi-select-search [props]="f"></val-multi-select-search>
8462
8486
  </ng-container>
8463
8487
  <ng-container *ngIf="f.type === types.MULTI_SELECT_SIMPLE">
8464
- <val-multi-select-simple [props]="getFieldProp(f)"></val-multi-select-simple>
8488
+ <val-multi-select-simple [props]="f"></val-multi-select-simple>
8465
8489
  </ng-container>
8466
- <val-hint [props]="getFieldProp(f)"></val-hint>
8490
+ <val-hint [props]="f"></val-hint>
8467
8491
  </div>
8468
8492
  <val-divider [props]="{ fill: 'solid', size: 'medium', color: 'medium' }"></val-divider>
8469
8493
  <ng-content></ng-content>
@@ -8513,59 +8537,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
8513
8537
  size: 'large',
8514
8538
  }"
8515
8539
  ></val-display>
8516
- <div class="section" *ngFor="let s of props.sections">
8540
+ <div class="section" *ngFor="let s of processedSections">
8517
8541
  <val-title [props]="{ content: s.name, size: 'large', color: '', bold: false }"></val-title>
8518
8542
  <div class="input" *ngFor="let f of s.fields">
8519
8543
  <val-title [props]="{ content: f.label, size: 'small', color: 'dark', bold: false }"></val-title>
8520
8544
  <ng-container *ngIf="f.type === types.TEXT">
8521
- <val-text-input [props]="getFieldProp(f)"></val-text-input>
8545
+ <val-text-input [props]="f"></val-text-input>
8522
8546
  </ng-container>
8523
8547
  <ng-container *ngIf="f.type === types.CHECK">
8524
8548
  <val-check-input></val-check-input>
8525
8549
  </ng-container>
8526
8550
  <ng-container *ngIf="f.type === types.COMMENT">
8527
- <val-comment-input [props]="getFieldProp(f)"></val-comment-input>
8551
+ <val-comment-input [props]="f"></val-comment-input>
8528
8552
  </ng-container>
8529
8553
  <ng-container *ngIf="f.type === types.DATE">
8530
- <val-date-input [props]="getFieldProp(f)"></val-date-input>
8554
+ <val-date-input [props]="f"></val-date-input>
8531
8555
  </ng-container>
8532
8556
  <ng-container *ngIf="f.type === types.EMAIL">
8533
- <val-email-input [props]="getFieldProp(f)"></val-email-input>
8557
+ <val-email-input [props]="f"></val-email-input>
8534
8558
  </ng-container>
8535
8559
  <ng-container *ngIf="f.type === types.FILE">
8536
- <val-file-input [props]="getFieldProp(f)"></val-file-input>
8560
+ <val-file-input [props]="f"></val-file-input>
8537
8561
  </ng-container>
8538
8562
  <ng-container *ngIf="f.type === types.HOUR">
8539
- <val-hour-input [props]="getFieldProp(f)"></val-hour-input>
8563
+ <val-hour-input [props]="f"></val-hour-input>
8540
8564
  </ng-container>
8541
8565
  <ng-container *ngIf="f.type === types.NUMBER">
8542
- <val-number-input [props]="getFieldProp(f)"></val-number-input>
8566
+ <val-number-input [props]="f"></val-number-input>
8543
8567
  </ng-container>
8544
8568
  <ng-container *ngIf="f.type === types.NUMBER_FROM_TO">
8545
- <val-number-from-to [props]="getFieldProp(f)"></val-number-from-to>
8569
+ <val-number-from-to [props]="f"></val-number-from-to>
8546
8570
  </ng-container>
8547
8571
  <ng-container *ngIf="f.type === types.PASSWORD">
8548
- <val-password-input [props]="getFieldProp(f)"></val-password-input>
8572
+ <val-password-input [props]="f"></val-password-input>
8549
8573
  </ng-container>
8550
8574
  <ng-container *ngIf="f.type === types.PIN_CODE">
8551
- <val-pin-input [props]="getFieldProp(f)"></val-pin-input>
8575
+ <val-pin-input [props]="f"></val-pin-input>
8552
8576
  </ng-container>
8553
8577
  <ng-container *ngIf="f.type === types.RADIO">
8554
- <val-radio-input [props]="getFieldProp(f)"></val-radio-input>
8578
+ <val-radio-input [props]="f"></val-radio-input>
8555
8579
  </ng-container>
8556
8580
  <ng-container *ngIf="f.type === types.SELECT">
8557
- <val-select-input [props]="getFieldProp(f)"></val-select-input>
8581
+ <val-select-input [props]="f"></val-select-input>
8558
8582
  </ng-container>
8559
8583
  <ng-container *ngIf="f.type === types.SEARCH_SELECT">
8560
- <val-select-search [props]="getFieldProp(f)"></val-select-search>
8584
+ <val-select-search [props]="f"></val-select-search>
8561
8585
  </ng-container>
8562
8586
  <ng-container *ngIf="f.type === types.MULTI_SELECT">
8563
- <val-multi-select-search [props]="getFieldProp(f)"></val-multi-select-search>
8587
+ <val-multi-select-search [props]="f"></val-multi-select-search>
8564
8588
  </ng-container>
8565
8589
  <ng-container *ngIf="f.type === types.MULTI_SELECT_SIMPLE">
8566
- <val-multi-select-simple [props]="getFieldProp(f)"></val-multi-select-simple>
8590
+ <val-multi-select-simple [props]="f"></val-multi-select-simple>
8567
8591
  </ng-container>
8568
- <val-hint [props]="getFieldProp(f)"></val-hint>
8592
+ <val-hint [props]="f"></val-hint>
8569
8593
  </div>
8570
8594
  <val-divider [props]="{ fill: 'solid', size: 'medium', color: 'medium' }"></val-divider>
8571
8595
  <ng-content></ng-content>