@colijnit/corecomponents_v12 12.0.46 → 12.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/colijnit-corecomponents_v12.umd.js +421 -13
- package/bundles/colijnit-corecomponents_v12.umd.js.map +1 -1
- package/colijnit-corecomponents_v12.d.ts +2 -0
- package/colijnit-corecomponents_v12.metadata.json +1 -1
- package/esm2015/colijnit-corecomponents_v12.js +3 -1
- package/esm2015/lib/components/base/base-input.component.js +2 -2
- package/esm2015/lib/components/drop-down-list/drop-down-list.component.js +8 -1
- package/esm2015/lib/components/input-date-range-picker/input-date-range-picker.component.js +2 -1
- package/esm2015/lib/components/input-search/input-search.component.js +15 -7
- package/esm2015/lib/components/input-text/input-text.component.js +2 -2
- package/esm2015/lib/components/pagination/paginate.pipe.js +106 -0
- package/esm2015/lib/components/pagination/pagination-instance.js +2 -0
- package/esm2015/lib/components/pagination/pagination.component.js +194 -0
- package/esm2015/lib/components/pagination/pagination.module.js +26 -0
- package/esm2015/lib/components/pagination/pagination.service.js +88 -0
- package/esm2015/lib/components/simple-grid/simple-grid-cell.component.js +1 -4
- package/esm2015/lib/core/interface/filter-item-viewmodel.js +1 -1
- package/esm2015/public-api.js +3 -1
- package/fesm2015/colijnit-corecomponents_v12.js +426 -13
- package/fesm2015/colijnit-corecomponents_v12.js.map +1 -1
- package/lib/components/drop-down-list/drop-down-list.component.d.ts +3 -0
- package/lib/components/input-search/input-search.component.d.ts +2 -2
- package/lib/components/input-text/style/_layout.scss +5 -2
- package/lib/components/pagination/paginate.pipe.d.ts +18 -0
- package/lib/components/pagination/pagination-instance.d.ts +14 -0
- package/lib/components/pagination/pagination.component.d.ts +46 -0
- package/lib/components/pagination/pagination.module.d.ts +2 -0
- package/lib/components/pagination/pagination.service.d.ts +24 -0
- package/lib/components/pagination/style/_layout.scss +87 -0
- package/lib/components/pagination/style/_material-definition.scss +6 -0
- package/lib/components/pagination/style/_theme.scss +5 -0
- package/lib/components/pagination/style/material.scss +5 -0
- package/lib/components/simple-grid/simple-grid-cell.component.d.ts +2 -3
- package/lib/core/interface/filter-item-viewmodel.d.ts +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -4900,7 +4900,7 @@
|
|
|
4900
4900
|
break;
|
|
4901
4901
|
}
|
|
4902
4902
|
else if (node.children.length > 0) {
|
|
4903
|
-
this._findInputNode(node.children);
|
|
4903
|
+
return this._findInputNode(node.children);
|
|
4904
4904
|
}
|
|
4905
4905
|
}
|
|
4906
4906
|
};
|
|
@@ -5394,6 +5394,7 @@
|
|
|
5394
5394
|
* Where 'text' is showing in the dropdown and 'id' used for the model binding
|
|
5395
5395
|
*/
|
|
5396
5396
|
_this.fields = {};
|
|
5397
|
+
_this.allowFiltering = false;
|
|
5397
5398
|
_super.prototype._markAsOnPush.call(_this);
|
|
5398
5399
|
return _this;
|
|
5399
5400
|
}
|
|
@@ -5410,7 +5411,7 @@
|
|
|
5410
5411
|
DropDownListComponent.decorators = [
|
|
5411
5412
|
{ type: core.Component, args: [{
|
|
5412
5413
|
selector: "co-drop-down-list",
|
|
5413
|
-
template: "\n <ejs-dropdownlist\n [dataSource]=\"collection\"\n [value]=\"model\"\n [fields]=\"fields\"\n [placeholder]=\"placeholder\"\n [readonly]=\"readonly\"\n [itemTemplate]=\"itemTemplate\"\n [headerTemplate]=\"headerTemplate\"\n [valueTemplate]=\"valueTemplate\"\n [disabled]=\"disabled\"\n [ngModel]=\"model\"\n (ngModelChange)=\"modelChange.emit($event)\"\n (valueChange)=\"handleValueChanged($event)\"\n showClearButton=\"true\"\n floatLabelType=\"Auto\"\n >\n </ejs-dropdownlist>\n <div class=\"required-indicator\"></div>\n <ng-template #validationError></ng-template>\n ",
|
|
5414
|
+
template: "\n <ejs-dropdownlist\n [dataSource]=\"collection\"\n [allowFiltering]=\"allowFiltering\"\n [value]=\"model\"\n [fields]=\"fields\"\n [filterBarPlaceholder]=\"filterBarPlaceholder\"\n [filterType]=\"filterType\"\n [placeholder]=\"placeholder\"\n [readonly]=\"readonly\"\n [itemTemplate]=\"itemTemplate\"\n [headerTemplate]=\"headerTemplate\"\n [valueTemplate]=\"valueTemplate\"\n [disabled]=\"disabled\"\n [ngModel]=\"model\"\n (ngModelChange)=\"modelChange.emit($event)\"\n (valueChange)=\"handleValueChanged($event)\"\n showClearButton=\"true\"\n floatLabelType=\"Auto\"\n >\n </ejs-dropdownlist>\n <div class=\"required-indicator\"></div>\n <ng-template #validationError></ng-template>\n ",
|
|
5414
5415
|
providers: [
|
|
5415
5416
|
ej2AngularDropdowns.CheckBoxSelectionService,
|
|
5416
5417
|
{
|
|
@@ -5436,6 +5437,9 @@
|
|
|
5436
5437
|
collection: [{ type: core.Input }],
|
|
5437
5438
|
fields: [{ type: core.Input }],
|
|
5438
5439
|
placeholder: [{ type: core.Input }],
|
|
5440
|
+
allowFiltering: [{ type: core.Input }],
|
|
5441
|
+
filterBarPlaceholder: [{ type: core.Input }],
|
|
5442
|
+
filterType: [{ type: core.Input }],
|
|
5439
5443
|
itemTemplate: [{ type: core.Input }],
|
|
5440
5444
|
headerTemplate: [{ type: core.Input }],
|
|
5441
5445
|
valueTemplate: [{ type: core.Input }],
|
|
@@ -6430,7 +6434,7 @@
|
|
|
6430
6434
|
InputDateRangePickerComponent.decorators = [
|
|
6431
6435
|
{ type: core.Component, args: [{
|
|
6432
6436
|
selector: "co-input-date-range",
|
|
6433
|
-
template: "\n <ejs-daterangepicker\n [format]=\"dateFormat\"\n [placeholder]=\"placeholder\"\n [ngModel]=\"model\"\n (ngModelChange)=\"rangeChange()\"\n (close)=\"close.next($event)\"\n (select)=\"select.next($event)\"\n (cleared)=\"cleared.next($event)\"\n [(startDate)]=\"startDate\"\n [(endDate)]=\"endDate\"\n ></ejs-daterangepicker>\n <div class=\"required-indicator\"></div>\n <ng-template #validationError></ng-template>\n ",
|
|
6437
|
+
template: "\n <ejs-daterangepicker\n floatLabelType=\"Auto\"\n [format]=\"dateFormat\"\n [placeholder]=\"placeholder\"\n [ngModel]=\"model\"\n (ngModelChange)=\"rangeChange()\"\n (close)=\"close.next($event)\"\n (select)=\"select.next($event)\"\n (cleared)=\"cleared.next($event)\"\n [(startDate)]=\"startDate\"\n [(endDate)]=\"endDate\"\n ></ejs-daterangepicker>\n <div class=\"required-indicator\"></div>\n <ng-template #validationError></ng-template>\n ",
|
|
6434
6438
|
encapsulation: core.ViewEncapsulation.None
|
|
6435
6439
|
},] }
|
|
6436
6440
|
];
|
|
@@ -7261,7 +7265,7 @@
|
|
|
7261
7265
|
InputTextComponent.decorators = [
|
|
7262
7266
|
{ type: core.Component, args: [{
|
|
7263
7267
|
selector: "co-input-text",
|
|
7264
|
-
template: "\n <label *ngIf=\"showPlaceholderOnFocus || (!showPlaceholderOnFocus && !hasValue && !focused)\" [textContent]=\"placeholder\"></label>\n <co-icon *ngIf=\"leftIcon\" class=\"input-text-left-icon\" [icon]=\"leftIcon\"></co-icon>\n <input #input\n [type]=\"type\"\n [ngModel]=\"model\"\n [min]=\"type === 'number' && this.min ? this.min : undefined\"\n [max]=\"type === 'number' && this.max ? this.max : undefined\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n (ngModelChange)=\"modelChange.emit($event)\"\n >\n <co-
|
|
7268
|
+
template: "\n <label *ngIf=\"showPlaceholderOnFocus || (!showPlaceholderOnFocus && !hasValue && !focused)\" [textContent]=\"placeholder\"></label>\n <co-icon *ngIf=\"leftIcon\" class=\"input-text-left-icon\" [icon]=\"leftIcon\"></co-icon>\n <co-icon *ngIf=\"rightIcon\" class=\"input-text-right-icon\" [icon]=\"rightIcon\"></co-icon>\n <input #input\n [type]=\"type\"\n [ngModel]=\"model\"\n [min]=\"type === 'number' && this.min ? this.min : undefined\"\n [max]=\"type === 'number' && this.max ? this.max : undefined\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n (ngModelChange)=\"modelChange.emit($event)\"\n >\n <co-commit-buttons *ngIf=\"showSaveCancel && focused && canSaveOrCancel\"\n [committing]=\"committing\"\n [commitFinished]=\"commitFinished\"\n (commitClick)=\"commitClick($event)\"\n (cancelClick)=\"cancelClick($event)\"\n >\n </co-commit-buttons>\n <div class=\"required-indicator\"></div>\n <ng-template #validationError></ng-template>\n ",
|
|
7265
7269
|
providers: [{
|
|
7266
7270
|
provide: COMPONENT_INTERFACE_NAME,
|
|
7267
7271
|
useExisting: core.forwardRef(function () { return InputTextComponent; })
|
|
@@ -7547,9 +7551,9 @@
|
|
|
7547
7551
|
function InputSearchComponent() {
|
|
7548
7552
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
7549
7553
|
_this.searchIcon = exports.CoreComponentsIcon.Magnifier;
|
|
7550
|
-
_this.iconRight = false;
|
|
7551
|
-
_this.noIcon = false;
|
|
7552
7554
|
_this.search = new core.EventEmitter();
|
|
7555
|
+
_this.useLeftIcon = false;
|
|
7556
|
+
_this.useRightIcon = false;
|
|
7553
7557
|
return _this;
|
|
7554
7558
|
}
|
|
7555
7559
|
InputSearchComponent.prototype.showClass = function () {
|
|
@@ -7568,18 +7572,24 @@
|
|
|
7568
7572
|
InputSearchComponent.decorators = [
|
|
7569
7573
|
{ type: core.Component, args: [{
|
|
7570
7574
|
selector: 'co-input-search',
|
|
7571
|
-
template: "\n <co-input-text\n [model]=\"model\"\n [leftIcon]=\"
|
|
7575
|
+
template: "\n <co-input-text\n [model]=\"model\"\n [leftIcon]=\"useLeftIcon ? searchIcon : null\"\n [rightIcon]=\"useRightIcon ? searchIcon : null\"\n [placeholder]=\"placeholder\"\n [showPlaceholderOnFocus]=\"false\"\n (modelChange)=\"modelChange.emit($event)\"\n ></co-input-text>\n ",
|
|
7572
7576
|
changeDetection: core.ChangeDetectionStrategy.OnPush,
|
|
7573
7577
|
encapsulation: core.ViewEncapsulation.None
|
|
7574
7578
|
},] }
|
|
7575
7579
|
];
|
|
7576
7580
|
InputSearchComponent.propDecorators = {
|
|
7577
7581
|
placeholder: [{ type: core.Input }],
|
|
7578
|
-
iconRight: [{ type: core.Input }],
|
|
7579
|
-
noIcon: [{ type: core.HostBinding, args: ['class.no-icon',] }, { type: core.Input }],
|
|
7580
7582
|
search: [{ type: core.Output }],
|
|
7583
|
+
useLeftIcon: [{ type: core.Input }],
|
|
7584
|
+
useRightIcon: [{ type: core.Input }],
|
|
7581
7585
|
showClass: [{ type: core.HostBinding, args: ['class.co-input-search',] }]
|
|
7582
|
-
};
|
|
7586
|
+
};
|
|
7587
|
+
__decorate([
|
|
7588
|
+
InputBoolean()
|
|
7589
|
+
], InputSearchComponent.prototype, "useLeftIcon", void 0);
|
|
7590
|
+
__decorate([
|
|
7591
|
+
InputBoolean()
|
|
7592
|
+
], InputSearchComponent.prototype, "useRightIcon", void 0);
|
|
7583
7593
|
|
|
7584
7594
|
var InputSearchModule = /** @class */ (function () {
|
|
7585
7595
|
function InputSearchModule() {
|
|
@@ -9848,9 +9858,6 @@
|
|
|
9848
9858
|
this.cellClick.next();
|
|
9849
9859
|
}
|
|
9850
9860
|
};
|
|
9851
|
-
SimpleGridCellComponent.prototype.ngOnChanges = function (changes) {
|
|
9852
|
-
console.log(changes);
|
|
9853
|
-
};
|
|
9854
9861
|
SimpleGridCellComponent.prototype._setFocusComponent = function () {
|
|
9855
9862
|
if (this.editMode && this.fieldEditMode) {
|
|
9856
9863
|
var element = this._getElement();
|
|
@@ -10518,6 +10525,403 @@
|
|
|
10518
10525
|
},] }
|
|
10519
10526
|
];
|
|
10520
10527
|
|
|
10528
|
+
var PaginationService = /** @class */ (function () {
|
|
10529
|
+
function PaginationService() {
|
|
10530
|
+
this.change = new rxjs.Subject();
|
|
10531
|
+
this.instances = {};
|
|
10532
|
+
}
|
|
10533
|
+
Object.defineProperty(PaginationService.prototype, "DEFAULT_ID", {
|
|
10534
|
+
get: function () {
|
|
10535
|
+
return PaginationService.DEFAULT_ID;
|
|
10536
|
+
},
|
|
10537
|
+
enumerable: false,
|
|
10538
|
+
configurable: true
|
|
10539
|
+
});
|
|
10540
|
+
PaginationService.prototype.register = function (instance) {
|
|
10541
|
+
if (!instance.id) {
|
|
10542
|
+
instance.id = PaginationService.DEFAULT_ID;
|
|
10543
|
+
}
|
|
10544
|
+
if (!this.instances[instance.id]) {
|
|
10545
|
+
this.instances[instance.id] = instance;
|
|
10546
|
+
this.change.next(instance.id);
|
|
10547
|
+
}
|
|
10548
|
+
else {
|
|
10549
|
+
var changed = this.updateInstance(instance);
|
|
10550
|
+
if (changed) {
|
|
10551
|
+
this.change.next(instance.id);
|
|
10552
|
+
}
|
|
10553
|
+
}
|
|
10554
|
+
};
|
|
10555
|
+
// Returns the current page number.
|
|
10556
|
+
PaginationService.prototype.getCurrentPage = function (id) {
|
|
10557
|
+
if (this.instances[id]) {
|
|
10558
|
+
return this.instances[id].currentPage;
|
|
10559
|
+
}
|
|
10560
|
+
};
|
|
10561
|
+
// Sets the current page number.
|
|
10562
|
+
PaginationService.prototype.setCurrentPage = function (id, page) {
|
|
10563
|
+
if (this.instances[id]) {
|
|
10564
|
+
var instance = this.instances[id];
|
|
10565
|
+
var maxPage = Math.ceil(instance.totalItems / instance.itemsPerPage);
|
|
10566
|
+
if (page <= maxPage && 1 <= page) {
|
|
10567
|
+
this.instances[id].currentPage = page;
|
|
10568
|
+
this.change.next(id);
|
|
10569
|
+
}
|
|
10570
|
+
}
|
|
10571
|
+
};
|
|
10572
|
+
// Sets the value of instance.totalItems
|
|
10573
|
+
PaginationService.prototype.setTotalItems = function (id, totalItems) {
|
|
10574
|
+
if (this.instances[id] && 0 <= totalItems) {
|
|
10575
|
+
this.instances[id].totalItems = totalItems;
|
|
10576
|
+
this.change.next(id);
|
|
10577
|
+
}
|
|
10578
|
+
};
|
|
10579
|
+
// Sets the value of instance.itemsPerPage.
|
|
10580
|
+
PaginationService.prototype.setItemsPerPage = function (id, itemsPerPage) {
|
|
10581
|
+
if (this.instances[id]) {
|
|
10582
|
+
this.instances[id].itemsPerPage = itemsPerPage;
|
|
10583
|
+
this.change.next(id);
|
|
10584
|
+
}
|
|
10585
|
+
};
|
|
10586
|
+
/**
|
|
10587
|
+
* Returns a clone of the pagination instance object matching the id. If no
|
|
10588
|
+
* id specified, returns the instance corresponding to the default id.
|
|
10589
|
+
*/
|
|
10590
|
+
PaginationService.prototype.getInstance = function (id) {
|
|
10591
|
+
if (id === void 0) { id = PaginationService.DEFAULT_ID; }
|
|
10592
|
+
if (this.instances[id]) {
|
|
10593
|
+
return ObjectUtils.GetShallowClone(this.instances[id]);
|
|
10594
|
+
}
|
|
10595
|
+
return {};
|
|
10596
|
+
};
|
|
10597
|
+
/**
|
|
10598
|
+
* Check each property of the instance and update any that have changed. Return
|
|
10599
|
+
* true if any changes were made, else return false.
|
|
10600
|
+
*/
|
|
10601
|
+
PaginationService.prototype.updateInstance = function (instance) {
|
|
10602
|
+
var changed = false;
|
|
10603
|
+
for (var prop in this.instances[instance.id]) {
|
|
10604
|
+
if (instance[prop] !== this.instances[instance.id][prop]) {
|
|
10605
|
+
this.instances[instance.id][prop] = instance[prop];
|
|
10606
|
+
changed = true;
|
|
10607
|
+
}
|
|
10608
|
+
}
|
|
10609
|
+
return changed;
|
|
10610
|
+
};
|
|
10611
|
+
return PaginationService;
|
|
10612
|
+
}());
|
|
10613
|
+
PaginationService.DEFAULT_ID = "DEFAULT_PAGINATION_ID";
|
|
10614
|
+
PaginationService.decorators = [
|
|
10615
|
+
{ type: core.Injectable }
|
|
10616
|
+
];
|
|
10617
|
+
PaginationService.ctorParameters = function () { return []; };
|
|
10618
|
+
|
|
10619
|
+
var PaginationComponent = /** @class */ (function () {
|
|
10620
|
+
function PaginationComponent(_paginationService) {
|
|
10621
|
+
var _this = this;
|
|
10622
|
+
this._paginationService = _paginationService;
|
|
10623
|
+
this.maxSize = 7;
|
|
10624
|
+
this.directionLinks = true;
|
|
10625
|
+
this.previousLabel = 'Vorige pagina';
|
|
10626
|
+
this.nextLabel = 'Volgende pagina';
|
|
10627
|
+
this.autoHide = false;
|
|
10628
|
+
// Emits the new page number.
|
|
10629
|
+
this.pageChange = new core.EventEmitter();
|
|
10630
|
+
this.showClass = true;
|
|
10631
|
+
this.pages = [];
|
|
10632
|
+
this.changeSub = this._paginationService.change.subscribe(function (id) {
|
|
10633
|
+
if (_this.id === id) {
|
|
10634
|
+
_this._updatePageLinks();
|
|
10635
|
+
}
|
|
10636
|
+
});
|
|
10637
|
+
}
|
|
10638
|
+
PaginationComponent.prototype.ngOnInit = function () {
|
|
10639
|
+
if (!this.id) {
|
|
10640
|
+
this.id = this._paginationService.DEFAULT_ID;
|
|
10641
|
+
}
|
|
10642
|
+
this._updatePageLinks();
|
|
10643
|
+
};
|
|
10644
|
+
PaginationComponent.prototype.ngOnChanges = function () {
|
|
10645
|
+
this._updatePageLinks();
|
|
10646
|
+
};
|
|
10647
|
+
PaginationComponent.prototype.ngOnDestroy = function () {
|
|
10648
|
+
this.changeSub.unsubscribe();
|
|
10649
|
+
};
|
|
10650
|
+
PaginationComponent.prototype.goToFirstPage = function () {
|
|
10651
|
+
if (!this.isOnFirstPage()) {
|
|
10652
|
+
this.setCurrentPage(1);
|
|
10653
|
+
}
|
|
10654
|
+
};
|
|
10655
|
+
PaginationComponent.prototype.goToPreviousPage = function () {
|
|
10656
|
+
if (!this.isOnFirstPage()) {
|
|
10657
|
+
this.setCurrentPage(this.getCurrentPage() - 1);
|
|
10658
|
+
}
|
|
10659
|
+
};
|
|
10660
|
+
PaginationComponent.prototype.goToNextPage = function () {
|
|
10661
|
+
if (!this.isOnLastPage()) {
|
|
10662
|
+
this.setCurrentPage(this.getCurrentPage() + 1);
|
|
10663
|
+
}
|
|
10664
|
+
};
|
|
10665
|
+
PaginationComponent.prototype.setCurrentPage = function (page) {
|
|
10666
|
+
this.pageChange.emit(page);
|
|
10667
|
+
};
|
|
10668
|
+
PaginationComponent.prototype.isOnFirstPage = function () {
|
|
10669
|
+
return this.getCurrentPage() === 1;
|
|
10670
|
+
};
|
|
10671
|
+
PaginationComponent.prototype.isOnLastPage = function () {
|
|
10672
|
+
return this.getLastPage() === this.getCurrentPage();
|
|
10673
|
+
};
|
|
10674
|
+
PaginationComponent.prototype.shouldBeHidden = function () {
|
|
10675
|
+
if (!this.autoHide) {
|
|
10676
|
+
return false;
|
|
10677
|
+
}
|
|
10678
|
+
else {
|
|
10679
|
+
var instance = this._paginationService.getInstance();
|
|
10680
|
+
return (instance.totalItems <= instance.itemsPerPage);
|
|
10681
|
+
}
|
|
10682
|
+
};
|
|
10683
|
+
/**
|
|
10684
|
+
* Updates the page links and checks that the current page is valid. Should run whenever the
|
|
10685
|
+
* PaginationService.change stream emits a value matching the current ID, or when any of the
|
|
10686
|
+
* input values changes.
|
|
10687
|
+
*/
|
|
10688
|
+
PaginationComponent.prototype._updatePageLinks = function () {
|
|
10689
|
+
var paginationInstance = this._paginationService.getInstance(this.id);
|
|
10690
|
+
this.pages = this.createPageArray(paginationInstance.currentPage, paginationInstance.itemsPerPage, paginationInstance.totalItems, this.maxSize);
|
|
10691
|
+
var correctedCurrentPage = this.outOfBoundCorrection(paginationInstance);
|
|
10692
|
+
if (correctedCurrentPage !== paginationInstance.currentPage) {
|
|
10693
|
+
this.setCurrentPage(correctedCurrentPage);
|
|
10694
|
+
}
|
|
10695
|
+
};
|
|
10696
|
+
PaginationComponent.prototype.getCurrentPage = function () {
|
|
10697
|
+
return this._paginationService.getCurrentPage(this.id);
|
|
10698
|
+
};
|
|
10699
|
+
PaginationComponent.prototype.getLastPage = function () {
|
|
10700
|
+
var instance = this._paginationService.getInstance(this.id);
|
|
10701
|
+
return Math.ceil(instance.totalItems / instance.itemsPerPage);
|
|
10702
|
+
};
|
|
10703
|
+
/**
|
|
10704
|
+
* Checks that the instance.currentPage property is within bounds for the current page range.
|
|
10705
|
+
* If not, return a correct value for currentPage, or the current value if OK.
|
|
10706
|
+
*/
|
|
10707
|
+
PaginationComponent.prototype.outOfBoundCorrection = function (instance) {
|
|
10708
|
+
var totalPages = Math.ceil(instance.totalItems / instance.itemsPerPage);
|
|
10709
|
+
if (totalPages < instance.currentPage && 0 < totalPages) {
|
|
10710
|
+
return totalPages;
|
|
10711
|
+
}
|
|
10712
|
+
else if (instance.currentPage < 1) {
|
|
10713
|
+
return 1;
|
|
10714
|
+
}
|
|
10715
|
+
return instance.currentPage;
|
|
10716
|
+
};
|
|
10717
|
+
// Returns an array of IPage objects to use in the pagination controls.
|
|
10718
|
+
PaginationComponent.prototype.createPageArray = function (currentPage, itemsPerPage, totalItems, paginationRange) {
|
|
10719
|
+
// paginationRange could be a string if passed from attribute, so cast to number.
|
|
10720
|
+
paginationRange = +paginationRange;
|
|
10721
|
+
var pages = [];
|
|
10722
|
+
var totalPages = Math.ceil(totalItems / itemsPerPage);
|
|
10723
|
+
var halfWay = Math.ceil(paginationRange / 2);
|
|
10724
|
+
var isStart = currentPage <= halfWay;
|
|
10725
|
+
var isEnd = totalPages - halfWay < currentPage;
|
|
10726
|
+
var isMiddle = !isStart && !isEnd;
|
|
10727
|
+
var ellipsesNeeded = paginationRange < totalPages;
|
|
10728
|
+
var i = 1;
|
|
10729
|
+
while (i <= totalPages && i <= paginationRange) {
|
|
10730
|
+
var label = void 0;
|
|
10731
|
+
var pageNumber = this.calculatePageNumber(i, currentPage, paginationRange, totalPages);
|
|
10732
|
+
var openingEllipsesNeeded = (i === 2 && (isMiddle || isEnd));
|
|
10733
|
+
var closingEllipsesNeeded = (i === paginationRange - 1 && (isMiddle || isStart));
|
|
10734
|
+
if (ellipsesNeeded && (openingEllipsesNeeded || closingEllipsesNeeded)) {
|
|
10735
|
+
label = '...';
|
|
10736
|
+
}
|
|
10737
|
+
else {
|
|
10738
|
+
label = '' + pageNumber;
|
|
10739
|
+
}
|
|
10740
|
+
pages.push({
|
|
10741
|
+
label: label,
|
|
10742
|
+
value: pageNumber
|
|
10743
|
+
});
|
|
10744
|
+
i++;
|
|
10745
|
+
}
|
|
10746
|
+
return pages;
|
|
10747
|
+
};
|
|
10748
|
+
// Given the position in the sequence of pagination links [i], figure out what page number corresponds to that position.
|
|
10749
|
+
PaginationComponent.prototype.calculatePageNumber = function (i, currentPage, paginationRange, totalPages) {
|
|
10750
|
+
var halfWay = Math.ceil(paginationRange / 2);
|
|
10751
|
+
if (i === paginationRange) {
|
|
10752
|
+
return totalPages;
|
|
10753
|
+
}
|
|
10754
|
+
else if (i === 1) {
|
|
10755
|
+
return i;
|
|
10756
|
+
}
|
|
10757
|
+
else if (paginationRange < totalPages) {
|
|
10758
|
+
if (totalPages - halfWay < currentPage) {
|
|
10759
|
+
return totalPages - paginationRange + i;
|
|
10760
|
+
}
|
|
10761
|
+
else if (halfWay < currentPage) {
|
|
10762
|
+
return currentPage - halfWay + i;
|
|
10763
|
+
}
|
|
10764
|
+
else {
|
|
10765
|
+
return i;
|
|
10766
|
+
}
|
|
10767
|
+
}
|
|
10768
|
+
else {
|
|
10769
|
+
return i;
|
|
10770
|
+
}
|
|
10771
|
+
};
|
|
10772
|
+
return PaginationComponent;
|
|
10773
|
+
}());
|
|
10774
|
+
PaginationComponent.decorators = [
|
|
10775
|
+
{ type: core.Component, args: [{
|
|
10776
|
+
selector: 'co-pagination',
|
|
10777
|
+
template: "\n <div class=\"pagination-component-main-wrapper\" *ngIf=\"!shouldBeHidden()\">\n <div>\n <ng-content></ng-content>\n </div>\n <ul class=\"pagination\">\n <li *ngIf=\"directionLinks\" class=\"pagination-previous\">\n <a (click)=\"goToPreviousPage()\" [class.disabled]=\"isOnFirstPage()\">{{ previousLabel }}</a>\n </li>\n <li *ngFor=\"let page of pages\" [class.current]=\"getCurrentPage() === page.value\" (click)=\"setCurrentPage(page.value)\">\n <span>{{page.label}}</span>\n </li>\n <li *ngIf=\"directionLinks\" class=\"pagination-next\">\n <a (click)=\"goToNextPage()\" [class.disabled]=\"isOnLastPage()\">{{ nextLabel }}</a>\n </li>\n </ul>\n </div>\n ",
|
|
10778
|
+
encapsulation: core.ViewEncapsulation.None
|
|
10779
|
+
},] }
|
|
10780
|
+
];
|
|
10781
|
+
PaginationComponent.ctorParameters = function () { return [
|
|
10782
|
+
{ type: PaginationService }
|
|
10783
|
+
]; };
|
|
10784
|
+
PaginationComponent.propDecorators = {
|
|
10785
|
+
template: [{ type: core.ViewChild, args: ['template',] }],
|
|
10786
|
+
id: [{ type: core.Input }],
|
|
10787
|
+
maxSize: [{ type: core.Input }],
|
|
10788
|
+
directionLinks: [{ type: core.Input }],
|
|
10789
|
+
previousLabel: [{ type: core.Input }],
|
|
10790
|
+
nextLabel: [{ type: core.Input }],
|
|
10791
|
+
autoHide: [{ type: core.Input }],
|
|
10792
|
+
pageChange: [{ type: core.Output }],
|
|
10793
|
+
showClass: [{ type: core.HostBinding, args: ['class.co-pagination',] }]
|
|
10794
|
+
};
|
|
10795
|
+
|
|
10796
|
+
var LARGE_NUMBER = 999999999;
|
|
10797
|
+
var PaginatePipe = /** @class */ (function () {
|
|
10798
|
+
function PaginatePipe(paginateService) {
|
|
10799
|
+
this.paginateService = paginateService;
|
|
10800
|
+
// store the values from the last time the pipe
|
|
10801
|
+
this.state = {};
|
|
10802
|
+
}
|
|
10803
|
+
PaginatePipe.prototype.transform = function (collection, args) {
|
|
10804
|
+
// When an observable is passed through the AsyncPipe, it will output
|
|
10805
|
+
// `null` until the subscription resolves. In this case, we want to
|
|
10806
|
+
// use the cached data from the `state` object to prevent the NgFor
|
|
10807
|
+
// from flashing empty until the real values arrive.
|
|
10808
|
+
if (!(collection instanceof Array)) {
|
|
10809
|
+
var _id = args.id || this.paginateService.DEFAULT_ID;
|
|
10810
|
+
if (this.state[_id]) {
|
|
10811
|
+
return this.state[_id].slice;
|
|
10812
|
+
}
|
|
10813
|
+
else {
|
|
10814
|
+
return collection;
|
|
10815
|
+
}
|
|
10816
|
+
}
|
|
10817
|
+
var serverSideMode = args.totalItems !== undefined;
|
|
10818
|
+
var instance = this._createInstance(collection, args);
|
|
10819
|
+
var id = instance.id;
|
|
10820
|
+
var start;
|
|
10821
|
+
var end;
|
|
10822
|
+
var perPage = instance.itemsPerPage;
|
|
10823
|
+
this.paginateService.register(instance);
|
|
10824
|
+
if (!serverSideMode && collection instanceof Array) {
|
|
10825
|
+
perPage = perPage || LARGE_NUMBER;
|
|
10826
|
+
start = (instance.currentPage - 1) * perPage;
|
|
10827
|
+
end = start + perPage;
|
|
10828
|
+
var isIdentical = this._stateIsIdentical(id, collection, start, end);
|
|
10829
|
+
if (isIdentical) {
|
|
10830
|
+
return this.state[id].slice;
|
|
10831
|
+
}
|
|
10832
|
+
else {
|
|
10833
|
+
var slice = collection.slice(start, end);
|
|
10834
|
+
this._saveState(id, collection, slice, start, end);
|
|
10835
|
+
this.paginateService.change.next(id);
|
|
10836
|
+
return slice;
|
|
10837
|
+
}
|
|
10838
|
+
}
|
|
10839
|
+
// save the state for server-side collection to avoid null
|
|
10840
|
+
// flash as new data loads.
|
|
10841
|
+
this._saveState(id, collection, collection, start, end);
|
|
10842
|
+
return collection;
|
|
10843
|
+
};
|
|
10844
|
+
// Create an IPaginationInstance object, using defaults for any optional properties not supplied.
|
|
10845
|
+
PaginatePipe.prototype._createInstance = function (collection, args) {
|
|
10846
|
+
var config = args;
|
|
10847
|
+
this._checkConfig(config);
|
|
10848
|
+
return {
|
|
10849
|
+
id: config.id || this.paginateService.DEFAULT_ID,
|
|
10850
|
+
itemsPerPage: config.itemsPerPage || 0,
|
|
10851
|
+
currentPage: config.currentPage || 1,
|
|
10852
|
+
totalItems: config.totalItems || collection.length
|
|
10853
|
+
};
|
|
10854
|
+
};
|
|
10855
|
+
// Ensure the argument passed to the filter contains the required properties.
|
|
10856
|
+
PaginatePipe.prototype._checkConfig = function (config) {
|
|
10857
|
+
var required = ["itemsPerPage", "currentPage"];
|
|
10858
|
+
var missing = required.filter(function (prop) { return !config.hasOwnProperty(prop); });
|
|
10859
|
+
if (0 < missing.length) {
|
|
10860
|
+
throw new Error("PaginatePipe: Argument is missing the following required properties: " + missing.join(", "));
|
|
10861
|
+
}
|
|
10862
|
+
};
|
|
10863
|
+
/**
|
|
10864
|
+
* To avoid returning a brand new array each time the pipe is run, we store the state of the sliced
|
|
10865
|
+
* array for a given id. This means that the next time the pipe is run on this collection & id, we just
|
|
10866
|
+
* need to check that the collection, start and end points are all identical, and if so, return the
|
|
10867
|
+
* last sliced array.
|
|
10868
|
+
*/
|
|
10869
|
+
PaginatePipe.prototype._saveState = function (id, collection, slice, start, end) {
|
|
10870
|
+
this.state[id] = {
|
|
10871
|
+
collection: collection,
|
|
10872
|
+
size: collection.length,
|
|
10873
|
+
slice: slice,
|
|
10874
|
+
start: start,
|
|
10875
|
+
end: end
|
|
10876
|
+
};
|
|
10877
|
+
};
|
|
10878
|
+
// For a given id, returns true if the collection, size, start and end values are identical.
|
|
10879
|
+
PaginatePipe.prototype._stateIsIdentical = function (id, collection, start, end) {
|
|
10880
|
+
var state = this.state[id];
|
|
10881
|
+
if (!state) {
|
|
10882
|
+
return false;
|
|
10883
|
+
}
|
|
10884
|
+
return state.collection === collection &&
|
|
10885
|
+
state.size === collection.length &&
|
|
10886
|
+
state.start === start &&
|
|
10887
|
+
state.end === end;
|
|
10888
|
+
};
|
|
10889
|
+
return PaginatePipe;
|
|
10890
|
+
}());
|
|
10891
|
+
PaginatePipe.decorators = [
|
|
10892
|
+
{ type: core.Pipe, args: [{
|
|
10893
|
+
name: 'paginate',
|
|
10894
|
+
pure: false
|
|
10895
|
+
},] }
|
|
10896
|
+
];
|
|
10897
|
+
PaginatePipe.ctorParameters = function () { return [
|
|
10898
|
+
{ type: PaginationService }
|
|
10899
|
+
]; };
|
|
10900
|
+
|
|
10901
|
+
var PaginationModule = /** @class */ (function () {
|
|
10902
|
+
function PaginationModule() {
|
|
10903
|
+
}
|
|
10904
|
+
return PaginationModule;
|
|
10905
|
+
}());
|
|
10906
|
+
PaginationModule.decorators = [
|
|
10907
|
+
{ type: core.NgModule, args: [{
|
|
10908
|
+
imports: [
|
|
10909
|
+
common.CommonModule
|
|
10910
|
+
],
|
|
10911
|
+
providers: [
|
|
10912
|
+
PaginationService
|
|
10913
|
+
],
|
|
10914
|
+
declarations: [
|
|
10915
|
+
PaginationComponent,
|
|
10916
|
+
PaginatePipe
|
|
10917
|
+
],
|
|
10918
|
+
exports: [
|
|
10919
|
+
PaginationComponent,
|
|
10920
|
+
PaginatePipe
|
|
10921
|
+
]
|
|
10922
|
+
},] }
|
|
10923
|
+
];
|
|
10924
|
+
|
|
10521
10925
|
/*
|
|
10522
10926
|
* Public API Surface of corecomponents
|
|
10523
10927
|
*/
|
|
@@ -10603,6 +11007,8 @@
|
|
|
10603
11007
|
exports.MultiSelectListComponent = MultiSelectListComponent;
|
|
10604
11008
|
exports.MultiSelectListModule = MultiSelectListModule;
|
|
10605
11009
|
exports.ObserveVisibilityModule = ObserveVisibilityModule;
|
|
11010
|
+
exports.PaginationComponent = PaginationComponent;
|
|
11011
|
+
exports.PaginationModule = PaginationModule;
|
|
10606
11012
|
exports.PopupButtonsComponent = PopupButtonsComponent;
|
|
10607
11013
|
exports.PopupMessageDisplayComponent = PopupMessageDisplayComponent;
|
|
10608
11014
|
exports.PopupModule = PopupModule;
|
|
@@ -10623,6 +11029,8 @@
|
|
|
10623
11029
|
exports["ɵbc"] = PrependPipe;
|
|
10624
11030
|
exports["ɵbd"] = ClickOutsideDirective;
|
|
10625
11031
|
exports["ɵbe"] = ClickOutsideMasterService;
|
|
11032
|
+
exports["ɵbf"] = PaginationService;
|
|
11033
|
+
exports["ɵbg"] = PaginatePipe;
|
|
10626
11034
|
exports["ɵc"] = CoRippleDirective;
|
|
10627
11035
|
exports["ɵd"] = CoViewportRulerService;
|
|
10628
11036
|
exports["ɵe"] = CoScrollDispatcherService;
|