ngx-sp-infra 6.5.12 → 6.5.13

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.
@@ -6422,11 +6422,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
6422
6422
  }] } });
6423
6423
 
6424
6424
  class LibComboboxReworkComponent {
6425
+ set list(value) {
6426
+ this._list = value;
6427
+ // Re-resolve the current value when the list changes
6428
+ if (this._value) {
6429
+ this.writeValue(this._value);
6430
+ }
6431
+ }
6432
+ get list() {
6433
+ return this._list;
6434
+ }
6425
6435
  // Getter/Setter para o valor
6426
6436
  get value() { return this._value; }
6427
6437
  set value(val) {
6428
- if (val !== this._value) {
6429
- this._value = val;
6438
+ const previousValue = this._value;
6439
+ this._value = val;
6440
+ if (val !== previousValue) {
6430
6441
  this._onChange(this.formatReturn(val)); // Notifica o FormControl sobre a mudança
6431
6442
  }
6432
6443
  }
@@ -6465,7 +6476,7 @@ class LibComboboxReworkComponent {
6465
6476
  this._destroy$ = new Subject();
6466
6477
  // #endregion PRIVATE
6467
6478
  // #region PUBLIC
6468
- this.list = [];
6479
+ this._list = [];
6469
6480
  this.placeholder = "Selecione uma opção...";
6470
6481
  this.searchPlaceholder = "Pesquisa...";
6471
6482
  this.noResultsText = "Nenhum registro encontrado com esta pesquisa...";
@@ -6582,6 +6593,10 @@ class LibComboboxReworkComponent {
6582
6593
  if (typeof val === 'object' && val !== null && val[this.customValue] !== undefined) {
6583
6594
  return val;
6584
6595
  }
6596
+ // Se a lista não tiver sido carregada ainda ou for vazia e houver um valor pré-definido retorna o mesmo
6597
+ if ((!this.list || this.list.length === 0) && val) {
6598
+ return val;
6599
+ }
6585
6600
  // Se é um valor primitivo, tenta encontrar na lista
6586
6601
  const match = this.list?.find((item) => item[this.customValue] === val);
6587
6602
  return match ?? null;