ngx-sp-infra 6.0.7 → 6.0.8

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.
@@ -6391,7 +6391,7 @@ class LibComboboxReworkComponent {
6391
6391
  set value(val) {
6392
6392
  if (val !== this._value) {
6393
6393
  this._value = val;
6394
- this._onChange(val); // Notifica o FormControl sobre a mudança
6394
+ this._onChange(this.formatReturn(val)); // Notifica o FormControl sobre a mudança
6395
6395
  }
6396
6396
  }
6397
6397
  displayValue() {
@@ -6519,12 +6519,10 @@ class LibComboboxReworkComponent {
6519
6519
  if (this.selectedValues.length === 0)
6520
6520
  this.selectedValues = null;
6521
6521
  this.value = this.selectedValues;
6522
- this._onChange(this.selectedValues);
6523
6522
  this.selectionChange.emit(this.selectedValues);
6524
6523
  }
6525
6524
  else {
6526
6525
  this.value = item;
6527
- this._onChange(item);
6528
6526
  this.selectionChange.emit(item);
6529
6527
  this.closeDropdown();
6530
6528
  }
@@ -6552,26 +6550,22 @@ class LibComboboxReworkComponent {
6552
6550
  const match = this.list?.find((item) => item[this.customValue] === val);
6553
6551
  return match ?? null;
6554
6552
  }
6553
+ /** Formata o valor de retorno com base na configuração de retorno */
6554
+ formatReturn(val) {
6555
+ if (val) {
6556
+ if (this.multiple && Array.isArray(val)) {
6557
+ // Retorna a lista de IDs
6558
+ return val.map(v => v[this.customValue]);
6559
+ }
6560
+ else {
6561
+ // Retorna o ID do item
6562
+ return val[this.customValue];
6563
+ }
6564
+ }
6565
+ return val;
6566
+ }
6555
6567
  // #endregion Seleção
6556
6568
  // #region VALUE_ACCESSOR do Angular
6557
- // // Método antigo
6558
- // public writeValue(obj: T | T[] | null): void {
6559
- // if (!obj) this.selectedValues = null;
6560
- // this._onTouched();
6561
- // if (this.multiple && obj) {
6562
- // this.selectedValues = Array.isArray(obj) ? [...obj] : [];
6563
- // if (this.selectedValues.length === 0) this.selectedValues = null;
6564
- // this.value = this.selectedValues;
6565
- // this._onChange(this.selectedValues);
6566
- // this.selectionChange.emit(this.selectedValues);
6567
- // }
6568
- // else {
6569
- // this.value = obj;
6570
- // this._onChange(obj);
6571
- // this.selectionChange.emit(obj);
6572
- // }
6573
- // this._cdr.markForCheck();
6574
- // }
6575
6569
  writeValue(obj) {
6576
6570
  if (!obj)
6577
6571
  this.selectedValues = null;
@@ -6583,13 +6577,11 @@ class LibComboboxReworkComponent {
6583
6577
  if (this.selectedValues.length === 0)
6584
6578
  this.selectedValues = null;
6585
6579
  this.value = this.selectedValues;
6586
- this._onChange(this.selectedValues);
6587
6580
  this.selectionChange.emit(this.selectedValues);
6588
6581
  }
6589
6582
  else {
6590
6583
  const resolved = this.resolveValue(obj);
6591
6584
  this.value = resolved;
6592
- this._onChange(resolved);
6593
6585
  this.selectionChange.emit(resolved);
6594
6586
  }
6595
6587
  this._cdr.markForCheck();
@@ -6696,7 +6688,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
6696
6688
  }
6697
6689
  ], template: "<div class=\"reusable-combobox input-group\" [class.show]=\"isOpen\" (focusout)=\"onBlurOutside($event)\" >\n @if (leftButtonTemplate) { <ng-container *ngTemplateOutlet=\"leftButtonTemplate\"></ng-container> }\n\n <div class=\"dropdown w-100\">\n <div #toggleButton id=\"toggle-button\" class=\"form-select d-flex align-items-center text-start\" type=\"button\" data-bs-toggle=\"dropdown\"\n data-bs-auto-close=\"outside\" [attr.aria-expanded]=\"isOpen\" [attr.aria-haspopup]=\"true\" [attr.aria-label]=\"placeholder\" [class.disabled]=\"disabled\"\n [class.is-invalid]=\"invalid\" (click)=\"toggleDropdown()\" readonly\n [ngClass]=\"{\n 'rounded-start-0': leftButtonTemplate,\n 'rounded-end-0': rightButtonTemplate,\n }\" >\n <span class=\"w-100 overflow-hidden text-truncate\"> {{ displayValue() }} </span> \n </div>\n\n <div class=\"dropdown-menu p-2 w-100\" [class.show]=\"isOpen\" style=\"max-height: 320px; overflow-y: auto;\" >\n <div class=\"dropdown-search input-group mb-2\">\n <input class=\"form-control form-control-sm\" type=\"search\" [placeholder]=\"searchPlaceholder\" [formControl]=\"searchControl\" aria-label=\"Pesquisar op\u00E7\u00F5es\" (keyup.enter)=\"filterButtonClick.emit(searchControl.value)\" />\n <button class=\"btn btn-sm btn-primary\" type=\"button\" (click)=\"filterButtonClick.emit(searchControl.value)\"> <lib-icon iconName=\"lupa\" iconSize=\"medium-small\" /> </button>\n </div>\n\n @if (multiple && selectedValues?.length) {\n <div class=\"d-flex flex-row gap-2 flex-wrap my-2\">\n <span *ngFor=\"let value of selectedValues; trackBy: trackByFn\" class=\"px-3 badge rounded-pill text-primary bg-primary-subtle\">\n {{ value[customLabel] }} <lib-icon class=\"glb-cursor-pointer\" iconName=\"fechar\" iconSize=\"small\" (click)=\"select(value)\" />\n </span>\n </div>\n }\n\n <!-- Se utilizar o filtro interno utiliza a propriedade de lista filteredItems$, caso contr\u00E1rio usa a pr\u00F3pria list pois ela ser\u00E1 filtrada pelo componente pai -->\n <ng-container *ngIf=\"(innerFilter ? (filteredItems$ | async) : list) as items\">\n @if (items.length === 0) { <div class=\"py-2 px-3 text-muted small\">{{ noResultsText }}</div> }\n\n @if (value !== '' && value !== null) {\n <button type=\"button\" class=\"dropdown-item d-flex align-items-center\" (click)=\"writeValue(null)\">\n <span class=\"fw-bold\">Limpar {{ multiple ? 'op\u00E7\u00F5es selecionadas' : 'op\u00E7\u00E3o selecionada' }}</span>\n </button>\n }\n\n <button *ngFor=\"let item of items; trackBy: trackByFn\" class=\"dropdown-item d-flex align-items-center\" type=\"button\"\n (click)=\"select(item)\" [attr.aria-selected]=\"isSelected(item)\" >\n\n @if (optionTemplate) {\n <ng-container *ngTemplateOutlet=\"optionTemplate; context: { $implicit: item, selected: isSelected(item) }\"></ng-container>\n }\n @else {\n <div class=\"w-100 original\">\n <div class=\"d-flex justify-content-between\">\n <div>{{ (item[customLabel] ?? item[customValue]) }}</div>\n <small class=\"text-muted\" *ngIf=\"isSelected(item)\">\u2713</small>\n </div>\n </div>\n }\n </button>\n </ng-container>\n </div>\n </div>\n\n @if (rightButtonTemplate) { <ng-container *ngTemplateOutlet=\"rightButtonTemplate\"></ng-container> }\n</div>\n", styles: [".reusable-combobox{position:relative;display:flex;flex-wrap:nowrap;width:100%;max-width:100%}.reusable-combobox #toggle-button{box-sizing:border-box}.reusable-combobox .dropdown-menu{width:100%;box-shadow:0 6px 18px #00000014;border-radius:.5rem}.reusable-combobox .dropdown-item{cursor:pointer;border-radius:6px;transition:all .3s ease}.reusable-combobox .dropdown-item:hover:not(:focus){background-color:#f1f5f9}.reusable-combobox.compact .dropdown-menu{max-height:200px}.bg-primary-subtle{background-color:#d1dfe7!important}::-webkit-scrollbar{width:4px;background:transparent}::-webkit-scrollbar-thumb{background:#bbb;border-radius:16px}\n"] }]
6698
6690
  }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }], propDecorators: { list: [{
6699
- type: Input
6691
+ type: Input,
6692
+ args: [{ required: true }]
6700
6693
  }], placeholder: [{
6701
6694
  type: Input
6702
6695
  }], searchPlaceholder: [{