matcha-components 19.135.0 → 19.136.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.
@@ -639,6 +639,183 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
639
639
  type: Output
640
640
  }] } });
641
641
 
642
+ /*
643
+ HOW TO USE ---------------------------------------------------------
644
+ TEMPLATE:
645
+ <!-- Elemento sentinela para detectar o scroll -->
646
+ <option disabled style="height: 1px; padding: 0; margin: 0;">
647
+ <!-- Esse <div> não precisa ter conteúdo visual; ele apenas será observado -->
648
+ <div infiniteScroll (scrolledToEnd)="onScrolledToEnd()"></div>
649
+ </option>
650
+ */
651
+ class MatchaLazyloadComponent {
652
+ constructor(element) {
653
+ this.element = element;
654
+ // Evento que será disparado quando o elemento entrar na área visível
655
+ this.scrolledToEnd = new EventEmitter();
656
+ }
657
+ ngOnInit() {
658
+ // Configura o observer para disparar quando 10% do elemento estiver visível
659
+ const options = {
660
+ root: null, // Usa a viewport
661
+ rootMargin: '0px',
662
+ threshold: 0.1
663
+ };
664
+ this.observer = new IntersectionObserver((entries) => {
665
+ entries.forEach(entry => {
666
+ if (entry.isIntersecting) {
667
+ this.scrolledToEnd.emit();
668
+ }
669
+ });
670
+ }, options);
671
+ this.observer.observe(this.element.nativeElement);
672
+ }
673
+ ngOnDestroy() {
674
+ this.observer.disconnect();
675
+ }
676
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
677
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: MatchaLazyloadComponent, isStandalone: false, selector: "matcha-lazyload", outputs: { scrolledToEnd: "scrolledToEnd" }, ngImport: i0, template: "<ng-content></ng-content>\n", styles: [""] }); }
678
+ }
679
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadComponent, decorators: [{
680
+ type: Component,
681
+ args: [{ selector: 'matcha-lazyload', standalone: false, template: "<ng-content></ng-content>\n" }]
682
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { scrolledToEnd: [{
683
+ type: Output
684
+ }] } });
685
+
686
+ class MatchaLazyloadDataComponent {
687
+ constructor(element) {
688
+ this.element = element;
689
+ /**
690
+ * Lista inicial (opcional) para iniciar a agregação.
691
+ */
692
+ this.initialList = [];
693
+ /**
694
+ * Threshold para o Intersection Observer (padrão: 0.1 = 10% do elemento visível).
695
+ */
696
+ this.threshold = 0.1;
697
+ /**
698
+ * Emite a lista acumulada de itens.
699
+ */
700
+ this.aggregatedData = new EventEmitter();
701
+ /**
702
+ * Emite o item exato, quando a aggregatedData tiver um único item igual ao searchTerm.
703
+ */
704
+ this.exactMatch = new EventEmitter();
705
+ this.aggregatedList = [];
706
+ this.currentPage = 0;
707
+ // Subscription para as chamadas do loadData
708
+ this.dataSubscription = new Subscription();
709
+ // Subscription exclusiva para o debounce do searchTerm
710
+ this.searchSubscription = new Subscription();
711
+ // Subject para aplicar debounce no searchTerm
712
+ this.searchTermSubject = new Subject();
713
+ }
714
+ ngOnInit() {
715
+ this.initialize();
716
+ // Configura o Intersection Observer para carregamento via scroll
717
+ const options = {
718
+ root: null,
719
+ rootMargin: '0px',
720
+ threshold: this.threshold
721
+ };
722
+ this.observer = new IntersectionObserver(entries => {
723
+ entries.forEach(entry => {
724
+ if (entry.isIntersecting) {
725
+ this.loadNextPage();
726
+ }
727
+ });
728
+ }, options);
729
+ this.observer.observe(this.element.nativeElement);
730
+ // Inscreve para receber alterações do searchTerm com debounce
731
+ this.searchSubscription = this.searchTermSubject.pipe(debounceTime(300)).subscribe(() => {
732
+ // Reseta e carrega a primeira página após o debounce
733
+ this.resetData();
734
+ this.loadNextPage();
735
+ });
736
+ }
737
+ ngOnChanges(changes) {
738
+ if (changes['resetKey'] && !changes['resetKey'].firstChange) {
739
+ this.resetData();
740
+ }
741
+ if (changes['searchTerm'] && !changes['searchTerm'].firstChange) {
742
+ // Emite o novo valor para o Subject e aguarda o debounce
743
+ this.searchTermSubject.next(changes['searchTerm'].currentValue);
744
+ }
745
+ }
746
+ /**
747
+ * Inicializa ou reinicializa a lista agregada e o contador de página.
748
+ */
749
+ initialize() {
750
+ this.aggregatedList = [...this.initialList];
751
+ this.currentPage = 0;
752
+ this.aggregatedData.emit(this.aggregatedList);
753
+ this.checkExactMatch();
754
+ }
755
+ /**
756
+ * Reseta apenas as assinaturas e o estado dos dados (não a inscrição do searchTerm).
757
+ */
758
+ resetData() {
759
+ // Cancela as assinaturas das chamadas de loadData
760
+ this.dataSubscription.unsubscribe();
761
+ this.dataSubscription = new Subscription();
762
+ // Re-inicializa a lista e o contador
763
+ this.initialize();
764
+ }
765
+ /**
766
+ * Carrega a próxima página de dados utilizando a função loadData.
767
+ */
768
+ loadNextPage() {
769
+ if (!this.loadData) {
770
+ return;
771
+ }
772
+ this.currentPage++;
773
+ const dataObservable = this.loadData(this.currentPage);
774
+ const sub = dataObservable.subscribe(data => {
775
+ if (data && data.length) {
776
+ this.aggregatedList = [...this.aggregatedList, ...data];
777
+ this.aggregatedData.emit(this.aggregatedList);
778
+ this.checkExactMatch();
779
+ }
780
+ });
781
+ this.dataSubscription.add(sub);
782
+ }
783
+ /**
784
+ * Verifica se a lista agregada possui exatamente um item e se esse item é igual ao searchTerm.
785
+ * Se sim, emite o output exactMatch com esse item.
786
+ */
787
+ checkExactMatch() {
788
+ if (this.aggregatedList.length === 1 && this.aggregatedList[0] === this.searchTerm) {
789
+ this.exactMatch.emit(this.aggregatedList[0]);
790
+ }
791
+ }
792
+ ngOnDestroy() {
793
+ this.observer.disconnect();
794
+ this.dataSubscription.unsubscribe();
795
+ this.searchSubscription.unsubscribe();
796
+ }
797
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadDataComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
798
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: MatchaLazyloadDataComponent, isStandalone: false, selector: "matcha-lazyload-data", inputs: { loadData: "loadData", initialList: "initialList", threshold: "threshold", resetKey: "resetKey", searchTerm: "searchTerm" }, outputs: { aggregatedData: "aggregatedData", exactMatch: "exactMatch" }, usesOnChanges: true, ngImport: i0, template: "<ng-content></ng-content>\n", styles: ["", ":host{height:1px;opacity:0}\n"] }); }
799
+ }
800
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadDataComponent, decorators: [{
801
+ type: Component,
802
+ args: [{ selector: 'matcha-lazyload-data', standalone: false, template: "<ng-content></ng-content>\n", styles: [":host{height:1px;opacity:0}\n"] }]
803
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { loadData: [{
804
+ type: Input
805
+ }], initialList: [{
806
+ type: Input
807
+ }], threshold: [{
808
+ type: Input
809
+ }], resetKey: [{
810
+ type: Input
811
+ }], searchTerm: [{
812
+ type: Input
813
+ }], aggregatedData: [{
814
+ type: Output
815
+ }], exactMatch: [{
816
+ type: Output
817
+ }] } });
818
+
642
819
  class MatchaButtonComponent {
643
820
  get colorAttr() {
644
821
  return this.color;
@@ -3718,6 +3895,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
3718
3895
  }]
