matcha-components 19.10.0 → 19.11.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.
@@ -1,7 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { EventEmitter, Component, Input, Output, ContentChildren, ElementRef, Renderer2, Inject, HostListener, Directive, NgModule } from '@angular/core';
3
3
  import { animation, style, animate, trigger, transition, useAnimation, state, query, stagger, animateChild, sequence, group } from '@angular/animations';
4
- import { Subscription } from 'rxjs';
4
+ import { Subscription, Subject } from 'rxjs';
5
+ import { debounceTime } from 'rxjs/operators';
5
6
  import * as i1 from '@angular/common';
6
7
  import { CommonModule } from '@angular/common';
7
8
 
@@ -501,11 +502,14 @@ class MatchaInfiniteScrollDataComponent {
501
502
  this.aggregatedList = [];
502
503
  this.currentPage = 0;
503
504
  this.subscription = new Subscription();
505
+ // Subject para aplicar debounce no searchTerm
506
+ this.searchTermSubject = new Subject();
504
507
  }
505
508
  ngOnInit() {
506
509
  this.initialize();
510
+ // Configura o Intersection Observer para carregamento via scroll
507
511
  const options = {
508
- root: null, // utiliza a viewport como área de visualização
512
+ root: null,
509
513
  rootMargin: '0px',
510
514
  threshold: this.threshold
511
515
  };
@@ -517,18 +521,24 @@ class MatchaInfiniteScrollDataComponent {
517
521
  });
518
522
  }, options);
519
523
  this.observer.observe(this.element.nativeElement);
524
+ // Inscreve para receber alterações do searchTerm com debounce
525
+ this.subscription.add(this.searchTermSubject.pipe(debounceTime(300) // ajusta o tempo conforme necessário
526
+ ).subscribe(() => {
527
+ // Reseta e carrega a primeira página após o debounce
528
+ this.reset();
529
+ this.loadNextPage();
530
+ }));
520
531
  }
521
532
  /**
522
- * Detecta mudanças no resetKey e, se for o caso, reseta a lista e a página atual.
533
+ * Detecta mudanças nos inputs e, se for o caso, reseta a lista e a página atual.
523
534
  */
524
535
  ngOnChanges(changes) {
525
536
  if (changes['resetKey'] && !changes['resetKey'].firstChange) {
526
537
  this.reset();
527
538
  }
528
539
  if (changes['searchTerm'] && !changes['searchTerm'].firstChange) {
529
- // Reset e dispara imediatamente a carga para o autocomplete
530
- this.reset();
531
- this.loadNextPage();
540
+ // Emite o novo valor para o Subject e aguarda o debounce
541
+ this.searchTermSubject.next(changes['searchTerm'].currentValue);
532
542
  }
533
543
  }
534
544
  /**