ngx-sp-infra 5.2.10 → 5.2.11

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.
@@ -5501,6 +5501,38 @@ class Utils {
5501
5501
  }
5502
5502
  return 0;
5503
5503
  }
5504
+ /** Método de ordenação alfanumérico com possibilidade de direção */
5505
+ static alphanumericSortOld(a, b, direction = 'asc') {
5506
+ const regex = /(\d+|\D+)/g;
5507
+ const stringA = this.propertyIsNullUndefinedOrEmpty(a) ? "" : a;
5508
+ const stringB = this.propertyIsNullUndefinedOrEmpty(b) ? "" : b;
5509
+ const aParts = stringA.toString().match(regex) || [];
5510
+ const bParts = stringB.toString().match(regex) || [];
5511
+ const length = Math.max(aParts.length, bParts.length);
5512
+ for (let i = 0; i < length; i++) {
5513
+ const aPart = aParts[i] || "";
5514
+ const bPart = bParts[i] || "";
5515
+ const aIsNumber = !isNaN(Number(aPart));
5516
+ const bIsNumber = !isNaN(Number(bPart));
5517
+ if (aIsNumber && bIsNumber) {
5518
+ const numCompare = Number(aPart) - Number(bPart);
5519
+ if (numCompare !== 0)
5520
+ return direction === 'asc' ? numCompare : -numCompare;
5521
+ }
5522
+ else if (aIsNumber) {
5523
+ return direction === 'asc' ? -1 : 1;
5524
+ }
5525
+ else if (bIsNumber) {
5526
+ return direction === 'asc' ? 1 : -1;
5527
+ }
5528
+ else {
5529
+ const strCompare = aPart.localeCompare(bPart);
5530
+ if (strCompare !== 0)
5531
+ return direction === 'asc' ? strCompare : -strCompare;
5532
+ }
5533
+ }
5534
+ return 0;
5535
+ }
5504
5536
  // #endregion ORDENAÇÃO
5505
5537
  // #region ==========> VALIDAÇÕES DE VAZIO <==========
5506
5538
  /** Retorna se a variável informada é === null || undefined || "" (string vazia) */
@@ -6055,7 +6087,7 @@ class TableComponent {
6055
6087
  recordsList.sort((a, b) => {
6056
6088
  const propertyA = this.getProperty(a, attribute).toUpperCase(); // Puxa o nome da coluna que irá ordenar
6057
6089
  const propertyB = this.getProperty(b, attribute).toUpperCase(); // Puxa o nome da coluna que irá ordenar
6058
- return Utils.alphanumericSort(propertyA, propertyB, this.sortDirection[attribute]);
6090
+ return Utils.alphanumericSortOld(propertyA, propertyB, this.sortDirection[attribute]);
6059
6091
  });
6060
6092
  }
6061
6093
  }
@@ -7626,7 +7658,7 @@ class LibTransferListComponent {
7626
7658
  atualizarSelecoes(origem, destino, origemConfig, origemSelecionados, componenteOrigem, componenteDestino) {
7627
7659
  origemSelecionados.forEach(item => destino.push(item));
7628
7660
  // destino = [ ...origemSelecionados ];
7629
- destino.sort((a, b) => Utils.alphanumericSort(a.ID, b.ID));
7661
+ destino.sort((a, b) => Utils.alphanumericSortOld(a.ID, b.ID));
7630
7662
  origemSelecionados.forEach(selectedItem => {
7631
7663
  const index = origem.findIndex(item => item === selectedItem);
7632
7664
  if (index !== -1)
@@ -8778,7 +8810,7 @@ class LibCustomizableTableComponent {
8778
8810
  this.list.sort((a, b) => {
8779
8811
  const propertyA = this.getProperty(a, attribute).toUpperCase();
8780
8812
  const propertyB = this.getProperty(b, attribute).toUpperCase();
8781
- return Utils.alphanumericSort(propertyA, propertyB, this.sortDirection[attribute]);
8813
+ return Utils.alphanumericSortOld(propertyA, propertyB, this.sortDirection[attribute]);
8782
8814
  });
8783
8815
  }
8784
8816
  /** Compara os valores das propriedades entre dois objetos */