3719
3896
  }] });
3720
3897
 
3898
+ class MatchaLazyloadModule {
3899
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
3900
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadModule, declarations: [MatchaLazyloadComponent, MatchaLazyloadDataComponent], imports: [CommonModule], exports: [MatchaLazyloadComponent, MatchaLazyloadDataComponent] }); }
3901
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadModule, imports: [CommonModule] }); }
3902
+ }
3903
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MatchaLazyloadModule, decorators: [{
3904
+ type: NgModule,
3905
+ args: [{
3906
+ declarations: [MatchaLazyloadComponent, MatchaLazyloadDataComponent],
3907
+ imports: [
3908
+ CommonModule
3909
+ ],
3910
+ exports: [MatchaLazyloadComponent, MatchaLazyloadDataComponent]
3911
+ }]
3912
+ }] });
3913
+
3721
3914
  class MatchaElevationDirective {
3722
3915
  constructor(_elementRef, _renderer) {
3723
3916
  this._elementRef = _elementRef;
@@ -5132,6 +5325,7 @@ class MatchaComponentsModule {
5132
5325
  MatchaHintTextModule,
5133
5326
  MatchaIconModule,
5134
5327
  MatchaInfiniteScrollModule,
5328
+ MatchaLazyloadModule,
5135
5329
  MatchaInputModule,
5136
5330
  // MatchaInputPhoneModule,
5137
5331
  MatchaMasonryModule,
@@ -5172,6 +5366,7 @@ class MatchaComponentsModule {
5172
5366
  MatchaHintTextModule,
5173
5367
  MatchaIconModule,
5174
5368
  MatchaInfiniteScrollModule,
5369
+ MatchaLazyloadModule,
5175
5370
  MatchaInputModule,
5176
5371
  // MatchaInputPhoneModule,
5177
5372
  MatchaMasonryModule,
@@ -5218,6 +5413,7 @@ class MatchaComponentsModule {
5218
5413
  MatchaHintTextModule,
5219
5414
  MatchaIconModule,
5220
5415
  MatchaInfiniteScrollModule,
5416
+ MatchaLazyloadModule,
5221
5417
  MatchaInputModule,
5222
5418
  // MatchaInputPhoneModule,
5223
5419
  MatchaMasonryModule,
@@ -5258,6 +5454,7 @@ class MatchaComponentsModule {
5258
5454
  MatchaHintTextModule,
5259
5455
  MatchaIconModule,
5260
5456
  MatchaInfiniteScrollModule,
5457
+ MatchaLazyloadModule,
5261
5458
  MatchaInputModule,
5262
5459
  // MatchaInputPhoneModule,
5263
5460
  MatchaMasonryModule,
@@ -5310,6 +5507,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
5310
5507
  MatchaHintTextModule,
5311
5508
  MatchaIconModule,
5312
5509
  MatchaInfiniteScrollModule,
5510
+ MatchaLazyloadModule,
5313
5511
  MatchaInputModule,
5314
5512
  // MatchaInputPhoneModule,
5315
5513
  MatchaMasonryModule,
@@ -5352,6 +5550,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
5352
5550
  MatchaHintTextModule,
5353
5551
  MatchaIconModule,
5354
5552
  MatchaInfiniteScrollModule,
5553
+ MatchaLazyloadModule,
5355
5554
  MatchaInputModule,
5356
5555
  // MatchaInputPhoneModule,
5357
5556
  MatchaMasonryModule,
@@ -5446,5 +5645,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
5446
5645
  * Generated bundle index. Do not edit.
5447
5646
  */
5448
5647
 
5449
- export { MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteDirective, MatchaAutocompleteModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipsDirective, MatchaChipsModule, MatchaComponentsModule, MatchaDateComponent, MatchaDateModule, MatchaDatepickerDirective, MatchaDatepickerModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaLabelComponent, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOptionComponent, MatchaOptionModule, MatchaOptionService, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorDirective, MatchaPaginatorModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioButtonDirective, MatchaRadioButtonModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectDirective, MatchaSelectModule, MatchaSidenavDirective, MatchaSidenavModule, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderDirective, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTimeComponent, MatchaTimeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective };
5648
+ export { MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteDirective, MatchaAutocompleteModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaChipsDirective, MatchaChipsModule, MatchaComponentsModule, MatchaDateComponent, MatchaDateModule, MatchaDatepickerDirective, MatchaDatepickerModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaLabelComponent, MatchaLazyloadComponent, MatchaLazyloadDataComponent, MatchaLazyloadModule, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOptionComponent, MatchaOptionModule, MatchaOptionService, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorDirective, MatchaPaginatorModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioButtonDirective, MatchaRadioButtonModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectDirective, MatchaSelectModule, MatchaSidenavDirective, MatchaSidenavModule, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderDirective, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTimeComponent, MatchaTimeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective };
5450
5649
  //# sourceMappingURL=matcha-components.mjs.map