{"version":3,"file":"primeng-dataview.umd.js","sources":["../../src/app/components/dataview/dataview.ts","../../src/app/components/dataview/primeng-dataview.ts"],"sourcesContent":["import {NgModule,Component,ElementRef,OnInit,AfterContentInit,Input,Output,EventEmitter,ContentChild,ContentChildren,QueryList,TemplateRef,OnChanges,SimpleChanges,ChangeDetectionStrategy,ChangeDetectorRef, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {ObjectUtils} from 'primeng/utils';\nimport {Header,Footer,PrimeTemplate,SharedModule,FilterService} from 'primeng/api';\nimport {PaginatorModule} from 'primeng/paginator';\nimport {BlockableUI} from 'primeng/api';\n\n@Component({\n selector: 'p-dataView',\n template: `\n
\n
\n
\n \n
\n
\n
\n \n \n
\n \n
\n
\n \n \n \n
\n
{{emptyMessage}}
\n
\n
\n
\n \n
\n \n \n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./dataview.css']\n})\nexport class DataView implements OnInit,AfterContentInit,BlockableUI,OnChanges {\n\n @Input() layout: string = 'list';\n\n @Input() paginator: boolean;\n\n @Input() rows: number;\n\n @Input() totalRecords: number;\n\n @Input() pageLinks: number = 5;\n\n @Input() rowsPerPageOptions: any[];\n\n @Input() paginatorPosition: string = 'bottom';\n\n @Input() alwaysShowPaginator: boolean = true;\n\n @Input() paginatorDropdownAppendTo: any;\n\n @Input() paginatorDropdownScrollHeight: string = '200px';\n\n @Input() currentPageReportTemplate: string = '{currentPage} of {totalPages}';\n\n @Input() showCurrentPageReport: boolean;\n\n @Input() showJumpToPageDropdown: boolean;\n\n @Input() showFirstLastIcon: boolean = true;\n\n @Input() showPageLinks: boolean = true;\n\n @Input() lazy: boolean;\n\n @Input() emptyMessage: string = 'No records found';\n\n @Output() onLazyLoad: EventEmitter = new EventEmitter();\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() trackBy: Function = (index: number, item: any) => item;\n\n @Input() filterBy: string;\n\n @Input() filterLocale: string;\n\n @Input() loading: boolean;\n\n @Input() loadingIcon: string = 'pi pi-spinner';\n\n @Input() first: number = 0;\n\n @Input() sortField: string;\n\n @Input() sortOrder: number;\n\n @Input() value: any[];\n\n @Output() onPage: EventEmitter = new EventEmitter();\n\n @Output() onSort: EventEmitter = new EventEmitter();\n\n @Output() onChangeLayout: EventEmitter = new EventEmitter();\n\n @ContentChild(Header) header;\n\n @ContentChild(Footer) footer;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n _value: any[];\n\n listItemTemplate: TemplateRef;\n\n gridItemTemplate: TemplateRef;\n\n itemTemplate: TemplateRef;\n\n headerTemplate: TemplateRef;\n\n footerTemplate: TemplateRef;\n\n paginatorLeftTemplate: TemplateRef;\n\n paginatorRightTemplate: TemplateRef;\n\n paginatorDropdownItemTemplate: TemplateRef;\n\n filteredValue: any[];\n\n filterValue: string;\n\n initialized: boolean;\n\n constructor(public el: ElementRef, public cd: ChangeDetectorRef, public filterService: FilterService) {}\n\n ngOnInit() {\n if (this.lazy) {\n this.onLazyLoad.emit(this.createLazyLoadMetadata());\n }\n this.initialized = true;\n }\n\n ngOnChanges(simpleChanges: SimpleChanges) {\n if (simpleChanges.value) {\n this._value = simpleChanges.value.currentValue;\n this.updateTotalRecords();\n\n if (!this.lazy && this.hasFilter()) {\n this.filter(this.filterValue);\n }\n }\n\n if (simpleChanges.sortField || simpleChanges.sortOrder) {\n //avoid triggering lazy load prior to lazy initialization at onInit\n if (!this.lazy || this.initialized) {\n this.sort();\n }\n }\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'listItem':\n this.listItemTemplate = item.template;\n break;\n\n case 'gridItem':\n this.gridItemTemplate = item.template;\n break;\n\n case 'paginatorleft':\n this.paginatorLeftTemplate = item.template;\n break;\n\n case 'paginatorright':\n this.paginatorRightTemplate = item.template;\n break;\n\n case 'paginatordropdownitem':\n this.paginatorDropdownItemTemplate = 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 });\n\n this.updateItemTemplate();\n }\n\n updateItemTemplate() {\n switch(this.layout) {\n case 'list':\n this.itemTemplate = this.listItemTemplate;\n break;\n\n case 'grid':\n this.itemTemplate = this.gridItemTemplate;\n break;\n }\n }\n\n changeLayout(layout: string) {\n this.layout = layout;\n this.onChangeLayout.emit({\n layout: this.layout\n });\n this.updateItemTemplate();\n\n this.cd.markForCheck();\n }\n\n updateTotalRecords() {\n this.totalRecords = this.lazy ? this.totalRecords : (this._value ? this._value.length : 0);\n }\n\n paginate(event) {\n this.first = event.first;\n this.rows = event.rows;\n\n if (this.lazy) {\n this.onLazyLoad.emit(this.createLazyLoadMetadata());\n }\n\n this.onPage.emit({\n first: this.first,\n rows: this.rows\n });\n }\n\n sort() {\n this.first = 0;\n\n if (this.lazy) {\n this.onLazyLoad.emit(this.createLazyLoadMetadata());\n }\n else if (this.value) {\n this.value.sort((data1, data2) => {\n let value1 = ObjectUtils.resolveFieldData(data1, this.sortField);\n let value2 = ObjectUtils.resolveFieldData(data2, this.sortField);\n let result = null;\n\n if (value1 == null && value2 != null)\n result = -1;\n else if (value1 != null && value2 == null)\n result = 1;\n else if (value1 == null && value2 == null)\n result = 0;\n else if (typeof value1 === 'string' && typeof value2 === 'string')\n result = value1.localeCompare(value2);\n else\n result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;\n\n return (this.sortOrder * result);\n });\n\n if (this.hasFilter()) {\n this.filter(this.filterValue);\n }\n }\n\n this.onSort.emit({\n sortField: this.sortField,\n sortOrder: this.sortOrder\n });\n }\n\n isEmpty() {\n let data = this.filteredValue||this.value;\n return data == null || data.length == 0;\n }\n\n createLazyLoadMetadata(): any {\n return {\n first: this.first,\n rows: this.rows,\n sortField: this.sortField,\n sortOrder: this.sortOrder\n };\n }\n\n getBlockableElement(): HTMLElement {\n return this.el.nativeElement.children[0];\n }\n\n filter(filter: string, filterMatchMode:string =\"contains\") {\n this.filterValue = filter;\n\n if (this.value && this.value.length) {\n let searchFields = this.filterBy.split(',');\n this.filteredValue = this.filterService.filter(this.value, searchFields, filter, filterMatchMode, this.filterLocale);\n\n if (this.filteredValue.length === this.value.length ) {\n this.filteredValue = null;\n }\n\n if (this.paginator) {\n this.first = 0;\n this.totalRecords = this.filteredValue ? this.filteredValue.length : this.value ? this.value.length : 0;\n }\n\n this.cd.markForCheck();\n }\n }\n\n hasFilter() {\n return this.filterValue && this.filterValue.trim().length > 0;\n }\n}\n\n@Component({\n selector: 'p-dataViewLayoutOptions',\n template: `\n
\n \n
\n `,\n encapsulation: ViewEncapsulation.None\n})\nexport class DataViewLayoutOptions {\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n constructor(public dv: DataView) {}\n\n changeLayout(event: Event, layout: string) {\n this.dv.changeLayout(layout);\n event.preventDefault();\n }\n}\n@NgModule({\n imports: [CommonModule,SharedModule,PaginatorModule],\n exports: [DataView,SharedModule,DataViewLayoutOptions],\n declarations: [DataView,DataViewLayoutOptions]\n})\nexport class DataViewModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["EventEmitter","ObjectUtils","Component","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","ChangeDetectorRef","FilterService","Input","Output","ContentChild","Header","Footer","ContentChildren","PrimeTemplate","NgModule","CommonModule","SharedModule","PaginatorModule"],"mappings":";;;;;;;QAgJI,kBAAmB,EAAc,EAAS,EAAqB,EAAS,aAA4B;YAAjF,OAAE,GAAF,EAAE,CAAY;YAAS,OAAE,GAAF,EAAE,CAAmB;YAAS,kBAAa,GAAb,aAAa,CAAe;YA9F3F,WAAM,GAAW,MAAM,CAAC;YAQxB,cAAS,GAAW,CAAC,CAAC;YAItB,sBAAiB,GAAW,QAAQ,CAAC;YAErC,wBAAmB,GAAY,IAAI,CAAC;YAIpC,kCAA6B,GAAW,OAAO,CAAC;YAEhD,8BAAyB,GAAW,+BAA+B,CAAC;YAMpE,sB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