import * as i0 from '@angular/core'; import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, ContentChild, ContentChildren, ViewChild, Output, NgModule } from '@angular/core'; import * as i2 from '@angular/common'; import { CommonModule } from '@angular/common'; import { Header, Footer, PrimeTemplate, SharedModule } from 'primeng/api'; import * as i1 from '@angular/cdk/scrolling'; import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling'; class VirtualScroller { constructor(el) { this.el = el; this.delay = 250; this.trackBy = (index, item) => item; this.onLazyLoad = new EventEmitter(); this._totalRecords = 0; this.page = 0; this._first = 0; } get totalRecords() { return this._totalRecords; } set totalRecords(val) { this._totalRecords = val; console.log("totalRecords is deprecated, provide a value with the length of virtual items instead."); } get first() { return this._first; } set first(val) { this._first = val; console.log("first property is deprecated, use scrollToIndex function to scroll a specific item."); } get cache() { return this._cache; } set cache(val) { this._cache = val; console.log("cache is deprecated as it is always on."); } 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; } }); } onScrollIndexChange(index) { if (this.lazy) { if (this.virtualScrollTimeout) { clearTimeout(this.virtualScrollTimeout); } this.virtualScrollTimeout = setTimeout(() => { let page = Math.floor(index / this.rows); let virtualScrollOffset = page === 0 ? 0 : (page - 1) * this.rows; let virtualScrollChunkSize = page === 0 ? this.rows * 2 : this.rows * 3; if (page !== this.virtualPage) { this.virtualPage = page; this.onLazyLoad.emit({ first: virtualScrollOffset, rows: virtualScrollChunkSize }); } }, this.delay); } } getBlockableElement() { return this.el.nativeElement.children[0]; } //@deprecated scrollTo(index, mode) { this.scrollToIndex(index, mode); } scrollToIndex(index, mode) { if (this.viewport) { this.viewport.scrollToIndex(index, mode); } } } VirtualScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: VirtualScroller, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); VirtualScroller.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: VirtualScroller, selector: "p-virtualScroller", inputs: { value: "value", itemSize: "itemSize", style: "style", styleClass: "styleClass", scrollHeight: "scrollHeight", lazy: "lazy", rows: "rows", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx", delay: "delay", trackBy: "trackBy", totalRecords: "totalRecords", first: "first", cache: "cache" }, 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: "viewport", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], ngImport: i0, template: `