@colijnit/corecomponents_v12 12.0.49 → 12.0.50

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.
@@ -4900,7 +4900,7 @@
4900
4900
  break;
4901
4901
  }
4902
4902
  else if (node.children.length > 0) {
4903
- return this._findInputNode(node.children);
4903
+ this._findInputNode(node.children);
4904
4904
  }
4905
4905
  }
4906
4906
  };
@@ -6246,7 +6246,7 @@
6246
6246
  InputComboBoxComponent.decorators = [
6247
6247
  { type: core.Component, args: [{
6248
6248
  selector: "co-input-combo-box",
6249
- template: "\n <ejs-combobox #combo [dataSource]=\"collection\"\n [fields]=\"fields\"\n [placeholder]=\"placeholder\"\n [autofill]=\"true\"\n [ngModel]=\"model\"\n (ngModelChange)=\"modelChange.emit($event)\"\n (valueChange)=\"valueChange.emit($event)\"\n (focus)=\"onFocus()\"\n showClearButton=\"true\"\n floatLabelType=\"Auto\"\n >\n </ejs-combobox>\n <div class=\"required-indicator\"></div>\n <ng-template #validationError></ng-template>\n ",
6249
+ template: "\n <ejs-combobox #combo [dataSource]=\"collection\"\n [fields]=\"fields\"\n [disabled]=\"readonly\"\n [placeholder]=\"placeholder\"\n [autofill]=\"true\"\n [ngModel]=\"model\"\n (ngModelChange)=\"modelChange.emit($event)\"\n (valueChange)=\"valueChange.emit($event)\"\n (focus)=\"onFocus()\"\n showClearButton=\"true\"\n floatLabelType=\"Auto\"\n >\n </ejs-combobox>\n <div class=\"required-indicator\"></div>\n <ng-template #validationError></ng-template>\n ",
6250
6250
  providers: [{
6251
6251
  provide: COMPONENT_INTERFACE_NAME,
6252
6252
  useExisting: core.forwardRef(function () { return InputComboBoxComponent; })
@@ -6434,7 +6434,7 @@
6434
6434
  InputDateRangePickerComponent.decorators = [
6435
6435
  { type: core.Component, args: [{
6436
6436
  selector: "co-input-date-range",
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 ",
6437
+ 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 ",
6438
6438
  encapsulation: core.ViewEncapsulation.None
6439
6439
  },] }
6440
6440
  ];
@@ -7554,6 +7554,7 @@
7554
7554
  _this.search = new core.EventEmitter();
7555
7555
  _this.useLeftIcon = false;
7556
7556
  _this.useRightIcon = false;
7557
+ _this.noIcon = false;
7557
7558
  return _this;
7558
7559
  }
7559
7560
  InputSearchComponent.prototype.showClass = function () {
@@ -7582,6 +7583,7 @@
7582
7583
  search: [{ type: core.Output }],
7583
7584
  useLeftIcon: [{ type: core.Input }],
7584
7585
  useRightIcon: [{ type: core.Input }],
7586
+ noIcon: [{ type: core.HostBinding, args: ['class.no-icon',] }, { type: core.Input }],
7585
7587
  showClass: [{ type: core.HostBinding, args: ['class.co-input-search',] }]
7586
7588
  };
7587
7589
  __decorate([
@@ -9501,10 +9503,12 @@
9501
9503
  _this.showAdd = false;
9502
9504
  _this.showDelete = false;
9503
9505
  _this.rightToolbar = false;
9506
+ _this.rowsPerPage = 1000;
9504
9507
  _this.editing = false;
9505
9508
  _this.editRowIndex = -1;
9506
9509
  _this.editCellIndex = -1;
9507
9510
  _this.selectedRowIndex = -1;
9511
+ _this.currentPage = 1;
9508
9512
  _this._doubleClicked = false;
9509
9513
  _this._newRow = false;
9510
9514
  return _this;
@@ -9771,6 +9775,10 @@
9771
9775
  }
9772
9776
  this._detectChanges();
9773
9777
  };
9778
+ SimpleGridComponent.prototype.pageChange = function (page) {
9779
+ this.currentPage = page;
9780
+ //this.gridBody.nativeElement.scrollTop = 0;
9781
+ };
9774
9782
  SimpleGridComponent.prototype._detectChanges = function () {
9775
9783
  this._changeDetection.detectChanges();
9776
9784
  };
@@ -9779,7 +9787,7 @@
9779
9787
  SimpleGridComponent.decorators = [
9780
9788
  { type: core.Component, args: [{
9781
9789
  selector: 'co-simple-grid',
9782
- template: "\n <co-grid-toolbar *ngIf=\"showToolbar\" [class.right]=\"rightToolbar\"\n [showEdit]=\"inlineEdit\"\n [showAdd]=\"showAdd\"\n [showDelete]=\"showDelete\"\n [deleteEnabled]=\"selectedRowIndex > -1\"\n (addClick)=\"addNewRow()\"\n (editClick)=\"editRow($event)\"\n (saveClick)=\"validateAndSave()\"\n (cancelClick)=\"cancelEditRow()\"\n (deleteClick)=\"removeRow()\"\n ></co-grid-toolbar>\n <table class=\"simple-grid-table\">\n <colgroup>\n <col *ngFor=\"let column of headerColumns; let index = index\"\n [class.simple-grid-column-auto-fit]=\"column.autoFit\"\n [style.width.px]=\"column.width\"\n [style.min-width.px]=\"MIN_COLUMN_WIDTH\">\n </colgroup>\n <thead>\n <tr>\n <th scope=\"col\" #headerCell class=\"simple-grid-column-header\" *ngFor=\"let column of headerColumns; let index = index\">\n <div class=\"simple-grid-column-header-wrapper\" [class.resizable]=\"resizable\"\n [ngClass]=\"column.textAlign ? column.textAlign : defaultTextAlign\">\n <ng-container *ngIf=\"column.headerTemplate; else noHeaderTemplate\">\n <ng-container [ngTemplateOutlet]=\"column.headerTemplate\"></ng-container>\n </ng-container>\n <ng-template #noHeaderTemplate>\n <div class=\"simple-grid-column-header-label\" [ngClass]=\"column.textAlign ? column.textAlign : defaultTextAlign\"\n [textContent]=\"column.headerText || '&nbsp;'\"\n ></div>\n </ng-template>\n <div *ngIf=\"resizable && column.resizable\" class=\"simple-grid-column-sizer\"\n (mousedown)=\"handleSizerMouseDown($event, column)\"\n ></div>\n </div>\n </th>\n </tr>\n </thead>\n <tbody #dropList cdkDropList cdkDropListOrientation=\"vertical\"\n class=\"simple-grid-drag-drop-list\"\n [cdkDropListDisabled]=\"!dragDropEnabled\"\n [cdkDropListData]=\"data\"\n [cdkDropListEnterPredicate]=\"handleCanDragDrop\"\n (cdkDropListDropped)=\"handleDrop($event)\">\n <tr class=\"simple-grid-row\" [class.selected]=\"rowIndex === selectedRowIndex && !editing\" observeVisibility\n [class.editing]=\"rowIndex === editRowIndex\" *ngFor=\"let row of data; let rowIndex = index\" cdkDrag\n (click)=\"handleClickRow($event, rowIndex)\" (dblclick)=\"handleDblClickRow($event, rowIndex)\" (visible)=\"rowVisible.next(row)\">\n <co-form class=\"simple-grid-row-form\">\n <ng-container *ngIf=\"isSingleColumnRow(row)\">\n <td class=\"simple-grid-single-column-cell\" [attr.colspan]=\"headerColumns.length\">\n <co-simple-grid-cell\n [column]=\"columns[singleColumnIndex(row)]\"\n [row]=\"row\"\n [editMode]=\"false\"\n ></co-simple-grid-cell>\n </td>\n </ng-container>\n <ng-container *ngIf=\"!isSingleColumnRow(row)\">\n <ng-container *ngFor=\"let column of headerColumns; let columnIndex = index\">\n <td class=\"simple-grid-column-cell\" *ngIf=\"columnIndex !== singleColumnIndex(row)\">\n <co-simple-grid-cell\n [column]=\"column\"\n [row]=\"row\"\n [editMode]=\"inlineEdit && editing && rowIndex === editRowIndex\"\n [fieldEditMode]=\"editCellIndex === columnIndex\"\n (cellClick)=\"handleCellClick(columnIndex)\"\n ></co-simple-grid-cell>\n <div *ngIf=\"column.resizable\" class=\"simple-grid-column-sizer-placeholder\"></div>\n </td>\n </ng-container>\n </ng-container>\n </co-form>\n </tr>\n </tbody>\n </table>\n ",
9790
+ template: "\n <co-grid-toolbar *ngIf=\"showToolbar\" [class.right]=\"rightToolbar\"\n [showEdit]=\"inlineEdit\"\n [showAdd]=\"showAdd\"\n [showDelete]=\"showDelete\"\n [deleteEnabled]=\"selectedRowIndex > -1\"\n (addClick)=\"addNewRow()\"\n (editClick)=\"editRow($event)\"\n (saveClick)=\"validateAndSave()\"\n (cancelClick)=\"cancelEditRow()\"\n (deleteClick)=\"removeRow()\"\n ></co-grid-toolbar>\n <table class=\"simple-grid-table\">\n <colgroup>\n <col *ngFor=\"let column of headerColumns; let index = index\"\n [class.simple-grid-column-auto-fit]=\"column.autoFit\"\n [style.width.px]=\"column.width\"\n [style.min-width.px]=\"MIN_COLUMN_WIDTH\">\n </colgroup>\n <thead>\n <tr>\n <th scope=\"col\" #headerCell class=\"simple-grid-column-header\" *ngFor=\"let column of headerColumns; let index = index\">\n <div class=\"simple-grid-column-header-wrapper\" [class.resizable]=\"resizable\"\n [ngClass]=\"column.textAlign ? column.textAlign : defaultTextAlign\">\n <ng-container *ngIf=\"column.headerTemplate; else noHeaderTemplate\">\n <ng-container [ngTemplateOutlet]=\"column.headerTemplate\"></ng-container>\n </ng-container>\n <ng-template #noHeaderTemplate>\n <div class=\"simple-grid-column-header-label\" [ngClass]=\"column.textAlign ? column.textAlign : defaultTextAlign\"\n [textContent]=\"column.headerText || '&nbsp;'\"\n ></div>\n </ng-template>\n <div *ngIf=\"resizable && column.resizable\" class=\"simple-grid-column-sizer\"\n (mousedown)=\"handleSizerMouseDown($event, column)\"\n ></div>\n </div>\n </th>\n </tr>\n </thead>\n <tbody #dropList cdkDropList cdkDropListOrientation=\"vertical\"\n class=\"simple-grid-drag-drop-list\"\n [cdkDropListDisabled]=\"!dragDropEnabled\"\n [cdkDropListData]=\"data\"\n [cdkDropListEnterPredicate]=\"handleCanDragDrop\"\n (cdkDropListDropped)=\"handleDrop($event)\">\n <tr class=\"simple-grid-row\" [class.selected]=\"rowIndex === selectedRowIndex && !editing\" observeVisibility\n [class.editing]=\"rowIndex === editRowIndex\" *ngFor=\"let row of (!!rowsPerPage ? (data | paginate: {itemsPerPage: rowsPerPage, currentPage: currentPage}) : data); last as last; let rowIndex = index\" cdkDrag\n (click)=\"handleClickRow($event, rowIndex)\" (dblclick)=\"handleDblClickRow($event, rowIndex)\" (visible)=\"rowVisible.next(row)\">\n <co-form class=\"simple-grid-row-form\">\n <ng-container *ngIf=\"isSingleColumnRow(row)\">\n <td class=\"simple-grid-single-column-cell\" [attr.colspan]=\"headerColumns.length\">\n <co-simple-grid-cell\n [column]=\"columns[singleColumnIndex(row)]\"\n [row]=\"row\"\n [editMode]=\"false\"\n ></co-simple-grid-cell>\n </td>\n </ng-container>\n <ng-container *ngIf=\"!isSingleColumnRow(row)\">\n <ng-container *ngFor=\"let column of headerColumns; let columnIndex = index\">\n <td class=\"simple-grid-column-cell\" *ngIf=\"columnIndex !== singleColumnIndex(row)\">\n <co-simple-grid-cell\n [column]=\"column\"\n [row]=\"row\"\n [editMode]=\"inlineEdit && editing && rowIndex === editRowIndex\"\n [fieldEditMode]=\"editCellIndex === columnIndex\"\n (cellClick)=\"handleCellClick(columnIndex)\"\n ></co-simple-grid-cell>\n <div *ngIf=\"column.resizable\" class=\"simple-grid-column-sizer-placeholder\"></div>\n </td>\n </ng-container>\n </ng-container>\n </co-form>\n </tr>\n </tbody>\n </table>\n <co-pagination *ngIf=\"data?.length > rowsPerPage\" [autoHide]=\"true\" (pageChange)=\"pageChange($event)\"></co-pagination>\n ",
9783
9791
  providers: [
9784
9792
  FormMasterService
9785
9793
  ],
@@ -9796,1128 +9804,1130 @@
9796
9804
  showAdd: [{ type: core.Input }],
9797
9805
  showDelete: [{ type: core.Input }],
9798
9806
  rightToolbar: [{ type: core.Input }],
9807
+ rowsPerPage: [{ type: core.Input }],
9799
9808
  showClass: [{ type: core.HostBinding, args: ['class.co-simple-grid',] }],
9800
9809
  handleKeyDown: [{ type: core.HostListener, args: ['keydown', ['$event'],] }]
9801
9810
  };
9802
9811
 
9803
- var SimpleGridCellComponent = /** @class */ (function () {
9804
- function SimpleGridCellComponent(_changeDetector) {
9805
- this._changeDetector = _changeDetector;
9806
- this.defaultTextAlign = exports.ColumnAlign.Left;
9807
- this.editMode = false;
9808
- this.cellClick = new core.EventEmitter();
9809
- this._fieldEditMode = false;
9810
- this._focused = false;
9812
+ var PaginationService = /** @class */ (function () {
9813
+ function PaginationService() {
9814
+ this.change = new rxjs.Subject();
9815
+ this.instances = {};
9811
9816
  }
9812
- Object.defineProperty(SimpleGridCellComponent.prototype, "editTemplateContent", {
9813
- set: function (template) {
9814
- if (template) {
9815
- this._editTemplate = template;
9816
- this._setFocusComponent();
9817
- }
9818
- },
9819
- enumerable: false,
9820
- configurable: true
9821
- });
9822
- Object.defineProperty(SimpleGridCellComponent.prototype, "noEditTemplateContent", {
9823
- set: function (template) {
9824
- if (template) {
9825
- this._template = template;
9826
- this._setFocusComponent();
9827
- }
9828
- },
9829
- enumerable: false,
9830
- configurable: true
9831
- });
9832
- Object.defineProperty(SimpleGridCellComponent.prototype, "noTemplateContent", {
9833
- set: function (template) {
9834
- if (template) {
9835
- this._inputTemplate = template;
9836
- this._setFocusComponent();
9837
- }
9838
- },
9839
- enumerable: false,
9840
- configurable: true
9841
- });
9842
- Object.defineProperty(SimpleGridCellComponent.prototype, "fieldEditMode", {
9817
+ Object.defineProperty(PaginationService.prototype, "DEFAULT_ID", {
9843
9818
  get: function () {
9844
- return this._fieldEditMode;
9845
- },
9846
- set: function (value) {
9847
- this._fieldEditMode = value;
9848
- this._setFocusComponent();
9819
+ return PaginationService.DEFAULT_ID;
9849
9820
  },
9850
9821
  enumerable: false,
9851
9822
  configurable: true
9852
9823
  });
9853
- SimpleGridCellComponent.prototype.showClass = function () {
9854
- return true;
9855
- };
9856
- SimpleGridCellComponent.prototype.handleClick = function (event) {
9857
- if (this.column && !this.column.readonly) {
9858
- this.cellClick.next();
9824
+ PaginationService.prototype.register = function (instance) {
9825
+ if (!instance.id) {
9826
+ instance.id = PaginationService.DEFAULT_ID;
9859
9827
  }
9860
- };
9861
- SimpleGridCellComponent.prototype._setFocusComponent = function () {
9862
- if (this.editMode && this.fieldEditMode) {
9863
- var element = this._getElement();
9864
- if (element) {
9865
- var focusEvent = this._createNewEvent(element, 'focus');
9866
- element.focus();
9867
- element.dispatchEvent(focusEvent);
9868
- this._focused = true;
9869
- }
9828
+ if (!this.instances[instance.id]) {
9829
+ this.instances[instance.id] = instance;
9830
+ this.change.next(instance.id);
9870
9831
  }
9871
9832
  else {
9872
- if (this._focused) {
9873
- var element = this._getElement();
9874
- if (element) {
9875
- var blurEvent = this._createNewEvent(element, 'blur');
9876
- element.blur();
9877
- element.dispatchEvent(blurEvent);
9878
- }
9879
- this._focused = false;
9833
+ var changed = this.updateInstance(instance);
9834
+ if (changed) {
9835
+ this.change.next(instance.id);
9880
9836
  }
9881
9837
  }
9882
- this._detectChanges();
9883
9838
  };
9884
- SimpleGridCellComponent.prototype._getFirstFormInput = function (parent) {
9885
- if (parent) {
9886
- var collection_1 = Array.from(parent.getElementsByTagName('input'));
9887
- var otherCollection = Array.from(parent.getElementsByTagName('textarea'));
9888
- otherCollection.map(function (o) { return collection_1.push(o); });
9889
- if (collection_1.length > 0) {
9890
- return collection_1[0];
9891
- }
9839
+ // Returns the current page number.
9840
+ PaginationService.prototype.getCurrentPage = function (id) {
9841
+ if (this.instances[id]) {
9842
+ return this.instances[id].currentPage;
9892
9843
  }
9893
9844
  };
9894
- SimpleGridCellComponent.prototype._createNewEvent = function (element, eventType) {
9895
- var event;
9896
- if ("createEvent" in document) {
9897
- event = document.createEvent("Event");
9898
- event.initEvent(eventType, true, true);
9899
- }
9900
- else if ("Event" in window) {
9901
- event = new Event(eventType, { bubbles: true, cancelable: true });
9845
+ // Sets the current page number.
9846
+ PaginationService.prototype.setCurrentPage = function (id, page) {
9847
+ if (this.instances[id]) {
9848
+ var instance = this.instances[id];
9849
+ var maxPage = Math.ceil(instance.totalItems / instance.itemsPerPage);
9850
+ if (page <= maxPage && 1 <= page) {
9851
+ this.instances[id].currentPage = page;
9852
+ this.change.next(id);
9853
+ }
9902
9854
  }
9903
- return event;
9904
9855
  };
9905
- SimpleGridCellComponent.prototype._getElement = function () {
9906
- var templ;
9907
- if (this._editTemplate) {
9908
- templ = this._editTemplate;
9856
+ // Sets the value of instance.totalItems
9857
+ PaginationService.prototype.setTotalItems = function (id, totalItems) {
9858
+ if (this.instances[id] && 0 <= totalItems) {
9859
+ this.instances[id].totalItems = totalItems;
9860
+ this.change.next(id);
9909
9861
  }
9910
- else if (this._template) {
9911
- templ = this._template;
9862
+ };
9863
+ // Sets the value of instance.itemsPerPage.
9864
+ PaginationService.prototype.setItemsPerPage = function (id, itemsPerPage) {
9865
+ if (this.instances[id]) {
9866
+ this.instances[id].itemsPerPage = itemsPerPage;
9867
+ this.change.next(id);
9912
9868
  }
9913
- else {
9914
- templ = this._inputTemplate;
9869
+ };
9870
+ /**
9871
+ * Returns a clone of the pagination instance object matching the id. If no
9872
+ * id specified, returns the instance corresponding to the default id.
9873
+ */
9874
+ PaginationService.prototype.getInstance = function (id) {
9875
+ if (id === void 0) { id = PaginationService.DEFAULT_ID; }
9876
+ if (this.instances[id]) {
9877
+ return ObjectUtils.GetShallowClone(this.instances[id]);
9915
9878
  }
9916
- if (templ) {
9917
- if (templ && templ.elementRef) {
9918
- var inputElement = this._getFirstFormInput(templ.elementRef.nativeElement.parentElement);
9919
- if (inputElement) {
9920
- return inputElement;
9921
- }
9879
+ return {};
9880
+ };
9881
+ /**
9882
+ * Check each property of the instance and update any that have changed. Return
9883
+ * true if any changes were made, else return false.
9884
+ */
9885
+ PaginationService.prototype.updateInstance = function (instance) {
9886
+ var changed = false;
9887
+ for (var prop in this.instances[instance.id]) {
9888
+ if (instance[prop] !== this.instances[instance.id][prop]) {
9889
+ this.instances[instance.id][prop] = instance[prop];
9890
+ changed = true;
9922
9891
  }
9923
9892
  }
9893
+ return changed;
9924
9894
  };
9925
- SimpleGridCellComponent.prototype._detectChanges = function () {
9926
- this._changeDetector.detectChanges();
9927
- };
9928
- return SimpleGridCellComponent;
9895
+ return PaginationService;
9929
9896
  }());
9930
- SimpleGridCellComponent.decorators = [
9931
- { type: core.Component, args: [{
9932
- selector: "co-simple-grid-cell",
9933
- template: "\n <div class=\"simple-grid-column-cell-value\" [ngClass]=\"column.textAlign ? column.textAlign : defaultTextAlign\">\n <ng-container *ngIf=\"editMode; else noInlineEdit\">\n <ng-container #editTemplate *ngIf=\"column.editTemplate; else noEditTemplate\"\n [ngTemplateOutlet]=\"column.editTemplate\"\n [ngTemplateOutletContext]=\"{value: row[column.field], row: row}\"></ng-container>\n <ng-template #noEditTemplate>\n <ng-container *ngIf=\"column.template; else noTemplate\">\n <ng-container [ngTemplateOutlet]=\"column.template\"\n [ngTemplateOutletContext]=\"{value: row[column.field], row: row}\"></ng-container>\n </ng-container>\n <ng-template #noTemplate>\n <co-input-text [(model)]=\"row[column.field]\" [required]=\"column.required\"></co-input-text>\n </ng-template>\n </ng-template>\n </ng-container>\n <ng-template #noInlineEdit>\n <ng-container *ngIf=\"column.template; else noTemplate\">\n <ng-container [ngTemplateOutlet]=\"column.template\"\n [ngTemplateOutletContext]=\"{value: row[column.field], row: row}\"></ng-container>\n </ng-container>\n <ng-template #noTemplate>\n <span [textContent]=\"column.getFieldValue(row[column.field])\"></span>\n </ng-template>\n </ng-template>\n </div>\n ",
9934
- encapsulation: core.ViewEncapsulation.None
9935
- },] }
9897
+ PaginationService.DEFAULT_ID = "DEFAULT_PAGINATION_ID";
9898
+ PaginationService.decorators = [
9899
+ { type: core.Injectable }
9936
9900
  ];
9937
- SimpleGridCellComponent.ctorParameters = function () { return [
9938
- { type: core.ChangeDetectorRef }
9939
- ]; };
9940
- SimpleGridCellComponent.propDecorators = {
9941
- editTemplateContent: [{ type: core.ViewChild, args: ["editTemplate", { read: BaseInputComponent },] }],
9942
- noEditTemplateContent: [{ type: core.ViewChild, args: ["noEditTemplate",] }],
9943
- noTemplateContent: [{ type: core.ViewChild, args: ["noTemplate",] }],
9944
- column: [{ type: core.Input }],
9945
- row: [{ type: core.Input }],
9946
- editMode: [{ type: core.Input }],
9947
- fieldEditMode: [{ type: core.Input }],
9948
- cellClick: [{ type: core.Output }],
9949
- showClass: [{ type: core.HostBinding, args: ["class.co-simple-grid-cell",] }],
9950
- handleClick: [{ type: core.HostListener, args: ['click', ['$event'],] }]
9951
- };
9901
+ PaginationService.ctorParameters = function () { return []; };
9952
9902
 
9953
- var ObserveVisibilityDirective = /** @class */ (function () {
9954
- function ObserveVisibilityDirective(_element) {
9955
- this._element = _element;
9956
- this.debounceTime = 0;
9957
- this.threshold = 0;
9958
- this.visible = new core.EventEmitter();
9959
- this._subject = new rxjs.Subject();
9903
+ var PaginationComponent = /** @class */ (function () {
9904
+ function PaginationComponent(_paginationService) {
9905
+ var _this = this;
9906
+ this._paginationService = _paginationService;
9907
+ this.maxSize = 7;
9908
+ this.directionLinks = true;
9909
+ this.previousLabel = 'Vorige pagina';
9910
+ this.nextLabel = 'Volgende pagina';
9911
+ this.autoHide = false;
9912
+ // Emits the new page number.
9913
+ this.pageChange = new core.EventEmitter();
9914
+ this.showClass = true;
9915
+ this.pages = [];
9916
+ this.changeSub = this._paginationService.change.subscribe(function (id) {
9917
+ if (_this.id === id) {
9918
+ _this._updatePageLinks();
9919
+ }
9920
+ });
9960
9921
  }
9961
- ObserveVisibilityDirective.prototype.ngOnInit = function () {
9962
- this._createObserver();
9922
+ PaginationComponent.prototype.ngOnInit = function () {
9923
+ if (!this.id) {
9924
+ this.id = this._paginationService.DEFAULT_ID;
9925
+ }
9926
+ this._updatePageLinks();
9963
9927
  };
9964
- ObserveVisibilityDirective.prototype.ngAfterViewInit = function () {
9965
- this._startObservingElements();
9928
+ PaginationComponent.prototype.ngOnChanges = function () {
9929
+ this._updatePageLinks();
9966
9930
  };
9967
- ObserveVisibilityDirective.prototype.ngOnDestroy = function () {
9968
- if (this._observer) {
9969
- this._observer.disconnect();
9970
- this._observer = undefined;
9931
+ PaginationComponent.prototype.ngOnDestroy = function () {
9932
+ this.changeSub.unsubscribe();
9933
+ };
9934
+ PaginationComponent.prototype.goToFirstPage = function () {
9935
+ if (!this.isOnFirstPage()) {
9936
+ this.setCurrentPage(1);
9971
9937
  }
9972
- this._subject.next();
9973
- this._subject.complete();
9974
9938
  };
9975
- ObserveVisibilityDirective.prototype._isVisible = function (element) {
9976
- var _this = this;
9977
- return new Promise(function (resolve) {
9978
- var observer = new IntersectionObserver(function (_a) {
9979
- var _b = __read(_a, 1), entry = _b[0];
9980
- resolve(entry.isIntersecting && entry.intersectionRatio >= _this.threshold);
9981
- observer.disconnect();
9982
- });
9983
- observer.observe(element);
9984
- });
9939
+ PaginationComponent.prototype.goToPreviousPage = function () {
9940
+ if (!this.isOnFirstPage()) {
9941
+ this.setCurrentPage(this.getCurrentPage() - 1);
9942
+ }
9985
9943
  };
9986
- ObserveVisibilityDirective.prototype._createObserver = function () {
9987
- var _this = this;
9988
- var options = {
9989
- rootMargin: '0px',
9990
- threshold: this.threshold,
9991
- };
9992
- var isIntersecting = function (entry) { return entry.isIntersecting || entry.intersectionRatio > 0; };
9993
- this._observer = new IntersectionObserver(function (entries, observer) {
9994
- entries.forEach(function (entry) {
9995
- if (isIntersecting(entry)) {
9996
- _this._subject.next({ entry: entry, observer: observer });
9997
- }
9998
- });
9999
- }, options);
10000
- };
10001
- ObserveVisibilityDirective.prototype._startObservingElements = function () {
10002
- var _this = this;
10003
- if (!this._observer) {
10004
- return;
9944
+ PaginationComponent.prototype.goToNextPage = function () {
9945
+ if (!this.isOnLastPage()) {
9946
+ this.setCurrentPage(this.getCurrentPage() + 1);
10005
9947
  }
10006
- this._observer.observe(this._element.nativeElement);
10007
- this._subject
10008
- .pipe(operators.delay(this.debounceTime), operators.filter(Boolean))
10009
- .subscribe(function (_a) {
10010
- var entry = _a.entry, observer = _a.observer;
10011
- return __awaiter(_this, void 0, void 0, function () {
10012
- var target, isStillVisible;
10013
- return __generator(this, function (_a) {
10014
- switch (_a.label) {
10015
- case 0:
10016
- target = entry.target;
10017
- return [4 /*yield*/, this._isVisible(target)];
10018
- case 1:
10019
- isStillVisible = _a.sent();
10020
- if (isStillVisible) {
10021
- this.visible.emit(target);
10022
- observer.unobserve(target);
10023
- }
10024
- return [2 /*return*/];
10025
- }
10026
- });
10027
- });
10028
- });
10029
- };
10030
- return ObserveVisibilityDirective;
10031
- }());
10032
- ObserveVisibilityDirective.decorators = [
10033
- { type: core.Directive, args: [{
10034
- selector: '[observeVisibility]',
10035
- },] }
10036
- ];
10037
- ObserveVisibilityDirective.ctorParameters = function () { return [
10038
- { type: core.ElementRef }
10039
- ]; };
10040
- ObserveVisibilityDirective.propDecorators = {
10041
- debounceTime: [{ type: core.Input }],
10042
- threshold: [{ type: core.Input }],
10043
- visible: [{ type: core.Output }]
10044
- };
10045
-
10046
- var ObserveVisibilityModule = /** @class */ (function () {
10047
- function ObserveVisibilityModule() {
10048
- }
10049
- return ObserveVisibilityModule;
10050
- }());
10051
- ObserveVisibilityModule.decorators = [
10052
- { type: core.NgModule, args: [{
10053
- declarations: [
10054
- ObserveVisibilityDirective
10055
- ],
10056
- exports: [
10057
- ObserveVisibilityDirective
10058
- ]
10059
- },] }
10060
- ];
10061
-
10062
- var SimpleGridModule = /** @class */ (function () {
10063
- function SimpleGridModule() {
10064
- }
10065
- return SimpleGridModule;
10066
- }());
10067
- SimpleGridModule.decorators = [
10068
- { type: core.NgModule, args: [{
10069
- imports: [
10070
- common.CommonModule,
10071
- dragDrop.DragDropModule,
10072
- GridToolbarModule,
10073
- InputTextModule,
10074
- FormModule,
10075
- ObserveVisibilityModule
10076
- ],
10077
- declarations: [
10078
- SimpleGridComponent,
10079
- SimpleGridCellComponent,
10080
- SimpleGridColumnDirective
10081
- ],
10082
- exports: [
10083
- SimpleGridComponent,
10084
- SimpleGridCellComponent,
10085
- SimpleGridColumnDirective
10086
- ]
10087
- },] }
10088
- ];
10089
-
10090
- var FilterItemComponent = /** @class */ (function () {
10091
- function FilterItemComponent(iconService) {
10092
- this.iconService = iconService;
10093
- this.icons = exports.CoreComponentsIcon;
10094
- this.initialLimit = 10;
10095
- this.expanded = false;
10096
- // Set to false to use filter item with a multi selectable collection. Set to true to specify custom content
10097
- this.customContent = false;
10098
- // Set to true to show all results. Set to false to get 'show more' and 'show less' buttons to expand and contract.
10099
- this.showAllResults = false;
10100
- this.singleSelect = false;
10101
- this.searchPlaceholder = 'Search...';
10102
- this.showMoreLabel = 'Show more';
10103
- this.showLessLabel = 'Show less';
10104
- this.noResultsLabel = "No results";
10105
- this.collectionChange = new core.EventEmitter();
10106
- this.filteredCollection = [];
10107
- this.limitTo = 10;
10108
- this.filterText = "";
10109
- this._collection = [];
10110
- }
10111
- Object.defineProperty(FilterItemComponent.prototype, "collection", {
10112
- get: function () {
10113
- return this._collection;
10114
- },
10115
- set: function (value) {
10116
- var _a;
10117
- this._collection = value;
10118
- this.filteredCollection = (_a = this._collection) === null || _a === void 0 ? void 0 : _a.slice();
10119
- },
10120
- enumerable: false,
10121
- configurable: true
10122
- });
10123
- FilterItemComponent.prototype.showClass = function () {
10124
- return true;
10125
9948
  };
10126
- FilterItemComponent.prototype.ngOnInit = function () {
10127
- this.setToInitialLimit();
9949
+ PaginationComponent.prototype.setCurrentPage = function (page) {
9950
+ this.pageChange.emit(page);
10128
9951
  };
10129
- FilterItemComponent.prototype.setToInitialLimit = function () {
10130
- this.limitTo = this.initialLimit;
9952
+ PaginationComponent.prototype.isOnFirstPage = function () {
9953
+ return this.getCurrentPage() === 1;
10131
9954
  };
10132
- FilterItemComponent.prototype.increaseLimit = function () {
10133
- this.limitTo += 10;
9955
+ PaginationComponent.prototype.isOnLastPage = function () {
9956
+ return this.getLastPage() === this.getCurrentPage();
10134
9957
  };
10135
- FilterItemComponent.prototype.moreToShow = function () {
10136
- var _a;
10137
- if (this.showAllResults) {
9958
+ PaginationComponent.prototype.shouldBeHidden = function () {
9959
+ if (!this.autoHide) {
10138
9960
  return false;
10139
9961
  }
10140
- return ((_a = this.filteredCollection) === null || _a === void 0 ? void 0 : _a.length) > this.limitTo;
9962
+ else {
9963
+ var instance = this._paginationService.getInstance();
9964
+ return (instance.totalItems <= instance.itemsPerPage);
9965
+ }
10141
9966
  };
10142
- FilterItemComponent.prototype.lessToShow = function () {
10143
- var _a, _b;
10144
- if (this.showAllResults) {
10145
- return false;
9967
+ /**
9968
+ * Updates the page links and checks that the current page is valid. Should run whenever the
9969
+ * PaginationService.change stream emits a value matching the current ID, or when any of the
9970
+ * input values changes.
9971
+ */
9972
+ PaginationComponent.prototype._updatePageLinks = function () {
9973
+ var paginationInstance = this._paginationService.getInstance(this.id);
9974
+ this.pages = this.createPageArray(paginationInstance.currentPage, paginationInstance.itemsPerPage, paginationInstance.totalItems, this.maxSize);
9975
+ var correctedCurrentPage = this.outOfBoundCorrection(paginationInstance);
9976
+ if (correctedCurrentPage !== paginationInstance.currentPage) {
9977
+ this.setCurrentPage(correctedCurrentPage);
10146
9978
  }
10147
- return ((_a = this.filteredCollection) === null || _a === void 0 ? void 0 : _a.length) <= this.limitTo && ((_b = this.filteredCollection) === null || _b === void 0 ? void 0 : _b.length) > this.initialLimit;
10148
9979
  };
10149
- FilterItemComponent.prototype.handleModelChange = function (model) {
10150
- if (this.singleSelect) {
10151
- this.collection.forEach(function (m) {
10152
- if (m.code !== model.code && m.description !== model.description) {
10153
- m.checked = false;
10154
- }
9980
+ PaginationComponent.prototype.getCurrentPage = function () {
9981
+ return this._paginationService.getCurrentPage(this.id);
9982
+ };
9983
+ PaginationComponent.prototype.getLastPage = function () {
9984
+ var instance = this._paginationService.getInstance(this.id);
9985
+ return Math.ceil(instance.totalItems / instance.itemsPerPage);
9986
+ };
9987
+ /**
9988
+ * Checks that the instance.currentPage property is within bounds for the current page range.
9989
+ * If not, return a correct value for currentPage, or the current value if OK.
9990
+ */
9991
+ PaginationComponent.prototype.outOfBoundCorrection = function (instance) {
9992
+ var totalPages = Math.ceil(instance.totalItems / instance.itemsPerPage);
9993
+ if (totalPages < instance.currentPage && 0 < totalPages) {
9994
+ return totalPages;
9995
+ }
9996
+ else if (instance.currentPage < 1) {
9997
+ return 1;
9998
+ }
9999
+ return instance.currentPage;
10000
+ };
10001
+ // Returns an array of IPage objects to use in the pagination controls.
10002
+ PaginationComponent.prototype.createPageArray = function (currentPage, itemsPerPage, totalItems, paginationRange) {
10003
+ // paginationRange could be a string if passed from attribute, so cast to number.
10004
+ paginationRange = +paginationRange;
10005
+ var pages = [];
10006
+ var totalPages = Math.ceil(totalItems / itemsPerPage);
10007
+ var halfWay = Math.ceil(paginationRange / 2);
10008
+ var isStart = currentPage <= halfWay;
10009
+ var isEnd = totalPages - halfWay < currentPage;
10010
+ var isMiddle = !isStart && !isEnd;
10011
+ var ellipsesNeeded = paginationRange < totalPages;
10012
+ var i = 1;
10013
+ while (i <= totalPages && i <= paginationRange) {
10014
+ var label = void 0;
10015
+ var pageNumber = this.calculatePageNumber(i, currentPage, paginationRange, totalPages);
10016
+ var openingEllipsesNeeded = (i === 2 && (isMiddle || isEnd));
10017
+ var closingEllipsesNeeded = (i === paginationRange - 1 && (isMiddle || isStart));
10018
+ if (ellipsesNeeded && (openingEllipsesNeeded || closingEllipsesNeeded)) {
10019
+ label = '...';
10020
+ }
10021
+ else {
10022
+ label = '' + pageNumber;
10023
+ }
10024
+ pages.push({
10025
+ label: label,
10026
+ value: pageNumber
10155
10027
  });
10028
+ i++;
10156
10029
  }
10157
- model.checked = !model.checked;
10158
- this.collectionChange.emit(this.collection);
10030
+ return pages;
10159
10031
  };
10160
- // Applies filter to the collection.
10161
- FilterItemComponent.prototype.applyFilter = function (text) {
10162
- var _a, _b;
10163
- return __awaiter(this, void 0, void 0, function () {
10164
- var _c, filterText, filteredItemCount;
10165
- return __generator(this, function (_d) {
10166
- switch (_d.label) {
10167
- case 0:
10168
- if (!(!isNaN(this.minSearchCharsToLoadCollection) && this.collectionLoadFn)) return [3 /*break*/, 3];
10169
- if (!(text.length === this.minSearchCharsToLoadCollection && text.length > this.filterText.length)) return [3 /*break*/, 2];
10170
- _c = this;
10171
- return [4 /*yield*/, this.collectionLoadFn(text)];
10172
- case 1:
10173
- _c.collection = _d.sent();
10174
- return [3 /*break*/, 3];
10175
- case 2:
10176
- if (text.length < this.minSearchCharsToLoadCollection) {
10177
- this.collection = undefined;
10178
- }
10179
- _d.label = 3;
10180
- case 3:
10181
- this.filterText = text;
10182
- if (!this.collection) {
10183
- return [2 /*return*/, []];
10184
- }
10185
- filterText = (_a = this.filterText) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
10186
- filteredItemCount = 0;
10187
- this.filteredCollection = (_b = this.collection) === null || _b === void 0 ? void 0 : _b.filter(function (item) {
10188
- var _a;
10189
- var labelText = (_a = item.description) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
10190
- var isHiddenByFilter = ((labelText === null || labelText === void 0 ? void 0 : labelText.indexOf(filterText)) === -1);
10191
- if (isHiddenByFilter) {
10192
- return false;
10193
- }
10194
- else {
10195
- filteredItemCount++;
10196
- return true;
10197
- }
10198
- });
10199
- return [2 /*return*/];
10200
- }
10201
- });
10202
- });
10032
+ // Given the position in the sequence of pagination links [i], figure out what page number corresponds to that position.
10033
+ PaginationComponent.prototype.calculatePageNumber = function (i, currentPage, paginationRange, totalPages) {
10034
+ var halfWay = Math.ceil(paginationRange / 2);
10035
+ if (i === paginationRange) {
10036
+ return totalPages;
10037
+ }
10038
+ else if (i === 1) {
10039
+ return i;
10040
+ }
10041
+ else if (paginationRange < totalPages) {
10042
+ if (totalPages - halfWay < currentPage) {
10043
+ return totalPages - paginationRange + i;
10044
+ }
10045
+ else if (halfWay < currentPage) {
10046
+ return currentPage - halfWay + i;
10047
+ }
10048
+ else {
10049
+ return i;
10050
+ }
10051
+ }
10052
+ else {
10053
+ return i;
10054
+ }
10203
10055
  };
10204
- return FilterItemComponent;
10056
+ return PaginationComponent;
10205
10057
  }());
10206
- FilterItemComponent.decorators = [
10058
+ PaginationComponent.decorators = [
10207
10059
  { type: core.Component, args: [{
10208
- selector: "co-filter-item",
10209
- template: "\n <div class=\"co-filter-item-header\">\n <co-collapsible\n [headerTitle]=\"placeholder\"\n [expandButtonLast]=\"true\"\n [iconData]=\"iconService.getIcon(icons.ArrowPointDown)\"\n [expanded]=\"expanded\"\n >\n <div class=\"co-filter-item-collapsable-content\">\n <div class=\"co-filter-item-custom-content\" *ngIf=\"customContent; else collectionContent\">\n <ng-content></ng-content>\n </div>\n <ng-template #collectionContent>\n <div class=\"co-filter-item-collection-content\">\n <co-input-text\n *ngIf=\"collection?.length > 10 || minSearchCharsToLoadCollection\"\n [placeholder]=\"searchPlaceholder\"\n [model]=\"filterText\"\n (modelChange)=\"applyFilter($event)\"\n >\n </co-input-text>\n <div class=\"no-results\" *ngIf=\"filteredCollection?.length === 0\">\n <span [textContent]=\"noResultsLabel\"></span>\n </div>\n <div class=\"co-filter-item-collection-results\">\n <ng-container\n *ngFor=\"let option of filteredCollection; let index = index\">\n <div class=\"co-filter-item-collection-result-item\" *ngIf=\"index < limitTo || showAllResults\">\n <co-input-checkbox *ngIf=\"!singleSelect\"\n [label]=\"option.description\"\n [model]=\"option.checked\"\n (modelChange)=\"handleModelChange(option)\"\n ></co-input-checkbox>\n <co-input-radio-button *ngIf=\"singleSelect\"\n [name]=\"'radiogroup'\"\n [label]=\"option.description\"\n [model]=\"option.checked\"\n (modelChange)=\"handleModelChange(option)\"\n ></co-input-radio-button>\n <div class=\"co-filter-item-amount\" *ngIf=\"option.count\"\n [textContent]=\"option.count.toString() | append: ')' | prepend: ' ('\"\n ></div>\n </div>\n\n </ng-container>\n </div>\n <div class=\"co-filter-show-more-or-less\" *ngIf=\"!showAllResults\">\n <div class=\"co-filter-show-more clickable\"\n *ngIf=\"moreToShow()\">\n <a (click)=\"increaseLimit()\">\n <co-icon [iconData]=\"iconService.getIcon(icons.ArrowPointDown)\"></co-icon>\n <span [textContent]=\"showMoreLabel\"></span>\n </a>\n </div>\n <div class=\"co-filter-show-less clickable\"\n *ngIf=\"lessToShow()\">\n <a (click)=\"setToInitialLimit()\">\n <co-icon [iconData]=\"iconService.getIcon(icons.ArrowPointUp)\"></co-icon>\n <span [textContent]=\"showLessLabel\"></span>\n </a>\n </div>\n </div>\n </div>\n </ng-template>\n </div>\n </co-collapsible>\n </div>\n\n ",
10060
+ selector: 'co-pagination',
10061
+ 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 ",
10210
10062
  encapsulation: core.ViewEncapsulation.None
10211
10063
  },] }
10212
10064
  ];
10213
- FilterItemComponent.ctorParameters = function () { return [
10214
- { type: IconCacheService }
10065
+ PaginationComponent.ctorParameters = function () { return [
10066
+ { type: PaginationService }
10215
10067
  ]; };
10216
- FilterItemComponent.propDecorators = {
10217
- collection: [{ type: core.Input }],
10218
- placeholder: [{ type: core.Input }],
10219
- initialLimit: [{ type: core.Input }],
10220
- expanded: [{ type: core.Input }],
10221
- minSearchCharsToLoadCollection: [{ type: core.Input }],
10222
- collectionLoadFn: [{ type: core.Input }],
10223
- customContent: [{ type: core.Input }],
10224
- showAllResults: [{ type: core.Input }],
10225
- singleSelect: [{ type: core.Input }],
10226
- searchPlaceholder: [{ type: core.Input }],
10227
- showMoreLabel: [{ type: core.Input }],
10228
- showLessLabel: [{ type: core.Input }],
10229
- noResultsLabel: [{ type: core.Input }],
10230
- collectionChange: [{ type: core.Output }],
10231
- showClass: [{ type: core.HostBinding, args: ["class.co-filter-item",] }]
10068
+ PaginationComponent.propDecorators = {
10069
+ template: [{ type: core.ViewChild, args: ['template',] }],
10070
+ id: [{ type: core.Input }],
10071
+ maxSize: [{ type: core.Input }],
10072
+ directionLinks: [{ type: core.Input }],
10073
+ previousLabel: [{ type: core.Input }],
10074
+ nextLabel: [{ type: core.Input }],
10075
+ autoHide: [{ type: core.Input }],
10076
+ pageChange: [{ type: core.Output }],
10077
+ showClass: [{ type: core.HostBinding, args: ['class.co-pagination',] }]
10232
10078
  };
10233
10079
 
10234
- // A pipe for prepending strings to other strings in view templates.
10235
- var PrependPipe = /** @class */ (function () {
10236
- function PrependPipe() {
10080
+ var LARGE_NUMBER = 999999999;
10081
+ var PaginatePipe = /** @class */ (function () {
10082
+ function PaginatePipe(paginateService) {
10083
+ this.paginateService = paginateService;
10084
+ // store the values from the last time the pipe
10085
+ this.state = {};
10237
10086
  }
10238
- PrependPipe.prototype.transform = function (value, prepend) {
10239
- if (!value) {
10240
- return "";
10087
+ PaginatePipe.prototype.transform = function (collection, args) {
10088
+ // When an observable is passed through the AsyncPipe, it will output
10089
+ // `null` until the subscription resolves. In this case, we want to
10090
+ // use the cached data from the `state` object to prevent the NgFor
10091
+ // from flashing empty until the real values arrive.
10092
+ if (!(collection instanceof Array)) {
10093
+ var _id = args.id || this.paginateService.DEFAULT_ID;
10094
+ if (this.state[_id]) {
10095
+ return this.state[_id].slice;
10096
+ }
10097
+ else {
10098
+ return collection;
10099
+ }
10241
10100
  }
10242
- if (!prepend) {
10243
- return value;
10101
+ var serverSideMode = args.totalItems !== undefined;
10102
+ var instance = this._createInstance(collection, args);
10103
+ var id = instance.id;
10104
+ var start;
10105
+ var end;
10106
+ var perPage = instance.itemsPerPage;
10107
+ this.paginateService.register(instance);
10108
+ if (!serverSideMode && collection instanceof Array) {
10109
+ perPage = perPage || LARGE_NUMBER;
10110
+ start = (instance.currentPage - 1) * perPage;
10111
+ end = start + perPage;
10112
+ var isIdentical = this._stateIsIdentical(id, collection, start, end);
10113
+ if (isIdentical) {
10114
+ return this.state[id].slice;
10115
+ }
10116
+ else {
10117
+ var slice = collection.slice(start, end);
10118
+ this._saveState(id, collection, slice, start, end);
10119
+ this.paginateService.change.next(id);
10120
+ return slice;
10121
+ }
10244
10122
  }
10245
- return prepend + value;
10123
+ // save the state for server-side collection to avoid null
10124
+ // flash as new data loads.
10125
+ this._saveState(id, collection, collection, start, end);
10126
+ return collection;
10246
10127
  };
10247
- return PrependPipe;
10248
- }());
10249
- PrependPipe.decorators = [
10250
- { type: core.Pipe, args: [{ name: "prepend" },] }
10251
- ];
10252
-
10253
- var PrependPipeModule = /** @class */ (function () {
10254
- function PrependPipeModule() {
10255
- }
10256
- return PrependPipeModule;
10128
+ // Create an IPaginationInstance object, using defaults for any optional properties not supplied.
10129
+ PaginatePipe.prototype._createInstance = function (collection, args) {
10130
+ var config = args;
10131
+ this._checkConfig(config);
10132
+ return {
10133
+ id: config.id || this.paginateService.DEFAULT_ID,
10134
+ itemsPerPage: config.itemsPerPage || 0,
10135
+ currentPage: config.currentPage || 1,
10136
+ totalItems: config.totalItems || collection.length
10137
+ };
10138
+ };
10139
+ // Ensure the argument passed to the filter contains the required properties.
10140
+ PaginatePipe.prototype._checkConfig = function (config) {
10141
+ var required = ["itemsPerPage", "currentPage"];
10142
+ var missing = required.filter(function (prop) { return !config.hasOwnProperty(prop); });
10143
+ if (0 < missing.length) {
10144
+ throw new Error("PaginatePipe: Argument is missing the following required properties: " + missing.join(", "));
10145
+ }
10146
+ };
10147
+ /**
10148
+ * To avoid returning a brand new array each time the pipe is run, we store the state of the sliced
10149
+ * array for a given id. This means that the next time the pipe is run on this collection & id, we just
10150
+ * need to check that the collection, start and end points are all identical, and if so, return the
10151
+ * last sliced array.
10152
+ */
10153
+ PaginatePipe.prototype._saveState = function (id, collection, slice, start, end) {
10154
+ this.state[id] = {
10155
+ collection: collection,
10156
+ size: collection.length,
10157
+ slice: slice,
10158
+ start: start,
10159
+ end: end
10160
+ };
10161
+ };
10162
+ // For a given id, returns true if the collection, size, start and end values are identical.
10163
+ PaginatePipe.prototype._stateIsIdentical = function (id, collection, start, end) {
10164
+ var state = this.state[id];
10165
+ if (!state) {
10166
+ return false;
10167
+ }
10168
+ return state.collection === collection &&
10169
+ state.size === collection.length &&
10170
+ state.start === start &&
10171
+ state.end === end;
10172
+ };
10173
+ return PaginatePipe;
10257
10174
  }());
10258
- PrependPipeModule.decorators = [
10259
- { type: core.NgModule, args: [{
10260
- declarations: [
10261
- PrependPipe
10262
- ],
10263
- exports: [
10264
- PrependPipe
10265
- ]
10175
+ PaginatePipe.decorators = [
10176
+ { type: core.Pipe, args: [{
10177
+ name: 'paginate',
10178
+ pure: false
10266
10179
  },] }
10267
- ];
10180
+ ];
10181
+ PaginatePipe.ctorParameters = function () { return [
10182
+ { type: PaginationService }
10183
+ ]; };
10268
10184
 
10269
- var FilterItemModule = /** @class */ (function () {
10270
- function FilterItemModule() {
10185
+ var PaginationModule = /** @class */ (function () {
10186
+ function PaginationModule() {
10271
10187
  }
10272
- return FilterItemModule;
10188
+ return PaginationModule;
10273
10189
  }());
10274
- FilterItemModule.decorators = [
10190
+ PaginationModule.decorators = [
10275
10191
  { type: core.NgModule, args: [{
10276
10192
  imports: [
10277
- common.CommonModule,
10278
- CollapsibleModule,
10279
- InputTextModule,
10280
- InputCheckboxMultiSelectModule,
10281
- InputCheckboxModule,
10282
- IconModule,
10283
- scrolling.ScrollingModule,
10284
- AppendPipeModule,
10285
- PrependPipeModule,
10286
- InputTextModule,
10287
- InputRadioButtonModule
10193
+ common.CommonModule
10194
+ ],
10195
+ providers: [
10196
+ PaginationService
10288
10197
  ],
10289
10198
  declarations: [
10290
- FilterItemComponent
10199
+ PaginationComponent,
10200
+ PaginatePipe
10291
10201
  ],
10292
10202
  exports: [
10293
- FilterItemComponent
10203
+ PaginationComponent,
10204
+ PaginatePipe
10294
10205
  ]
10295
10206
  },] }
10296
10207
  ];
10297
10208
 
10298
- // Human-readable JS keyboard codes, as in KeyboardEvent.key string values.
10299
- var KeyboardKey;
10300
- (function (KeyboardKey) {
10301
- KeyboardKey["Down"] = "ArrowDown";
10302
- KeyboardKey["Up"] = "ArrowUp";
10303
- KeyboardKey["Left"] = "ArrowLeft";
10304
- KeyboardKey["Right"] = "ArrowRight";
10305
- KeyboardKey["Tab"] = "Tab";
10306
- KeyboardKey["Escape"] = "Escape";
10307
- KeyboardKey["Enter"] = "Enter";
10308
- KeyboardKey["Home"] = "Home";
10309
- KeyboardKey["End"] = "End";
10310
- KeyboardKey["Delete"] = "Delete";
10311
- KeyboardKey["Insert"] = "Insert";
10312
- KeyboardKey["ShiftLeft"] = "ShiftLeft";
10313
- KeyboardKey["ShiftRight"] = "ShiftRight";
10314
- KeyboardKey["Backspace"] = "Backspace";
10315
- KeyboardKey["SpaceBar"] = "Space";
10316
- KeyboardKey["Period"] = "Period";
10317
- KeyboardKey["DecimalPoint"] = "NumpadDecimal";
10318
- KeyboardKey["SemiColon"] = "Semicolon";
10319
- KeyboardKey["ControlRight"] = "ControlRight";
10320
- KeyboardKey["ControlLeft"] = "ControlLeft";
10321
- KeyboardKey["Comma"] = "Comma";
10322
- ////Minus,
10323
- ////MinusFireFox,
10324
- ////Substract,
10325
- KeyboardKey["Zero"] = "Digit0";
10326
- KeyboardKey["One"] = "Digit1";
10327
- KeyboardKey["Two"] = "Digit2";
10328
- KeyboardKey["Three"] = "Digit3";
10329
- KeyboardKey["Four"] = "Digit4";
10330
- KeyboardKey["Five"] = "Digit5";
10331
- KeyboardKey["Six"] = "Digit6";
10332
- KeyboardKey["Seven"] = "Digit7";
10333
- KeyboardKey["Eight"] = "Digit8";
10334
- KeyboardKey["Nine"] = "Digit9";
10335
- KeyboardKey["NumpadZero"] = "Numpad0";
10336
- KeyboardKey["NumpadOne"] = "Numpad1";
10337
- KeyboardKey["NumpadTwo"] = "Numpad2";
10338
- KeyboardKey["NumpadThree"] = "Numpad3";
10339
- KeyboardKey["NumpadFour"] = "Numpad4";
10340
- KeyboardKey["NumpadFive"] = "Numpad5";
10341
- KeyboardKey["NumpadSix"] = "Numpad6";
10342
- KeyboardKey["NumpadSeven"] = "Numpad7";
10343
- KeyboardKey["NumpadEight"] = "Numpad8";
10344
- KeyboardKey["NumpadNine"] = "Numpad9";
10345
- KeyboardKey["A"] = "KeyA";
10346
- KeyboardKey["B"] = "KeyB";
10347
- KeyboardKey["C"] = "KeyC";
10348
- KeyboardKey["D"] = "KeyD";
10349
- KeyboardKey["E"] = "KeyE";
10350
- KeyboardKey["F"] = "KeyF";
10351
- KeyboardKey["G"] = "KeyG";
10352
- KeyboardKey["H"] = "KeyH";
10353
- KeyboardKey["I"] = "KeyI";
10354
- KeyboardKey["J"] = "KeyJ";
10355
- KeyboardKey["K"] = "KeyK";
10356
- KeyboardKey["L"] = "KeyL";
10357
- KeyboardKey["M"] = "KeyM";
10358
- KeyboardKey["N"] = "KeyN";
10359
- KeyboardKey["O"] = "KeyO";
10360
- KeyboardKey["P"] = "KeyP";
10361
- KeyboardKey["Q"] = "KeyQ";
10362
- KeyboardKey["R"] = "KeyR";
10363
- KeyboardKey["S"] = "KeyS";
10364
- KeyboardKey["T"] = "KeyT";
10365
- KeyboardKey["U"] = "KeyU";
10366
- KeyboardKey["V"] = "KeyV";
10367
- KeyboardKey["W"] = "KeyW";
10368
- KeyboardKey["X"] = "KeyX";
10369
- KeyboardKey["Y"] = "KeyY";
10370
- KeyboardKey["Z"] = "KeyZ";
10371
- })(KeyboardKey || (KeyboardKey = {}));
10372
-
10373
- var ClickOutsideMasterService = /** @class */ (function () {
10374
- function ClickOutsideMasterService(_ngZone) {
10375
- var _this = this;
10376
- this._ngZone = _ngZone;
10377
- this._clickOutsideRefs = [];
10378
- this.onClick = function (event) {
10379
- _this._currentClick = event;
10380
- var first = _this._clickOutsideRefs[0];
10381
- var targets = _this._clickOutsideRefs.filter(function (co) { return co.alwaysTrigger; });
10382
- if (first) {
10383
- targets.push(first);
10384
- }
10385
- setTimeout(function () {
10386
- targets.forEach(function (clickOutside) { return _this.checkEmit(clickOutside, event); });
10387
- });
10388
- };
10389
- this.onKeyDown = function (event) {
10390
- if (event.key === KeyboardKey.Escape) {
10391
- var first = _this._clickOutsideRefs[0];
10392
- if (first) {
10393
- _this.checkEmit(first, event, true);
10394
- }
10395
- }
10396
- };
10397
- document.addEventListener('click', this.onClick, true);
10398
- window.addEventListener('keydown', this.onKeyDown, EventUtils.passiveBubble);
10209
+ var SimpleGridCellComponent = /** @class */ (function () {
10210
+ function SimpleGridCellComponent(_changeDetector) {
10211
+ this._changeDetector = _changeDetector;
10212
+ this.defaultTextAlign = exports.ColumnAlign.Left;
10213
+ this.editMode = false;
10214
+ this.cellClick = new core.EventEmitter();
10215
+ this._fieldEditMode = false;
10216
+ this._focused = false;
10399
10217
  }
10400
- Object.defineProperty(ClickOutsideMasterService.prototype, "currentClick", {
10401
- get: function () {
10402
- return this._currentClick;
10218
+ Object.defineProperty(SimpleGridCellComponent.prototype, "editTemplateContent", {
10219
+ set: function (template) {
10220
+ if (template) {
10221
+ this._editTemplate = template;
10222
+ this._setFocusComponent();
10223
+ }
10403
10224
  },
10404
10225
  enumerable: false,
10405
10226
  configurable: true
10406
10227
  });
10407
- ClickOutsideMasterService.prototype.ngOnDestroy = function () {
10408
- document.removeEventListener('click', this.onClick, true);
10409
- window.removeEventListener('keydown', this.onKeyDown, EventUtils.passiveBubble);
10410
- };
10411
- ClickOutsideMasterService.prototype.checkEmit = function (clickOutside, event, force) {
10412
- if (clickOutside && (clickOutside.currentClick !== this.currentClick || force) && this._clickOutsideRefs.indexOf(clickOutside) !== -1) {
10413
- this._ngZone.run(function () { return clickOutside.clickOutside.emit(event); });
10414
- }
10415
- };
10416
- ClickOutsideMasterService.prototype.addClickOutside = function (clickOutside) {
10417
- this.removeClickOutside(clickOutside);
10418
- this._clickOutsideRefs.unshift(clickOutside);
10419
- };
10420
- ClickOutsideMasterService.prototype.removeClickOutside = function (clickOutside) {
10421
- ArrayUtils.RemoveElement(clickOutside, this._clickOutsideRefs);
10422
- };
10423
- return ClickOutsideMasterService;
10424
- }());
10425
- ClickOutsideMasterService.decorators = [
10426
- { type: core.Injectable }
10427
- ];
10428
- ClickOutsideMasterService.ctorParameters = function () { return [
10429
- { type: core.NgZone }
10430
- ]; };
10431
-
10432
- var ClickOutsideDirective = /** @class */ (function () {
10433
- function ClickOutsideDirective(elementRef, _ngZone, _master) {
10434
- var _this = this;
10435
- this.elementRef = elementRef;
10436
- this._ngZone = _ngZone;
10437
- this._master = _master;
10438
- this.clickOutside = new core.EventEmitter();
10439
- this._enabled = true;
10440
- this._initialized = false;
10441
- this.onClick = function (event) {
10442
- if (_this._enabled) {
10443
- _this._currentClick = event;
10228
+ Object.defineProperty(SimpleGridCellComponent.prototype, "noEditTemplateContent", {
10229
+ set: function (template) {
10230
+ if (template) {
10231
+ this._template = template;
10232
+ this._setFocusComponent();
10444
10233
  }
10445
- };
10446
- }
10447
- Object.defineProperty(ClickOutsideDirective.prototype, "currentClick", {
10448
- get: function () {
10449
- return this._currentClick;
10450
10234
  },
10451
10235
  enumerable: false,
10452
10236
  configurable: true
10453
10237
  });
10454
- Object.defineProperty(ClickOutsideDirective.prototype, "enabled", {
10455
- set: function (enabled) {
10456
- enabled = enabled === undefined || enabled;
10457
- // noinspection SuspiciousTypeOfGuard
10458
- if (typeof enabled === 'boolean' && this._enabled !== enabled) {
10459
- this._enabled = enabled;
10460
- if (this._initialized) {
10461
- this._enabled ? this._master.addClickOutside(this) : this._master.removeClickOutside(this);
10462
- }
10238
+ Object.defineProperty(SimpleGridCellComponent.prototype, "noTemplateContent", {
10239
+ set: function (template) {
10240
+ if (template) {
10241
+ this._inputTemplate = template;
10242
+ this._setFocusComponent();
10463
10243
  }
10464
10244
  },
10465
10245
  enumerable: false,
10466
10246
  configurable: true
10467
10247
  });
10468
- ClickOutsideDirective.prototype.ngAfterViewInit = function () {
10469
- var _this = this;
10470
- setTimeout(function () {
10471
- _this._ngZone.runOutsideAngular(function () {
10472
- if (_this.elementRef && _this.elementRef.nativeElement) {
10473
- _this.elementRef.nativeElement.addEventListener('click', _this.onClick, EventUtils.passiveCapture);
10474
- if (_this._enabled) {
10475
- _this._master.addClickOutside(_this);
10476
- }
10477
- _this._initialized = true;
10478
- }
10479
- });
10480
- });
10481
- };
10482
- ClickOutsideDirective.prototype.ngOnDestroy = function () {
10483
- this._master.removeClickOutside(this);
10484
- this.elementRef.nativeElement.removeEventListener('click', this.onClick, EventUtils.passiveCapture);
10485
- this.elementRef = undefined;
10486
- };
10487
- return ClickOutsideDirective;
10488
- }());
10489
- ClickOutsideDirective.decorators = [
10490
- { type: core.Directive, args: [{
10491
- selector: "[clickOutside]",
10492
- exportAs: 'clickOutside'
10493
- },] }
10494
- ];
10495
- ClickOutsideDirective.ctorParameters = function () { return [
10496
- { type: core.ElementRef },
10497
- { type: core.NgZone },
10498
- { type: ClickOutsideMasterService }
10499
- ]; };
10500
- ClickOutsideDirective.propDecorators = {
10501
- enabled: [{ type: core.Input, args: ["clickOutside",] }],
10502
- alwaysTrigger: [{ type: core.Input }],
10503
- clickOutside: [{ type: core.Output }]
10504
- };
10505
- __decorate([
10506
- InputBoolean()
10507
- ], ClickOutsideDirective.prototype, "alwaysTrigger", void 0);
10508
-
10509
- var ClickoutsideModule = /** @class */ (function () {
10510
- function ClickoutsideModule() {
10511
- }
10512
- return ClickoutsideModule;
10513
- }());
10514
- ClickoutsideModule.decorators = [
10515
- { type: core.NgModule, args: [{
10516
- declarations: [
10517
- ClickOutsideDirective
10518
- ],
10519
- providers: [
10520
- ClickOutsideMasterService
10521
- ],
10522
- exports: [
10523
- ClickOutsideDirective
10524
- ]
10525
- },] }
10526
- ];
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", {
10248
+ Object.defineProperty(SimpleGridCellComponent.prototype, "fieldEditMode", {
10534
10249
  get: function () {
10535
- return PaginationService.DEFAULT_ID;
10250
+ return this._fieldEditMode;
10251
+ },
10252
+ set: function (value) {
10253
+ this._fieldEditMode = value;
10254
+ this._setFocusComponent();
10536
10255
  },
10537
10256
  enumerable: false,
10538
10257
  configurable: true
10539
10258
  });
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
- }
10259
+ SimpleGridCellComponent.prototype.showClass = function () {
10260
+ return true;
10554
10261
  };
10555
- // Returns the current page number.
10556
- PaginationService.prototype.getCurrentPage = function (id) {
10557
- if (this.instances[id]) {
10558
- return this.instances[id].currentPage;
10262
+ SimpleGridCellComponent.prototype.handleClick = function (event) {
10263
+ if (this.column && !this.column.readonly) {
10264
+ this.cellClick.next();
10559
10265
  }
10560
10266
  };
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);
10267
+ SimpleGridCellComponent.prototype._setFocusComponent = function () {
10268
+ if (this.editMode && this.fieldEditMode) {
10269
+ var element = this._getElement();
10270
+ if (element) {
10271
+ var focusEvent = this._createNewEvent(element, 'focus');
10272
+ element.focus();
10273
+ element.dispatchEvent(focusEvent);
10274
+ this._focused = true;
10569
10275
  }
10570
10276
  }
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);
10277
+ else {
10278
+ if (this._focused) {
10279
+ var element = this._getElement();
10280
+ if (element) {
10281
+ var blurEvent = this._createNewEvent(element, 'blur');
10282
+ element.blur();
10283
+ element.dispatchEvent(blurEvent);
10284
+ }
10285
+ this._focused = false;
10286
+ }
10577
10287
  }
10288
+ this._detectChanges();
10578
10289
  };
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);
10290
+ SimpleGridCellComponent.prototype._getFirstFormInput = function (parent) {
10291
+ if (parent) {
10292
+ var collection_1 = Array.from(parent.getElementsByTagName('input'));
10293
+ var otherCollection = Array.from(parent.getElementsByTagName('textarea'));
10294
+ otherCollection.map(function (o) { return collection_1.push(o); });
10295
+ if (collection_1.length > 0) {
10296
+ return collection_1[0];
10297
+ }
10584
10298
  }
10585
10299
  };
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]);
10300
+ SimpleGridCellComponent.prototype._createNewEvent = function (element, eventType) {
10301
+ var event;
10302
+ if ("createEvent" in document) {
10303
+ event = document.createEvent("Event");
10304
+ event.initEvent(eventType, true, true);
10594
10305
  }
10595
- return {};
10306
+ else if ("Event" in window) {
10307
+ event = new Event(eventType, { bubbles: true, cancelable: true });
10308
+ }
10309
+ return event;
10596
10310
  };
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;
10311
+ SimpleGridCellComponent.prototype._getElement = function () {
10312
+ var templ;
10313
+ if (this._editTemplate) {
10314
+ templ = this._editTemplate;
10315
+ }
10316
+ else if (this._template) {
10317
+ templ = this._template;
10318
+ }
10319
+ else {
10320
+ templ = this._inputTemplate;
10321
+ }
10322
+ if (templ) {
10323
+ if (templ && templ.elementRef) {
10324
+ var inputElement = this._getFirstFormInput(templ.elementRef.nativeElement.parentElement);
10325
+ if (inputElement) {
10326
+ return inputElement;
10327
+ }
10607
10328
  }
10608
10329
  }
10609
- return changed;
10610
10330
  };
10611
- return PaginationService;
10331
+ SimpleGridCellComponent.prototype._detectChanges = function () {
10332
+ this._changeDetector.detectChanges();
10333
+ };
10334
+ return SimpleGridCellComponent;
10612
10335
  }());
10613
- PaginationService.DEFAULT_ID = "DEFAULT_PAGINATION_ID";
10614
- PaginationService.decorators = [
10615
- { type: core.Injectable }
10336
+ SimpleGridCellComponent.decorators = [
10337
+ { type: core.Component, args: [{
10338
+ selector: "co-simple-grid-cell",
10339
+ template: "\n <div class=\"simple-grid-column-cell-value\" [ngClass]=\"column.textAlign ? column.textAlign : defaultTextAlign\">\n <ng-container *ngIf=\"editMode; else noInlineEdit\">\n <ng-container #editTemplate *ngIf=\"column.editTemplate; else noEditTemplate\"\n [ngTemplateOutlet]=\"column.editTemplate\"\n [ngTemplateOutletContext]=\"{value: row[column.field], row: row}\"></ng-container>\n <ng-template #noEditTemplate>\n <ng-container *ngIf=\"column.template; else noTemplate\">\n <ng-container [ngTemplateOutlet]=\"column.template\"\n [ngTemplateOutletContext]=\"{value: row[column.field], row: row}\"></ng-container>\n </ng-container>\n <ng-template #noTemplate>\n <co-input-text [(model)]=\"row[column.field]\" [required]=\"column.required\"></co-input-text>\n </ng-template>\n </ng-template>\n </ng-container>\n <ng-template #noInlineEdit>\n <ng-container *ngIf=\"column.template; else noTemplate\">\n <ng-container [ngTemplateOutlet]=\"column.template\"\n [ngTemplateOutletContext]=\"{value: row[column.field], row: row}\"></ng-container>\n </ng-container>\n <ng-template #noTemplate>\n <span [textContent]=\"column.getFieldValue(row[column.field])\"></span>\n </ng-template>\n </ng-template>\n </div>\n ",
10340
+ encapsulation: core.ViewEncapsulation.None
10341
+ },] }
10616
10342
  ];
10617
- PaginationService.ctorParameters = function () { return []; };
10343
+ SimpleGridCellComponent.ctorParameters = function () { return [
10344
+ { type: core.ChangeDetectorRef }
10345
+ ]; };
10346
+ SimpleGridCellComponent.propDecorators = {
10347
+ editTemplateContent: [{ type: core.ViewChild, args: ["editTemplate", { read: BaseInputComponent },] }],
10348
+ noEditTemplateContent: [{ type: core.ViewChild, args: ["noEditTemplate",] }],
10349
+ noTemplateContent: [{ type: core.ViewChild, args: ["noTemplate",] }],
10350
+ column: [{ type: core.Input }],
10351
+ row: [{ type: core.Input }],
10352
+ editMode: [{ type: core.Input }],
10353
+ fieldEditMode: [{ type: core.Input }],
10354
+ cellClick: [{ type: core.Output }],
10355
+ showClass: [{ type: core.HostBinding, args: ["class.co-simple-grid-cell",] }],
10356
+ handleClick: [{ type: core.HostListener, args: ['click', ['$event'],] }]
10357
+ };
10618
10358
 
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
- });
10359
+ var ObserveVisibilityDirective = /** @class */ (function () {
10360
+ function ObserveVisibilityDirective(_element) {
10361
+ this._element = _element;
10362
+ this.debounceTime = 0;
10363
+ this.threshold = 0;
10364
+ this.visible = new core.EventEmitter();
10365
+ this._subject = new rxjs.Subject();
10637
10366
  }
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
- }
10367
+ ObserveVisibilityDirective.prototype.ngOnInit = function () {
10368
+ this._createObserver();
10654
10369
  };
10655
- PaginationComponent.prototype.goToPreviousPage = function () {
10656
- if (!this.isOnFirstPage()) {
10657
- this.setCurrentPage(this.getCurrentPage() - 1);
10658
- }
10370
+ ObserveVisibilityDirective.prototype.ngAfterViewInit = function () {
10371
+ this._startObservingElements();
10659
10372
  };
10660
- PaginationComponent.prototype.goToNextPage = function () {
10661
- if (!this.isOnLastPage()) {
10662
- this.setCurrentPage(this.getCurrentPage() + 1);
10373
+ ObserveVisibilityDirective.prototype.ngOnDestroy = function () {
10374
+ if (this._observer) {
10375
+ this._observer.disconnect();
10376
+ this._observer = undefined;
10663
10377
  }
10378
+ this._subject.next();
10379
+ this._subject.complete();
10664
10380
  };
10665
- PaginationComponent.prototype.setCurrentPage = function (page) {
10666
- this.pageChange.emit(page);
10667
- };
10668
- PaginationComponent.prototype.isOnFirstPage = function () {
10669
- return this.getCurrentPage() === 1;
10381
+ ObserveVisibilityDirective.prototype._isVisible = function (element) {
10382
+ var _this = this;
10383
+ return new Promise(function (resolve) {
10384
+ var observer = new IntersectionObserver(function (_a) {
10385
+ var _b = __read(_a, 1), entry = _b[0];
10386
+ resolve(entry.isIntersecting && entry.intersectionRatio >= _this.threshold);
10387
+ observer.disconnect();
10388
+ });
10389
+ observer.observe(element);
10390
+ });
10670
10391
  };
10671
- PaginationComponent.prototype.isOnLastPage = function () {
10672
- return this.getLastPage() === this.getCurrentPage();
10392
+ ObserveVisibilityDirective.prototype._createObserver = function () {
10393
+ var _this = this;
10394
+ var options = {
10395
+ rootMargin: '0px',
10396
+ threshold: this.threshold,
10397
+ };
10398
+ var isIntersecting = function (entry) { return entry.isIntersecting || entry.intersectionRatio > 0; };
10399
+ this._observer = new IntersectionObserver(function (entries, observer) {
10400
+ entries.forEach(function (entry) {
10401
+ if (isIntersecting(entry)) {
10402
+ _this._subject.next({ entry: entry, observer: observer });
10403
+ }
10404
+ });
10405
+ }, options);
10673
10406
  };
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);
10407
+ ObserveVisibilityDirective.prototype._startObservingElements = function () {
10408
+ var _this = this;
10409
+ if (!this._observer) {
10410
+ return;
10681
10411
  }
10412
+ this._observer.observe(this._element.nativeElement);
10413
+ this._subject
10414
+ .pipe(operators.delay(this.debounceTime), operators.filter(Boolean))
10415
+ .subscribe(function (_a) {
10416
+ var entry = _a.entry, observer = _a.observer;
10417
+ return __awaiter(_this, void 0, void 0, function () {
10418
+ var target, isStillVisible;
10419
+ return __generator(this, function (_a) {
10420
+ switch (_a.label) {
10421
+ case 0:
10422
+ target = entry.target;
10423
+ return [4 /*yield*/, this._isVisible(target)];
10424
+ case 1:
10425
+ isStillVisible = _a.sent();
10426
+ if (isStillVisible) {
10427
+ this.visible.emit(target);
10428
+ observer.unobserve(target);
10429
+ }
10430
+ return [2 /*return*/];
10431
+ }
10432
+ });
10433
+ });
10434
+ });
10682
10435
  };
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
- }
10436
+ return ObserveVisibilityDirective;
10437
+ }());
10438
+ ObserveVisibilityDirective.decorators = [
10439
+ { type: core.Directive, args: [{
10440
+ selector: '[observeVisibility]',
10441
+ },] }
10442
+ ];
10443
+ ObserveVisibilityDirective.ctorParameters = function () { return [
10444
+ { type: core.ElementRef }
10445
+ ]; };
10446
+ ObserveVisibilityDirective.propDecorators = {
10447
+ debounceTime: [{ type: core.Input }],
10448
+ threshold: [{ type: core.Input }],
10449
+ visible: [{ type: core.Output }]
10450
+ };
10451
+
10452
+ var ObserveVisibilityModule = /** @class */ (function () {
10453
+ function ObserveVisibilityModule() {
10454
+ }
10455
+ return ObserveVisibilityModule;
10456
+ }());
10457
+ ObserveVisibilityModule.decorators = [
10458
+ { type: core.NgModule, args: [{
10459
+ declarations: [
10460
+ ObserveVisibilityDirective
10461
+ ],
10462
+ exports: [
10463
+ ObserveVisibilityDirective
10464
+ ]
10465
+ },] }
10466
+ ];
10467
+
10468
+ var SimpleGridModule = /** @class */ (function () {
10469
+ function SimpleGridModule() {
10470
+ }
10471
+ return SimpleGridModule;
10472
+ }());
10473
+ SimpleGridModule.decorators = [
10474
+ { type: core.NgModule, args: [{
10475
+ imports: [
10476
+ common.CommonModule,
10477
+ dragDrop.DragDropModule,
10478
+ GridToolbarModule,
10479
+ InputTextModule,
10480
+ FormModule,
10481
+ ObserveVisibilityModule,
10482
+ PaginationModule
10483
+ ],
10484
+ declarations: [
10485
+ SimpleGridComponent,
10486
+ SimpleGridCellComponent,
10487
+ SimpleGridColumnDirective
10488
+ ],
10489
+ exports: [
10490
+ SimpleGridComponent,
10491
+ SimpleGridCellComponent,
10492
+ SimpleGridColumnDirective
10493
+ ]
10494
+ },] }
10495
+ ];
10496
+
10497
+ var FilterItemComponent = /** @class */ (function () {
10498
+ function FilterItemComponent(iconService) {
10499
+ this.iconService = iconService;
10500
+ this.icons = exports.CoreComponentsIcon;
10501
+ this.initialLimit = 10;
10502
+ this.expanded = false;
10503
+ // Set to false to use filter item with a multi selectable collection. Set to true to specify custom content
10504
+ this.customContent = false;
10505
+ // Set to true to show all results. Set to false to get 'show more' and 'show less' buttons to expand and contract.
10506
+ this.showAllResults = false;
10507
+ this.singleSelect = false;
10508
+ this.searchPlaceholder = 'Search...';
10509
+ this.showMoreLabel = 'Show more';
10510
+ this.showLessLabel = 'Show less';
10511
+ this.noResultsLabel = "No results";
10512
+ this.collectionChange = new core.EventEmitter();
10513
+ this.filteredCollection = [];
10514
+ this.limitTo = 10;
10515
+ this.filterText = "";
10516
+ this._collection = [];
10517
+ }
10518
+ Object.defineProperty(FilterItemComponent.prototype, "collection", {
10519
+ get: function () {
10520
+ return this._collection;
10521
+ },
10522
+ set: function (value) {
10523
+ var _a;
10524
+ this._collection = value;
10525
+ this.filteredCollection = (_a = this._collection) === null || _a === void 0 ? void 0 : _a.slice();
10526
+ },
10527
+ enumerable: false,
10528
+ configurable: true
10529
+ });
10530
+ FilterItemComponent.prototype.showClass = function () {
10531
+ return true;
10695
10532
  };
10696
- PaginationComponent.prototype.getCurrentPage = function () {
10697
- return this._paginationService.getCurrentPage(this.id);
10533
+ FilterItemComponent.prototype.ngOnInit = function () {
10534
+ this.setToInitialLimit();
10698
10535
  };
10699
- PaginationComponent.prototype.getLastPage = function () {
10700
- var instance = this._paginationService.getInstance(this.id);
10701
- return Math.ceil(instance.totalItems / instance.itemsPerPage);
10536
+ FilterItemComponent.prototype.setToInitialLimit = function () {
10537
+ this.limitTo = this.initialLimit;
10702
10538
  };
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;
10539
+ FilterItemComponent.prototype.increaseLimit = function () {
10540
+ this.limitTo += 10;
10541
+ };
10542
+ FilterItemComponent.prototype.moreToShow = function () {
10543
+ var _a;
10544
+ if (this.showAllResults) {
10545
+ return false;
10711
10546
  }
10712
- else if (instance.currentPage < 1) {
10713
- return 1;
10547
+ return ((_a = this.filteredCollection) === null || _a === void 0 ? void 0 : _a.length) > this.limitTo;
10548
+ };
10549
+ FilterItemComponent.prototype.lessToShow = function () {
10550
+ var _a, _b;
10551
+ if (this.showAllResults) {
10552
+ return false;
10714
10553
  }
10715
- return instance.currentPage;
10554
+ return ((_a = this.filteredCollection) === null || _a === void 0 ? void 0 : _a.length) <= this.limitTo && ((_b = this.filteredCollection) === null || _b === void 0 ? void 0 : _b.length) > this.initialLimit;
10716
10555
  };
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
10556
+ FilterItemComponent.prototype.handleModelChange = function (model) {
10557
+ if (this.singleSelect) {
10558
+ this.collection.forEach(function (m) {
10559
+ if (m.code !== model.code && m.description !== model.description) {
10560
+ m.checked = false;
10561
+ }
10743
10562
  });
10744
- i++;
10745
10563
  }
10746
- return pages;
10564
+ model.checked = !model.checked;
10565
+ this.collectionChange.emit(this.collection);
10747
10566
  };
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;
10567
+ // Applies filter to the collection.
10568
+ FilterItemComponent.prototype.applyFilter = function (text) {
10569
+ var _a, _b;
10570
+ return __awaiter(this, void 0, void 0, function () {
10571
+ var _c, filterText, filteredItemCount;
10572
+ return __generator(this, function (_d) {
10573
+ switch (_d.label) {
10574
+ case 0:
10575
+ if (!(!isNaN(this.minSearchCharsToLoadCollection) && this.collectionLoadFn)) return [3 /*break*/, 3];
10576
+ if (!(text.length === this.minSearchCharsToLoadCollection && text.length > this.filterText.length)) return [3 /*break*/, 2];
10577
+ _c = this;
10578
+ return [4 /*yield*/, this.collectionLoadFn(text)];
10579
+ case 1:
10580
+ _c.collection = _d.sent();
10581
+ return [3 /*break*/, 3];
10582
+ case 2:
10583
+ if (text.length < this.minSearchCharsToLoadCollection) {
10584
+ this.collection = undefined;
10585
+ }
10586
+ _d.label = 3;
10587
+ case 3:
10588
+ this.filterText = text;
10589
+ if (!this.collection) {
10590
+ return [2 /*return*/, []];
10591
+ }
10592
+ filterText = (_a = this.filterText) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
10593
+ filteredItemCount = 0;
10594
+ this.filteredCollection = (_b = this.collection) === null || _b === void 0 ? void 0 : _b.filter(function (item) {
10595
+ var _a;
10596
+ var labelText = (_a = item.description) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
10597
+ var isHiddenByFilter = ((labelText === null || labelText === void 0 ? void 0 : labelText.indexOf(filterText)) === -1);
10598
+ if (isHiddenByFilter) {
10599
+ return false;
10600
+ }
10601
+ else {
10602
+ filteredItemCount++;
10603
+ return true;
10604
+ }
10605
+ });
10606
+ return [2 /*return*/];
10607
+ }
10608
+ });
10609
+ });
10610
+ };
10611
+ return FilterItemComponent;
10612
+ }());
10613
+ FilterItemComponent.decorators = [
10614
+ { type: core.Component, args: [{
10615
+ selector: "co-filter-item",
10616
+ template: "\n <div class=\"co-filter-item-header\">\n <co-collapsible\n [headerTitle]=\"placeholder\"\n [expandButtonLast]=\"true\"\n [iconData]=\"iconService.getIcon(icons.ArrowPointDown)\"\n [expanded]=\"expanded\"\n >\n <div class=\"co-filter-item-collapsable-content\">\n <div class=\"co-filter-item-custom-content\" *ngIf=\"customContent; else collectionContent\">\n <ng-content></ng-content>\n </div>\n <ng-template #collectionContent>\n <div class=\"co-filter-item-collection-content\">\n <co-input-text\n *ngIf=\"collection?.length > 10 || minSearchCharsToLoadCollection\"\n [placeholder]=\"searchPlaceholder\"\n [model]=\"filterText\"\n (modelChange)=\"applyFilter($event)\"\n >\n </co-input-text>\n <div class=\"no-results\" *ngIf=\"filteredCollection?.length === 0\">\n <span [textContent]=\"noResultsLabel\"></span>\n </div>\n <div class=\"co-filter-item-collection-results\">\n <ng-container\n *ngFor=\"let option of filteredCollection; let index = index\">\n <div class=\"co-filter-item-collection-result-item\" *ngIf=\"index < limitTo || showAllResults\">\n <co-input-checkbox *ngIf=\"!singleSelect\"\n [label]=\"option.description\"\n [model]=\"option.checked\"\n (modelChange)=\"handleModelChange(option)\"\n ></co-input-checkbox>\n <co-input-radio-button *ngIf=\"singleSelect\"\n [name]=\"'radiogroup'\"\n [label]=\"option.description\"\n [model]=\"option.checked\"\n (modelChange)=\"handleModelChange(option)\"\n ></co-input-radio-button>\n <div class=\"co-filter-item-amount\" *ngIf=\"option.count\"\n [textContent]=\"option.count.toString() | append: ')' | prepend: ' ('\"\n ></div>\n </div>\n\n </ng-container>\n </div>\n <div class=\"co-filter-show-more-or-less\" *ngIf=\"!showAllResults\">\n <div class=\"co-filter-show-more clickable\"\n *ngIf=\"moreToShow()\">\n <a (click)=\"increaseLimit()\">\n <co-icon [iconData]=\"iconService.getIcon(icons.ArrowPointDown)\"></co-icon>\n <span [textContent]=\"showMoreLabel\"></span>\n </a>\n </div>\n <div class=\"co-filter-show-less clickable\"\n *ngIf=\"lessToShow()\">\n <a (click)=\"setToInitialLimit()\">\n <co-icon [iconData]=\"iconService.getIcon(icons.ArrowPointUp)\"></co-icon>\n <span [textContent]=\"showLessLabel\"></span>\n </a>\n </div>\n </div>\n </div>\n </ng-template>\n </div>\n </co-collapsible>\n </div>\n\n ",
10617
+ encapsulation: core.ViewEncapsulation.None
10618
+ },] }
10619
+ ];
10620
+ FilterItemComponent.ctorParameters = function () { return [
10621
+ { type: IconCacheService }
10622
+ ]; };
10623
+ FilterItemComponent.propDecorators = {
10624
+ collection: [{ type: core.Input }],
10625
+ placeholder: [{ type: core.Input }],
10626
+ initialLimit: [{ type: core.Input }],
10627
+ expanded: [{ type: core.Input }],
10628
+ minSearchCharsToLoadCollection: [{ type: core.Input }],
10629
+ collectionLoadFn: [{ type: core.Input }],
10630
+ customContent: [{ type: core.Input }],
10631
+ showAllResults: [{ type: core.Input }],
10632
+ singleSelect: [{ type: core.Input }],
10633
+ searchPlaceholder: [{ type: core.Input }],
10634
+ showMoreLabel: [{ type: core.Input }],
10635
+ showLessLabel: [{ type: core.Input }],
10636
+ noResultsLabel: [{ type: core.Input }],
10637
+ collectionChange: [{ type: core.Output }],
10638
+ showClass: [{ type: core.HostBinding, args: ["class.co-filter-item",] }]
10639
+ };
10640
+
10641
+ // A pipe for prepending strings to other strings in view templates.
10642
+ var PrependPipe = /** @class */ (function () {
10643
+ function PrependPipe() {
10644
+ }
10645
+ PrependPipe.prototype.transform = function (value, prepend) {
10646
+ if (!value) {
10647
+ return "";
10753
10648
  }
10754
- else if (i === 1) {
10755
- return i;
10649
+ if (!prepend) {
10650
+ return value;
10756
10651
  }
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;
10652
+ return prepend + value;
10653
+ };
10654
+ return PrependPipe;
10655
+ }());
10656
+ PrependPipe.decorators = [
10657
+ { type: core.Pipe, args: [{ name: "prepend" },] }
10658
+ ];
10659
+
10660
+ var PrependPipeModule = /** @class */ (function () {
10661
+ function PrependPipeModule() {
10662
+ }
10663
+ return PrependPipeModule;
10664
+ }());
10665
+ PrependPipeModule.decorators = [
10666
+ { type: core.NgModule, args: [{
10667
+ declarations: [
10668
+ PrependPipe
10669
+ ],
10670
+ exports: [
10671
+ PrependPipe
10672
+ ]
10673
+ },] }
10674
+ ];
10675
+
10676
+ var FilterItemModule = /** @class */ (function () {
10677
+ function FilterItemModule() {
10678
+ }
10679
+ return FilterItemModule;
10680
+ }());
10681
+ FilterItemModule.decorators = [
10682
+ { type: core.NgModule, args: [{
10683
+ imports: [
10684
+ common.CommonModule,
10685
+ CollapsibleModule,
10686
+ InputTextModule,
10687
+ InputCheckboxMultiSelectModule,
10688
+ InputCheckboxModule,
10689
+ IconModule,
10690
+ scrolling.ScrollingModule,
10691
+ AppendPipeModule,
10692
+ PrependPipeModule,
10693
+ InputTextModule,
10694
+ InputRadioButtonModule
10695
+ ],
10696
+ declarations: [
10697
+ FilterItemComponent
10698
+ ],
10699
+ exports: [
10700
+ FilterItemComponent
10701
+ ]
10702
+ },] }
10703
+ ];
10704
+
10705
+ // Human-readable JS keyboard codes, as in KeyboardEvent.key string values.
10706
+ var KeyboardKey;
10707
+ (function (KeyboardKey) {
10708
+ KeyboardKey["Down"] = "ArrowDown";
10709
+ KeyboardKey["Up"] = "ArrowUp";
10710
+ KeyboardKey["Left"] = "ArrowLeft";
10711
+ KeyboardKey["Right"] = "ArrowRight";
10712
+ KeyboardKey["Tab"] = "Tab";
10713
+ KeyboardKey["Escape"] = "Escape";
10714
+ KeyboardKey["Enter"] = "Enter";
10715
+ KeyboardKey["Home"] = "Home";
10716
+ KeyboardKey["End"] = "End";
10717
+ KeyboardKey["Delete"] = "Delete";
10718
+ KeyboardKey["Insert"] = "Insert";
10719
+ KeyboardKey["ShiftLeft"] = "ShiftLeft";
10720
+ KeyboardKey["ShiftRight"] = "ShiftRight";
10721
+ KeyboardKey["Backspace"] = "Backspace";
10722
+ KeyboardKey["SpaceBar"] = "Space";
10723
+ KeyboardKey["Period"] = "Period";
10724
+ KeyboardKey["DecimalPoint"] = "NumpadDecimal";
10725
+ KeyboardKey["SemiColon"] = "Semicolon";
10726
+ KeyboardKey["ControlRight"] = "ControlRight";
10727
+ KeyboardKey["ControlLeft"] = "ControlLeft";
10728
+ KeyboardKey["Comma"] = "Comma";
10729
+ ////Minus,
10730
+ ////MinusFireFox,
10731
+ ////Substract,
10732
+ KeyboardKey["Zero"] = "Digit0";
10733
+ KeyboardKey["One"] = "Digit1";
10734
+ KeyboardKey["Two"] = "Digit2";
10735
+ KeyboardKey["Three"] = "Digit3";
10736
+ KeyboardKey["Four"] = "Digit4";
10737
+ KeyboardKey["Five"] = "Digit5";
10738
+ KeyboardKey["Six"] = "Digit6";
10739
+ KeyboardKey["Seven"] = "Digit7";
10740
+ KeyboardKey["Eight"] = "Digit8";
10741
+ KeyboardKey["Nine"] = "Digit9";
10742
+ KeyboardKey["NumpadZero"] = "Numpad0";
10743
+ KeyboardKey["NumpadOne"] = "Numpad1";
10744
+ KeyboardKey["NumpadTwo"] = "Numpad2";
10745
+ KeyboardKey["NumpadThree"] = "Numpad3";
10746
+ KeyboardKey["NumpadFour"] = "Numpad4";
10747
+ KeyboardKey["NumpadFive"] = "Numpad5";
10748
+ KeyboardKey["NumpadSix"] = "Numpad6";
10749
+ KeyboardKey["NumpadSeven"] = "Numpad7";
10750
+ KeyboardKey["NumpadEight"] = "Numpad8";
10751
+ KeyboardKey["NumpadNine"] = "Numpad9";
10752
+ KeyboardKey["A"] = "KeyA";
10753
+ KeyboardKey["B"] = "KeyB";
10754
+ KeyboardKey["C"] = "KeyC";
10755
+ KeyboardKey["D"] = "KeyD";
10756
+ KeyboardKey["E"] = "KeyE";
10757
+ KeyboardKey["F"] = "KeyF";
10758
+ KeyboardKey["G"] = "KeyG";
10759
+ KeyboardKey["H"] = "KeyH";
10760
+ KeyboardKey["I"] = "KeyI";
10761
+ KeyboardKey["J"] = "KeyJ";
10762
+ KeyboardKey["K"] = "KeyK";
10763
+ KeyboardKey["L"] = "KeyL";
10764
+ KeyboardKey["M"] = "KeyM";
10765
+ KeyboardKey["N"] = "KeyN";
10766
+ KeyboardKey["O"] = "KeyO";
10767
+ KeyboardKey["P"] = "KeyP";
10768
+ KeyboardKey["Q"] = "KeyQ";
10769
+ KeyboardKey["R"] = "KeyR";
10770
+ KeyboardKey["S"] = "KeyS";
10771
+ KeyboardKey["T"] = "KeyT";
10772
+ KeyboardKey["U"] = "KeyU";
10773
+ KeyboardKey["V"] = "KeyV";
10774
+ KeyboardKey["W"] = "KeyW";
10775
+ KeyboardKey["X"] = "KeyX";
10776
+ KeyboardKey["Y"] = "KeyY";
10777
+ KeyboardKey["Z"] = "KeyZ";
10778
+ })(KeyboardKey || (KeyboardKey = {}));
10779
+
10780
+ var ClickOutsideMasterService = /** @class */ (function () {
10781
+ function ClickOutsideMasterService(_ngZone) {
10782
+ var _this = this;
10783
+ this._ngZone = _ngZone;
10784
+ this._clickOutsideRefs = [];
10785
+ this.onClick = function (event) {
10786
+ _this._currentClick = event;
10787
+ var first = _this._clickOutsideRefs[0];
10788
+ var targets = _this._clickOutsideRefs.filter(function (co) { return co.alwaysTrigger; });
10789
+ if (first) {
10790
+ targets.push(first);
10763
10791
  }
10764
- else {
10765
- return i;
10792
+ setTimeout(function () {
10793
+ targets.forEach(function (clickOutside) { return _this.checkEmit(clickOutside, event); });
10794
+ });
10795
+ };
10796
+ this.onKeyDown = function (event) {
10797
+ if (event.key === KeyboardKey.Escape) {
10798
+ var first = _this._clickOutsideRefs[0];
10799
+ if (first) {
10800
+ _this.checkEmit(first, event, true);
10801
+ }
10766
10802
  }
10767
- }
10768
- else {
10769
- return i;
10803
+ };
10804
+ document.addEventListener('click', this.onClick, true);
10805
+ window.addEventListener('keydown', this.onKeyDown, EventUtils.passiveBubble);
10806
+ }
10807
+ Object.defineProperty(ClickOutsideMasterService.prototype, "currentClick", {
10808
+ get: function () {
10809
+ return this._currentClick;
10810
+ },
10811
+ enumerable: false,
10812
+ configurable: true
10813
+ });
10814
+ ClickOutsideMasterService.prototype.ngOnDestroy = function () {
10815
+ document.removeEventListener('click', this.onClick, true);
10816
+ window.removeEventListener('keydown', this.onKeyDown, EventUtils.passiveBubble);
10817
+ };
10818
+ ClickOutsideMasterService.prototype.checkEmit = function (clickOutside, event, force) {
10819
+ if (clickOutside && (clickOutside.currentClick !== this.currentClick || force) && this._clickOutsideRefs.indexOf(clickOutside) !== -1) {
10820
+ this._ngZone.run(function () { return clickOutside.clickOutside.emit(event); });
10770
10821
  }
10771
10822
  };
10772
- return PaginationComponent;
10823
+ ClickOutsideMasterService.prototype.addClickOutside = function (clickOutside) {
10824
+ this.removeClickOutside(clickOutside);
10825
+ this._clickOutsideRefs.unshift(clickOutside);
10826
+ };
10827
+ ClickOutsideMasterService.prototype.removeClickOutside = function (clickOutside) {
10828
+ ArrayUtils.RemoveElement(clickOutside, this._clickOutsideRefs);
10829
+ };
10830
+ return ClickOutsideMasterService;
10773
10831
  }());
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
- },] }
10832
+ ClickOutsideMasterService.decorators = [
10833
+ { type: core.Injectable }
10780
10834
  ];
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
- };
10835
+ ClickOutsideMasterService.ctorParameters = function () { return [
10836
+ { type: core.NgZone }
10837
+ ]; };
10795
10838
 
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;
10839
+ var ClickOutsideDirective = /** @class */ (function () {
10840
+ function ClickOutsideDirective(elementRef, _ngZone, _master) {
10841
+ var _this = this;
10842
+ this.elementRef = elementRef;
10843
+ this._ngZone = _ngZone;
10844
+ this._master = _master;
10845
+ this.clickOutside = new core.EventEmitter();
10846
+ this._enabled = true;
10847
+ this._initialized = false;
10848
+ this.onClick = function (event) {
10849
+ if (_this._enabled) {
10850
+ _this._currentClick = event;
10837
10851
  }
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
10852
  };
10853
+ }
10854
+ Object.defineProperty(ClickOutsideDirective.prototype, "currentClick", {
10855
+ get: function () {
10856
+ return this._currentClick;
10857
+ },
10858
+ enumerable: false,
10859
+ configurable: true
10860
+ });
10861
+ Object.defineProperty(ClickOutsideDirective.prototype, "enabled", {
10862
+ set: function (enabled) {
10863
+ enabled = enabled === undefined || enabled;
10864
+ // noinspection SuspiciousTypeOfGuard
10865
+ if (typeof enabled === 'boolean' && this._enabled !== enabled) {
10866
+ this._enabled = enabled;
10867
+ if (this._initialized) {
10868
+ this._enabled ? this._master.addClickOutside(this) : this._master.removeClickOutside(this);
10869
+ }
10870
+ }
10871
+ },
10872
+ enumerable: false,
10873
+ configurable: true
10874
+ });
10875
+ ClickOutsideDirective.prototype.ngAfterViewInit = function () {
10876
+ var _this = this;
10877
+ setTimeout(function () {
10878
+ _this._ngZone.runOutsideAngular(function () {
10879
+ if (_this.elementRef && _this.elementRef.nativeElement) {
10880
+ _this.elementRef.nativeElement.addEventListener('click', _this.onClick, EventUtils.passiveCapture);
10881
+ if (_this._enabled) {
10882
+ _this._master.addClickOutside(_this);
10883
+ }
10884
+ _this._initialized = true;
10885
+ }
10886
+ });
10887
+ });
10877
10888
  };
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;
10889
+ ClickOutsideDirective.prototype.ngOnDestroy = function () {
10890
+ this._master.removeClickOutside(this);
10891
+ this.elementRef.nativeElement.removeEventListener('click', this.onClick, EventUtils.passiveCapture);
10892
+ this.elementRef = undefined;
10888
10893
  };
10889
- return PaginatePipe;
10894
+ return ClickOutsideDirective;
10890
10895
  }());
10891
- PaginatePipe.decorators = [
10892
- { type: core.Pipe, args: [{
10893
- name: 'paginate',
10894
- pure: false
10896
+ ClickOutsideDirective.decorators = [
10897
+ { type: core.Directive, args: [{
10898
+ selector: "[clickOutside]",
10899
+ exportAs: 'clickOutside'
10895
10900
  },] }
10896
10901
  ];
10897
- PaginatePipe.ctorParameters = function () { return [
10898
- { type: PaginationService }
10899
- ]; };
10902
+ ClickOutsideDirective.ctorParameters = function () { return [
10903
+ { type: core.ElementRef },
10904
+ { type: core.NgZone },
10905
+ { type: ClickOutsideMasterService }
10906
+ ]; };
10907
+ ClickOutsideDirective.propDecorators = {
10908
+ enabled: [{ type: core.Input, args: ["clickOutside",] }],
10909
+ alwaysTrigger: [{ type: core.Input }],
10910
+ clickOutside: [{ type: core.Output }]
10911
+ };
10912
+ __decorate([
10913
+ InputBoolean()
10914
+ ], ClickOutsideDirective.prototype, "alwaysTrigger", void 0);
10900
10915
 
10901
- var PaginationModule = /** @class */ (function () {
10902
- function PaginationModule() {
10916
+ var ClickoutsideModule = /** @class */ (function () {
10917
+ function ClickoutsideModule() {
10903
10918
  }
10904
- return PaginationModule;
10919
+ return ClickoutsideModule;
10905
10920
  }());
10906
- PaginationModule.decorators = [
10921
+ ClickoutsideModule.decorators = [
10907
10922
  { type: core.NgModule, args: [{
10908
- imports: [
10909
- common.CommonModule
10923
+ declarations: [
10924
+ ClickOutsideDirective
10910
10925
  ],
10911
10926
  providers: [
10912
- PaginationService
10913
- ],
10914
- declarations: [
10915
- PaginationComponent,
10916
- PaginatePipe
10927
+ ClickOutsideMasterService
10917
10928
  ],
10918
10929
  exports: [
10919
- PaginationComponent,
10920
- PaginatePipe
10930
+ ClickOutsideDirective
10921
10931
  ]
10922
10932
  },] }
10923
10933
  ];
@@ -11024,13 +11034,13 @@
11024
11034
  exports.TileModule = TileModule;
11025
11035
  exports["ɵa"] = RippleModule;
11026
11036
  exports["ɵb"] = MD_RIPPLE_GLOBAL_OPTIONS;
11027
- exports["ɵba"] = SimpleGridCellComponent;
11028
- exports["ɵbb"] = PrependPipeModule;
11029
- exports["ɵbc"] = PrependPipe;
11030
- exports["ɵbd"] = ClickOutsideDirective;
11031
- exports["ɵbe"] = ClickOutsideMasterService;
11032
- exports["ɵbf"] = PaginationService;
11033
- exports["ɵbg"] = PaginatePipe;
11037
+ exports["ɵba"] = PaginationService;
11038
+ exports["ɵbb"] = PaginatePipe;
11039
+ exports["ɵbc"] = SimpleGridCellComponent;
11040
+ exports["ɵbd"] = PrependPipeModule;
11041
+ exports["ɵbe"] = PrependPipe;
11042
+ exports["ɵbf"] = ClickOutsideDirective;
11043
+ exports["ɵbg"] = ClickOutsideMasterService;
11034
11044
  exports["ɵc"] = CoRippleDirective;
11035
11045
  exports["ɵd"] = CoViewportRulerService;
11036
11046
  exports["ɵe"] = CoScrollDispatcherService;