matcha-components 19.11.0 → 19.13.0

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.
@@ -501,7 +501,10 @@ class MatchaInfiniteScrollDataComponent {
501
501
  this.aggregatedData = new EventEmitter();
502
502
  this.aggregatedList = [];
503
503
  this.currentPage = 0;
504
- this.subscription = new Subscription();
504
+ // Subscription para as chamadas do loadData
505
+ this.dataSubscription = new Subscription();
506
+ // Subscription exclusiva para o debounce do searchTerm
507
+ this.searchSubscription = new Subscription();
505
508
  // Subject para aplicar debounce no searchTerm
506
509
  this.searchTermSubject = new Subject();
507
510
  }
@@ -522,19 +525,19 @@ class MatchaInfiniteScrollDataComponent {
522
525
  }, options);
523
526
  this.observer.observe(this.element.nativeElement);
524
527
  // Inscreve para receber alterações do searchTerm com debounce
525
- this.subscription.add(this.searchTermSubject.pipe(debounceTime(300) // ajusta o tempo conforme necessário
528
+ this.searchSubscription = this.searchTermSubject.pipe(debounceTime(300) // ajuste o tempo conforme necessário
526
529
  ).subscribe(() => {
527
530
  // Reseta e carrega a primeira página após o debounce
528
- this.reset();
531
+ this.resetData();
529
532
  this.loadNextPage();
530
- }));
533
+ });
531
534
  }
532
535
  /**
533
536
  * Detecta mudanças nos inputs e, se for o caso, reseta a lista e a página atual.
534
537
  */
535
538
  ngOnChanges(changes) {
536
539
  if (changes['resetKey'] && !changes['resetKey'].firstChange) {
537
- this.reset();
540
+ this.resetData();
538
541
  }
539
542
  if (changes['searchTerm'] && !changes['searchTerm'].firstChange) {
540
543
  // Emite o novo valor para o Subject e aguarda o debounce
@@ -550,12 +553,12 @@ class MatchaInfiniteScrollDataComponent {
550
553
  this.aggregatedData.emit(this.aggregatedList);
551
554
  }
552
555
  /**
553
- * Reseta o estado interno da diretiva.
556
+ * Reseta apenas as assinaturas e o estado dos dados (não a inscrição do searchTerm).
554
557
  */
555
- reset() {
556
- // Cancela quaisquer assinaturas pendentes
557
- this.subscription.unsubscribe();
558
- this.subscription = new Subscription();
558
+ resetData() {
559
+ // Cancela as assinaturas das chamadas de loadData
560
+ this.dataSubscription.unsubscribe();
561
+ this.dataSubscription = new Subscription();
559
562
  // Re-inicializa a lista e o contador
560
563
  this.initialize();
561
564
  }
@@ -574,11 +577,12 @@ class MatchaInfiniteScrollDataComponent {
574
577
  this.aggregatedData.emit(this.aggregatedList);
575
578
  }
576
579
  });
577
- this.subscription.add(sub);
580
+ this.dataSubscription.add(sub);
578
581
  }
579
582
  ngOnDestroy() {
580
583
  this.observer.disconnect();
581
- this.subscription.unsubscribe();
584
+ this.dataSubscription.unsubscribe();
585
+ this.searchSubscription.unsubscribe();
582
586
  }
583
587
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: MatchaInfiniteScrollDataComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
584
588
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.4", type: MatchaInfiniteScrollDataComponent, isStandalone: false, selector: "matcha-infinite-scroll-data", inputs: { loadData: "loadData", initialList: "initialList", threshold: "threshold", resetKey: "resetKey", searchTerm: "searchTerm" }, outputs: { aggregatedData: "aggregatedData" }, usesOnChanges: true, ngImport: i0, template: "", styles: ["", ":host{height:1px;opacity:0}\n"] }); }