/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Component, Input, Output, NgModule, Optional, Inject, EventEmitter, HostBinding } from '@angular/core';
import { CurrentResourceStrings } from '../core/i18n/resources';
import { DisplayDensityToken, DisplayDensityBase, DisplayDensity } from '../core/displayDensity';
import { IgxSelectModule } from '../select/index';
import { IgxIconModule } from '../icon/index';
import { IgxButtonModule } from '../directives/button/button.directive';
import { IgxRippleModule } from '../directives/ripple/ripple.directive';
var IgxPaginatorComponent = /** @class */ (function (_super) {
    tslib_1.__extends(IgxPaginatorComponent, _super);
    function IgxPaginatorComponent(_displayDensityOptions) {
        var _this = _super.call(this, _displayDensityOptions) || this;
        _this._displayDensityOptions = _displayDensityOptions;
        _this._page = 0;
        _this.defaultSelectValues = [5, 10, 15, 25, 50, 100, 500];
        _this._perPage = 15;
        /**
         * An \@Input property that sets if the pager in the paginator should be enabled.
         * ```html
         * <igx-paginator [pagerEnabled]="true"></igx-paginator>
         * ```
         * \@memberof IgxPaginatorComponent
         */
        _this.pagerEnabled = true;
        /**
         * An \@Input property that sets if the pager in the paginator should be hidden.
         * ```html
         * <igx-paginator [pagerHidden]="true"></igx-paginator>
         * ```
         * \@memberof IgxPaginatorComponent
         */
        _this.pagerHidden = false;
        /**
         * An \@Input property that sets if the dropdown in the paginator should be enabled.
         * ```html
         * <igx-paginator [dropdownEnabled]="true"></igx-paginator>
         * ```
         * \@memberof IgxPaginatorComponent
         */
        _this.dropdownEnabled = true;
        /**
         * An \@Input property that sets if the dropdown in the paginator should be hidden.
         * ```html
         * <igx-paginator [dropdownHidden]="true"></igx-paginator>
         * ```
         * \@memberof IgxPaginatorComponent
         */
        _this.dropdownHidden = false;
        /**
         * An \@Input property, sets number of label of the select.
         * The default is 'Items per page' localized string.
         * ```html
         * <igx-paginator label="My custom label"></igx-paginator>
         * ```
         * \@memberof IgxPaginatorComponent
         */
        _this.selectLabel = CurrentResourceStrings.GridResStrings.igx_grid_paginator_label;
        /**
         * An event that is emitted when the select in the `IgxPaginatorComponent` changes its value.
         */
        _this.perPageChange = new EventEmitter();
        /**
         * An event that is emitted when the paginating is used.
         */
        _this.pageChange = new EventEmitter();
        return _this;
    }
    Object.defineProperty(IgxPaginatorComponent.prototype, "classCosy", {
        /**
         * Sets the class of the IgxPaginatorComponent based
         * on the provided displayDensity.
         */
        get: /**
         * Sets the class of the IgxPaginatorComponent based
         * on the provided displayDensity.
         * @return {?}
         */
        function () {
            return this.displayDensity === DisplayDensity.cosy;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "classCompact", {
        get: /**
         * @return {?}
         */
        function () {
            return this.displayDensity === DisplayDensity.compact;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "classComfortable", {
        get: /**
         * @return {?}
         */
        function () {
            return this.displayDensity === DisplayDensity.comfortable;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "page", {
        /**
       * An @Input property, sets current page of the `IgxPaginatorComponent`.
       * The default is 0.
       * ```typescript
       * let page = this.paginator.page;
       * ```
       * @memberof IgxPaginatorComponent
       */
        get: /**
         * An \@Input property, sets current page of the `IgxPaginatorComponent`.
         * The default is 0.
         * ```typescript
         * let page = this.paginator.page;
         * ```
         * \@memberof IgxPaginatorComponent
         * @return {?}
         */
        function () {
            return this._page;
        },
        set: /**
         * @param {?} value
         * @return {?}
         */
        function (value) {
            this._page = value;
            this.pageChange.emit(this._page);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "perPage", {
        /**
       * An @Input property, sets number of visible items per page in the `IgxPaginatorComponent`.
       * The default is 15.
       * ```typescript
       * let itemsPerPage = this.paginator.perPage;
       * ```
       * @memberof IgxPaginatorComponent
       */
        get: /**
         * An \@Input property, sets number of visible items per page in the `IgxPaginatorComponent`.
         * The default is 15.
         * ```typescript
         * let itemsPerPage = this.paginator.perPage;
         * ```
         * \@memberof IgxPaginatorComponent
         * @return {?}
         */
        function () {
            return this._perPage;
        },
        set: /**
         * @param {?} value
         * @return {?}
         */
        function (value) {
            this._perPage = Number(value);
            this.perPageChange.emit(this._perPage);
            this._selectOptions = this.sortUniqueOptions(this.defaultSelectValues, this._perPage);
            this.totalPages = Math.ceil(this.totalRecords / this._perPage);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "totalRecords", {
        /**
        * An @Input property that sets the total records.
        * ```typescript
        * let totalRecords = this.paginator.totalRecords;
        * ```
        * @memberof IgxPaginatorComponent
        */
        get: /**
         * An \@Input property that sets the total records.
         * ```typescript
         * let totalRecords = this.paginator.totalRecords;
         * ```
         * \@memberof IgxPaginatorComponent
         * @return {?}
         */
        function () {
            return this._totalRecords;
        },
        set: /**
         * @param {?} value
         * @return {?}
         */
        function (value) {
            this._totalRecords = value;
            this.totalPages = Math.ceil(this.totalRecords / this.perPage);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "selectOptions", {
        /**
        * An @Input property that sets custom options in the select of the paginator
        * ```typescript
        * let options = this.paginator.selectOptions;
        * ```
        * @memberof IgxPaginatorComponent
        */
        get: /**
         * An \@Input property that sets custom options in the select of the paginator
         * ```typescript
         * let options = this.paginator.selectOptions;
         * ```
         * \@memberof IgxPaginatorComponent
         * @return {?}
         */
        function () {
            return this._selectOptions;
        },
        set: /**
         * @param {?} value
         * @return {?}
         */
        function (value) {
            this._selectOptions = this.sortUniqueOptions(value, this._perPage);
            this.defaultSelectValues = tslib_1.__spread(this._selectOptions);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "isLastPage", {
        /**
         * Returns if the current page is the last page.
         * ```typescript
         * const lastPage = this.paginator.isLastPage;
         * ```
         */
        get: /**
         * Returns if the current page is the last page.
         * ```typescript
         * const lastPage = this.paginator.isLastPage;
         * ```
         * @return {?}
         */
        function () {
            return this.page + 1 >= this.totalPages;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPaginatorComponent.prototype, "isFirstPage", {
        /**
         * Returns if the current page is the first page.
         * ```typescript
         * const lastPage = this.paginator.isFirstPage;
         * ```
         */
        get: /**
         * Returns if the current page is the first page.
         * ```typescript
         * const lastPage = this.paginator.isFirstPage;
         * ```
         * @return {?}
         */
        function () {
            return this.page === 0;
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @private
     * @param {?} values
     * @param {?} newOption
     * @return {?}
     */
    IgxPaginatorComponent.prototype.sortUniqueOptions = /**
     * @private
     * @param {?} values
     * @param {?} newOption
     * @return {?}
     */
    function (values, newOption) {
        return Array.from(new Set(tslib_1.__spread(values, [newOption]))).sort(function (a, b) { return a - b; });
    };
    /**
     * @return {?}
     */
    IgxPaginatorComponent.prototype.paginatorSelectDisplayDensity = /**
     * @return {?}
     */
    function () {
        if (this.displayDensity === DisplayDensity.comfortable) {
            return DisplayDensity.cosy;
        }
        return DisplayDensity.compact;
    };
    /**
     * Goes to the next page of the `IgxPaginatorComponent`, if the paginator is not already at the last page.
     * ```typescript
     * this.paginator.nextPage();
     * ```
     * @memberof IgxPaginatorComponent
     */
    /**
     * Goes to the next page of the `IgxPaginatorComponent`, if the paginator is not already at the last page.
     * ```typescript
     * this.paginator.nextPage();
     * ```
     * \@memberof IgxPaginatorComponent
     * @return {?}
     */
    IgxPaginatorComponent.prototype.nextPage = /**
     * Goes to the next page of the `IgxPaginatorComponent`, if the paginator is not already at the last page.
     * ```typescript
     * this.paginator.nextPage();
     * ```
     * \@memberof IgxPaginatorComponent
     * @return {?}
     */
    function () {
        if (!this.isLastPage) {
            this.page += 1;
        }
    };
    /**
     * Goes to the previous page of the `IgxPaginatorComponent`, if the paginator is not already at the first page.
     * ```typescript
     * this.paginator.previousPage();
     * ```
     * @memberof IgxPaginatorComponent
     */
    /**
     * Goes to the previous page of the `IgxPaginatorComponent`, if the paginator is not already at the first page.
     * ```typescript
     * this.paginator.previousPage();
     * ```
     * \@memberof IgxPaginatorComponent
     * @return {?}
     */
    IgxPaginatorComponent.prototype.previousPage = /**
     * Goes to the previous page of the `IgxPaginatorComponent`, if the paginator is not already at the first page.
     * ```typescript
     * this.paginator.previousPage();
     * ```
     * \@memberof IgxPaginatorComponent
     * @return {?}
     */
    function () {
        if (!this.isFirstPage) {
            this.page -= 1;
        }
    };
    /**
     * Goes to the desired page index.
     * ```typescript
     * this.pagiantor.paginate(1);
     * ```
     * @param val
     * @memberof IgxPaginatorComponent
     */
    /**
     * Goes to the desired page index.
     * ```typescript
     * this.pagiantor.paginate(1);
     * ```
     * \@memberof IgxPaginatorComponent
     * @param {?} val
     * @return {?}
     */
    IgxPaginatorComponent.prototype.paginate = /**
     * Goes to the desired page index.
     * ```typescript
     * this.pagiantor.paginate(1);
     * ```
     * \@memberof IgxPaginatorComponent
     * @param {?} val
     * @return {?}
     */
    function (val) {
        if (val < 0 || val > this.totalPages - 1) {
            return;
        }
        this.page = val;
    };
    IgxPaginatorComponent.decorators = [
        { type: Component, args: [{
                    selector: 'igx-paginator',
                    template: "<div class=\"igx-grid-paginator__select\" [hidden]=\"dropdownHidden\">\n    <label class=\"igx-grid-paginator__label\">{{ selectLabel }}</label>\n    <div class=\"igx-grid-paginator__select-input\">\n        <igx-select [(ngModel)]=\"perPage\" [displayDensity]=\"paginatorSelectDisplayDensity()\" type=\"border\"\n            [disabled]=\"!dropdownEnabled\">\n            <igx-select-item [value]=\"val\" *ngFor=\"let val of selectOptions\">\n                {{val}}\n            </igx-select-item>\n        </igx-select>\n    </div>\n</div>\n<div class=\"igx-grid-paginator__pager\" [hidden]=\"pagerHidden\">\n    <button [disabled]=\"isFirstPage || !pagerEnabled ? true: false\" (click)=\"paginate(0)\" igxButton=\"icon\" igxRipple igxRippleCentered=\"true\">\n        <igx-icon fontSet=\"material\">first_page</igx-icon>\n    </button>\n    <button [disabled]=\"isFirstPage || !pagerEnabled ? true: false\" (click)=\"previousPage()\" igxButton=\"icon\" igxRipple igxRippleCentered=\"true\">\n        <igx-icon fontSet=\"material\">chevron_left</igx-icon>\n    </button>\n    <span>{{ page + 1 }} of {{ totalPages }}</span>\n    <button [disabled]=\"isLastPage || !pagerEnabled ? true: false\" (click)=\"nextPage()\" igxRipple igxRippleCentered=\"true\" igxButton=\"icon\">\n        <igx-icon fontSet=\"material\">chevron_right</igx-icon>\n    </button>\n    <button [disabled]=\"isLastPage || !pagerEnabled ? true: false\" (click)=\"paginate(totalPages - 1)\" igxButton=\"icon\" igxRipple\n        igxRippleCentered=\"true\">\n        <igx-icon fontSet=\"material\">last_page</igx-icon>\n    </button>\n</div>"
                }] }
    ];
    /** @nocollapse */
    IgxPaginatorComponent.ctorParameters = function () { return [
        { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DisplayDensityToken,] }] }
    ]; };
    IgxPaginatorComponent.propDecorators = {
        classCosy: [{ type: HostBinding, args: ['class.igx-grid-paginator--cosy',] }],
        classCompact: [{ type: HostBinding, args: ['class.igx-grid-paginator--compact',] }],
        classComfortable: [{ type: HostBinding, args: ['class.igx-grid-paginator',] }],
        page: [{ type: Input }],
        perPage: [{ type: Input }],
        totalRecords: [{ type: Input }],
        selectOptions: [{ type: Input }],
        pagerEnabled: [{ type: Input }],
        pagerHidden: [{ type: Input }],
        dropdownEnabled: [{ type: Input }],
        dropdownHidden: [{ type: Input }],
        selectLabel: [{ type: Input }],
        perPageChange: [{ type: Output }],
        pageChange: [{ type: Output }]
    };
    return IgxPaginatorComponent;
}(DisplayDensityBase));
export { IgxPaginatorComponent };
if (false) {
    /**
     * Total pages calculated from totalRecords and perPage
     * @type {?}
     */
    IgxPaginatorComponent.prototype.totalPages;
    /**
     * @type {?}
     * @protected
     */
    IgxPaginatorComponent.prototype._page;
    /**
     * @type {?}
     * @protected
     */
    IgxPaginatorComponent.prototype._totalRecords;
    /**
     * @type {?}
     * @protected
     */
    IgxPaginatorComponent.prototype._selectOptions;
    /**
     * @type {?}
     * @private
     */
    IgxPaginatorComponent.prototype.defaultSelectValues;
    /**
     * @type {?}
     * @protected
     */
    IgxPaginatorComponent.prototype._perPage;
    /**
     * An \@Input property that sets if the pager in the paginator should be enabled.
     * ```html
     * <igx-paginator [pagerEnabled]="true"></igx-paginator>
     * ```
     * \@memberof IgxPaginatorComponent
     * @type {?}
     */
    IgxPaginatorComponent.prototype.pagerEnabled;
    /**
     * An \@Input property that sets if the pager in the paginator should be hidden.
     * ```html
     * <igx-paginator [pagerHidden]="true"></igx-paginator>
     * ```
     * \@memberof IgxPaginatorComponent
     * @type {?}
     */
    IgxPaginatorComponent.prototype.pagerHidden;
    /**
     * An \@Input property that sets if the dropdown in the paginator should be enabled.
     * ```html
     * <igx-paginator [dropdownEnabled]="true"></igx-paginator>
     * ```
     * \@memberof IgxPaginatorComponent
     * @type {?}
     */
    IgxPaginatorComponent.prototype.dropdownEnabled;
    /**
     * An \@Input property that sets if the dropdown in the paginator should be hidden.
     * ```html
     * <igx-paginator [dropdownHidden]="true"></igx-paginator>
     * ```
     * \@memberof IgxPaginatorComponent
     * @type {?}
     */
    IgxPaginatorComponent.prototype.dropdownHidden;
    /**
     * An \@Input property, sets number of label of the select.
     * The default is 'Items per page' localized string.
     * ```html
     * <igx-paginator label="My custom label"></igx-paginator>
     * ```
     * \@memberof IgxPaginatorComponent
     * @type {?}
     */
    IgxPaginatorComponent.prototype.selectLabel;
    /**
     * An event that is emitted when the select in the `IgxPaginatorComponent` changes its value.
     * @type {?}
     */
    IgxPaginatorComponent.prototype.perPageChange;
    /**
     * An event that is emitted when the paginating is used.
     * @type {?}
     */
    IgxPaginatorComponent.prototype.pageChange;
    /**
     * @type {?}
     * @protected
     */
    IgxPaginatorComponent.prototype._displayDensityOptions;
}
var IgxPaginatorModule = /** @class */ (function () {
    function IgxPaginatorModule() {
    }
    IgxPaginatorModule.decorators = [
        { type: NgModule, args: [{
                    declarations: [IgxPaginatorComponent],
                    exports: [IgxPaginatorComponent],
                    imports: [CommonModule, IgxSelectModule, FormsModule, IgxIconModule, IgxButtonModule, IgxRippleModule]
                },] }
    ];
    return IgxPaginatorModule;
}());
export { IgxPaginatorModule };
//# sourceMappingURL=data:application/json;base64, 