matcha-components 19.9.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,
|
|
512
|
+
root: null,
|
|
509
513
|
rootMargin: '0px',
|
|
510
514
|
threshold: this.threshold
|
|
511
515
|
};
|
|
@@ -517,16 +521,25 @@ 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
|
|
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
|
-
console.log('changes', changes);
|
|
526
536
|
if (changes['resetKey'] && !changes['resetKey'].firstChange) {
|
|
527
|
-
console.log('entrou no if changes', changes);
|
|
528
537
|
this.reset();
|
|
529
538
|
}
|
|
539
|
+
if (changes['searchTerm'] && !changes['searchTerm'].firstChange) {
|
|
540
|
+
// Emite o novo valor para o Subject e aguarda o debounce
|
|
541
|
+
this.searchTermSubject.next(changes['searchTerm'].currentValue);
|
|
542
|
+
}
|
|
530
543
|
}
|
|
531
544
|
/**
|
|
532
545
|
* Inicializa ou reinicializa a lista agregada e o contador de página.
|
|
@@ -568,7 +581,7 @@ class MatchaInfiniteScrollDataComponent {
|
|
|
568
581
|
this.subscription.unsubscribe();
|
|
569
582
|
}
|
|
570
583
|
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 }); }
|
|
571
|
-
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" }, outputs: { aggregatedData: "aggregatedData" }, usesOnChanges: true, ngImport: i0, template: "", styles: ["", ":host{height:1px;opacity:0}\n"] }); }
|
|
584
|
+
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"] }); }
|
|
572
585
|
}
|
|
573
586
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: MatchaInfiniteScrollDataComponent, decorators: [{
|
|
574
587
|
type: Component,
|
|
@@ -581,6 +594,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
|
|
|
581
594
|
type: Input
|
|
582
595
|
}], resetKey: [{
|
|
583
596
|
type: Input
|
|
597
|
+
}], searchTerm: [{
|
|
598
|
+
type: Input
|
|
584
599
|
}], aggregatedData: [{
|
|
585
600
|
type: Output
|
|
586
601
|
}] } });
|