import { ChangeDetectionStrategy, Component, ContentChildren, EventEmitter, Input, Output, QueryList, TemplateRef, } from '@angular/core';
import { PaginationService } from 'ngx-pagination';
import { DataTableColumnComponent } from './data-table-column.component';
export class DataTableComponent {
    constructor() {
        this.allSelectChange = new EventEmitter();
        this.rowSelectChange = new EventEmitter();
        this.pageChange = new EventEmitter();
        this.itemsPerPageChange = new EventEmitter();
    }
    ngAfterContentInit() {
        this.rowTemplate = this.templateRefs.last;
    }
    trackByFn(index, item) {
        if (item.id != null) {
            return item.id;
        }
        else {
            return index;
        }
    }
}
DataTableComponent.decorators = [
    { type: Component, args: [{
                selector: 'vdr-data-table',
                template: "<ng-container *ngIf=\"!items || (items && items.length); else emptyPlaceholder\">\r\n    <table class=\"table\">\r\n        <thead>\r\n            <tr>\r\n                <th *ngIf=\"isRowSelectedFn\" class=\"align-middle\">\r\n                    <input\r\n                        type=\"checkbox\"\r\n                        clrCheckbox\r\n                        [checked]=\"allSelected\"\r\n                        (change)=\"allSelectChange.emit()\"\r\n                    />\r\n                </th>\r\n                <th *ngFor=\"let header of columns?.toArray()\" class=\"left\" [class.expand]=\"header.expand\">\r\n                    <ng-container *ngTemplateOutlet=\"header.template\"></ng-container>\r\n                </th>\r\n            </tr>\r\n        </thead>\r\n        <tbody>\r\n            <tr\r\n                *ngFor=\"\r\n                    let item of items\r\n                        | paginate\r\n                            : {\r\n                                  itemsPerPage: itemsPerPage,\r\n                                  currentPage: currentPage,\r\n                                  totalItems: totalItems\r\n                              };\r\n                    index as i;\r\n                    trackBy: trackByFn\r\n                \"\r\n            >\r\n                <td *ngIf=\"isRowSelectedFn\" class=\"align-middle\">\r\n                    <input\r\n                        type=\"checkbox\"\r\n                        clrCheckbox\r\n                        [checked]=\"isRowSelectedFn(item)\"\r\n                        (change)=\"rowSelectChange.emit(item)\"\r\n                    />\r\n                </td>\r\n                <ng-container\r\n                    *ngTemplateOutlet=\"rowTemplate; context: { item: item, index: i }\"\r\n                ></ng-container>\r\n            </tr>\r\n        </tbody>\r\n    </table>\r\n    <div class=\"table-footer\">\r\n        <vdr-items-per-page-controls\r\n            *ngIf=\"totalItems\"\r\n            [itemsPerPage]=\"itemsPerPage\"\r\n            (itemsPerPageChange)=\"itemsPerPageChange.emit($event)\"\r\n        ></vdr-items-per-page-controls>\r\n\r\n        <vdr-pagination-controls\r\n            *ngIf=\"totalItems\"\r\n            [currentPage]=\"currentPage\"\r\n            [itemsPerPage]=\"itemsPerPage\"\r\n            [totalItems]=\"totalItems\"\r\n            (pageChange)=\"pageChange.emit($event)\"\r\n        ></vdr-pagination-controls>\r\n    </div>\r\n</ng-container>\r\n<ng-template #emptyPlaceholder>\r\n    <vdr-empty-placeholder [emptyStateLabel]=\"emptyStateLabel\"></vdr-empty-placeholder>\r\n</ng-template>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                providers: [PaginationService],
                styles: [":host{display:block;max-width:100%;overflow:auto}thead th{position:sticky;top:24px;z-index:1}thead th.expand{width:100%}.table-footer{display:flex;align-items:baseline;justify-content:space-between;margin-top:6px}"]
            },] }
];
DataTableComponent.propDecorators = {
    items: [{ type: Input }],
    itemsPerPage: [{ type: Input }],
    currentPage: [{ type: Input }],
    totalItems: [{ type: Input }],
    allSelected: [{ type: Input }],
    isRowSelectedFn: [{ type: Input }],
    emptyStateLabel: [{ type: Input }],
    allSelectChange: [{ type: Output }],
    rowSelectChange: [{ type: Output }],
    pageChange: [{ type: Output }],
    itemsPerPageChange: [{ type: Output }],
    columns: [{ type: ContentChildren, args: [DataTableColumnComponent,] }],
    templateRefs: [{ type: ContentChildren, args: [TemplateRef,] }]
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YS10YWJsZS5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbGliL2NvcmUvc3JjL3NoYXJlZC9jb21wb25lbnRzL2RhdGEtdGFibGUvZGF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