{"version":3,"file":"primeng-virtualscroller.mjs","sources":["../../src/app/components/virtualscroller/virtualscroller.ts","../../src/app/components/virtualscroller/primeng-virtualscroller.ts"],"sourcesContent":["import {NgModule,Component,ElementRef,AfterContentInit,Input,Output,ViewChild,EventEmitter,ContentChild,ContentChildren,QueryList,TemplateRef,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {Header,Footer,PrimeTemplate,SharedModule} from 'primeng/api';\nimport {ScrollingModule,CdkVirtualScrollViewport} from '@angular/cdk/scrolling';\nimport {BlockableUI} from 'primeng/api';\n\n@Component({\n selector: 'p-virtualScroller',\n template:`\n
\n
\n \n \n
\n
\n
\n \n \n
\n \n
\n
\n
\n
\n
\n
\n \n \n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.Default,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./virtualscroller.css'],\n host: {\n 'class': 'p-element'\n }\n})\nexport class VirtualScroller implements AfterContentInit,BlockableUI {\n\n @Input() value: any[];\n\n @Input() itemSize: number;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() scrollHeight: any;\n\n @Input() lazy: boolean;\n\n @Input() rows: number;\n\n @Input() minBufferPx: number;\n\n @Input() maxBufferPx: number;\n\n @Input() delay: number = 250;\n\n @Input() trackBy: Function = (index: number, item: any) => item;\n\n @ContentChild(Header) header: Header;\n\n @ContentChild(Footer) footer: Footer;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n @ViewChild(CdkVirtualScrollViewport) viewport: CdkVirtualScrollViewport;\n\n @Output() onLazyLoad: EventEmitter = new EventEmitter();\n\n itemTemplate: TemplateRef;\n\n headerTemplate: TemplateRef;\n\n footerTemplate: TemplateRef;\n\n loadingItemTemplate: TemplateRef;\n\n _totalRecords: number = 0;\n\n page: number = 0;\n\n _first: number = 0;\n\n _cache: boolean;\n\n virtualScrollTimeout: any;\n\n virtualPage: number;\n\n constructor(public el: ElementRef) {}\n\n @Input() get totalRecords(): number {\n return this._totalRecords;\n }\n set totalRecords(val: number) {\n this._totalRecords = val;\n console.log(\"totalRecords is deprecated, provide a value with the length of virtual items instead.\");\n }\n\n @Input() get first(): number {\n return this._first;\n }\n set first(val:number) {\n this._first = val;\n console.log(\"first property is deprecated, use scrollToIndex function to scroll a specific item.\");\n }\n\n @Input() get cache(): boolean {\n return this._cache;\n }\n set cache(val: boolean) {\n this._cache = val;\n console.log(\"cache is deprecated as it is always on.\");\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'item':\n this.itemTemplate = item.template;\n break;\n\n case 'loadingItem':\n this.loadingItemTemplate = item.template;\n break;\n\n case 'header':\n this.headerTemplate = item.template;\n break;\n\n case 'footer':\n this.footerTemplate = item.template;\n break;\n\n default:\n this.itemTemplate = item.template;\n break;\n }\n });\n }\n\n onScrollIndexChange(index: number) {\n if (this.lazy) {\n if (this.virtualScrollTimeout) {\n clearTimeout(this.virtualScrollTimeout);\n }\n\n this.virtualScrollTimeout = setTimeout(() => {\n let page = Math.floor(index / this.rows);\n let virtualScrollOffset = page === 0 ? 0 : (page - 1) * this.rows;\n let virtualScrollChunkSize = page === 0 ? this.rows * 2 : this.rows * 3;\n\n if (page !== this.virtualPage) {\n this.virtualPage = page;\n this.onLazyLoad.emit({first: virtualScrollOffset, rows: virtualScrollChunkSize});\n }\n }, this.delay);\n }\n }\n\n getBlockableElement(): HTMLElement {\n return this.el.nativeElement.children[0];\n }\n\n //@deprecated\n scrollTo(index: number, mode?: ScrollBehavior): void {\n this.scrollToIndex(index, mode);\n }\n\n scrollToIndex(index: number, mode?: ScrollBehavior): void {\n if (this.viewport) {\n this.viewport.scrollToIndex(index, mode);\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule,ScrollingModule],\n exports: [VirtualScroller,SharedModule,ScrollingModule],\n declarations: [VirtualScroller]\n})\nexport class VirtualScrollerModule { }\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n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