From b688aff2a4d095497ee1744fb2e163e21410c149 Mon Sep 17 00:00:00 2001 From: HunteRoi Date: Fri, 17 Apr 2020 23:57:28 +0200 Subject: [PATCH] Open API for button labels and add aria-labels --- lib/jw-pagination.component.d.ts | 4 +++ lib/jw-pagination.component.js | 59 ++++++++++++++++++++++++-------- src/jw-pagination.component.ts | 49 ++++++++++++++++---------- 3 files changed, 79 insertions(+), 33 deletions(-) diff --git a/lib/jw-pagination.component.d.ts b/lib/jw-pagination.component.d.ts index 1a6d893..630173d 100644 --- a/lib/jw-pagination.component.d.ts +++ b/lib/jw-pagination.component.d.ts @@ -5,6 +5,10 @@ export declare class JwPaginationComponent implements OnInit, OnChanges { initialPage: number; pageSize: number; maxPages: number; + firstButtonLabel: string; + previousButtonLabel: string; + nextButtonLabel: string; + lastButtonLabel: string; pager: any; ngOnInit(): void; ngOnChanges(changes: SimpleChanges): void; diff --git a/lib/jw-pagination.component.js b/lib/jw-pagination.component.js index 9154b57..773079a 100644 --- a/lib/jw-pagination.component.js +++ b/lib/jw-pagination.component.js @@ -1,4 +1,10 @@ "use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var paginate = require("jw-paginate"); @@ -8,6 +14,10 @@ var JwPaginationComponent = /** @class */ (function () { this.initialPage = 1; this.pageSize = 10; this.maxPages = 10; + this.firstButtonLabel = 'First'; + this.previousButtonLabel = 'Previous'; + this.nextButtonLabel = 'Next'; + this.lastButtonLabel = 'Last'; this.pager = {}; } JwPaginationComponent.prototype.ngOnInit = function () { @@ -30,21 +40,40 @@ var JwPaginationComponent = /** @class */ (function () { // call change page function in parent component this.changePage.emit(pageOfItems); }; - JwPaginationComponent.decorators = [ - { type: core_1.Component, args: [{ - moduleId: module.id, - selector: 'jw-pagination', - template: "" - },] }, - ]; - /** @nocollapse */ - JwPaginationComponent.propDecorators = { - "items": [{ type: core_1.Input },], - "changePage": [{ type: core_1.Output },], - "initialPage": [{ type: core_1.Input },], - "pageSize": [{ type: core_1.Input },], - "maxPages": [{ type: core_1.Input },], - }; + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "items", void 0); + __decorate([ + core_1.Output() + ], JwPaginationComponent.prototype, "changePage", void 0); + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "initialPage", void 0); + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "pageSize", void 0); + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "maxPages", void 0); + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "firstButtonLabel", void 0); + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "previousButtonLabel", void 0); + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "nextButtonLabel", void 0); + __decorate([ + core_1.Input() + ], JwPaginationComponent.prototype, "lastButtonLabel", void 0); + JwPaginationComponent = __decorate([ + core_1.Component({ + moduleId: module.id, + selector: 'jw-pagination', + template: "", + }) + ], JwPaginationComponent); return JwPaginationComponent; }()); exports.JwPaginationComponent = JwPaginationComponent; diff --git a/src/jw-pagination.component.ts b/src/jw-pagination.component.ts index f8ccb40..8ac3fbe 100644 --- a/src/jw-pagination.component.ts +++ b/src/jw-pagination.component.ts @@ -6,30 +6,43 @@ import paginate = require('jw-paginate'); moduleId: module.id, selector: 'jw-pagination', template: `` +
  • + + {{ firstButtonLabel }} + +
  • +
  • + + {{ previousItemButton }} + +
  • +
  • + + {{ page }} + +
  • +
  • + + {{ nextItemButton }} + +
  • +
  • + + {{ lastButtonLabel }} + +
  • + `, }) - export class JwPaginationComponent implements OnInit, OnChanges { @Input() items: Array; @Output() changePage = new EventEmitter(true); @Input() initialPage = 1; @Input() pageSize = 10; @Input() maxPages = 10; + @Input() firstButtonLabel = 'First'; + @Input() previousButtonLabel = 'Previous'; + @Input() nextButtonLabel = 'Next'; + @Input() lastButtonLabel = 'Last'; pager: any = {}; @@ -57,4 +70,4 @@ export class JwPaginationComponent implements OnInit, OnChanges { // call change page function in parent component this.changePage.emit(pageOfItems); } -} \ No newline at end of file +}