import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { EventEmitter, numberAttribute, booleanAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChild, ContentChildren, ViewChild, NgModule } from '@angular/core'; import * as i2 from 'primeng/api'; import { Header, Footer, PrimeTemplate, SharedModule } from 'primeng/api'; import * as i3 from 'primeng/scroller'; import { ScrollerModule } from 'primeng/scroller'; /** * VirtualScroller is a performant approach to handle huge data efficiently. * @group Components */ class VirtualScroller { el; cd; /** * An array of objects to display. * @group Props */ value; /** * Height of an item in the list. * @group Props */ itemSize; /** * Inline style of the component. * @group Props */ style; /** * Style class of the component. * @group Props */ styleClass; /** * Max height of the content area in inline mode. * @group Props */ scrollHeight; /** * Defines if data is loaded and interacted with in lazy manner. * @group Props */ lazy; /** * Whether to use the scroller feature. The properties of scroller component can be used like an object in it. * @group Props */ options; /** * Threshold in milliseconds to delay lazy loading during scrolling. * @group Props */ delay = 250; /** * Callback to invoke in lazy mode to load new data. * @param {VirtualScrollerLazyLoadEvent} event - custom lazy load event. * @group Emits */ onLazyLoad = new EventEmitter(); header; footer; templates; scroller; itemTemplate; headerTemplate; footerTemplate; loadingItemTemplate; virtualScrollTimeout; constructor(el, cd) { this.el = el; this.cd = cd; } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'item': this.itemTemplate = item.template; break; case 'loadingItem': this.loadingItemTemplate = item.template; break; case 'header': this.headerTemplate = item.template; break; case 'footer': this.footerTemplate = item.template; break; default: this.itemTemplate = item.template; break; } }); } onLazyItemLoad(event) { if (this.virtualScrollTimeout) { clearTimeout(this.virtualScrollTimeout); } this.virtualScrollTimeout = setTimeout(() => { this.onLazyLoad.emit({ ...event, rows: event.last - event.first, forceUpdate: () => this.cd.detectChanges() }); }, this.delay); } getBlockableElement() { return this.el.nativeElement.children[0]; } scrollToIndex(index, mode) { this.scroller?.scrollToIndex(index, mode); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: VirtualScroller, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: VirtualScroller, selector: "p-virtualScroller", inputs: { value: "value", itemSize: ["itemSize", "itemSize", numberAttribute], style: "style", styleClass: "styleClass", scrollHeight: "scrollHeight", lazy: ["lazy", "lazy", booleanAttribute], options: "options", delay: ["delay", "delay", numberAttribute] }, outputs: { onLazyLoad: "onLazyLoad" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "header", first: true, predicate: Header, descendants: true }, { propertyName: "footer", first: true, predicate: Footer, descendants: true }, { propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true }], ngImport: i0, template: `