ngx-easy-table
Version:
Angular easy table
1,296 lines (1,261 loc) • 118 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/cdk/drag-drop'), require('ngx-pagination'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/scrolling')) :
typeof define === 'function' && define.amd ? define('ngx-easy-table', ['exports', '@angular/common', '@angular/core', '@angular/cdk/drag-drop', 'ngx-pagination', 'rxjs', 'rxjs/operators', '@angular/cdk/scrolling'], factory) :
(global = global || self, factory(global['ngx-easy-table'] = {}, global.ng.common, global.ng.core, global.ng.cdk['drag-drop'], global.ngxPagination, global.rxjs, global.rxjs.operators, global.ng.cdk.scrolling));
}(this, function (exports, common, core, dragDrop, ngxPagination, rxjs, operators, scrolling) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function Columns() { }
if (false) {
/** @type {?} */
Columns.prototype.key;
/** @type {?} */
Columns.prototype.title;
/** @type {?|undefined} */
Columns.prototype.placeholder;
/** @type {?|undefined} */
Columns.prototype.width;
/** @type {?|undefined} */
Columns.prototype.cellTemplate;
/** @type {?|undefined} */
Columns.prototype.orderEnabled;
/** @type {?|undefined} */
Columns.prototype.orderEventOnly;
/** @type {?|undefined} */
Columns.prototype.searchEnabled;
/** @type {?|undefined} */
Columns.prototype.orderBy;
/** @type {?|undefined} */
Columns.prototype.cssClass;
/** @type {?|undefined} */
Columns.prototype.pinned;
/** @type {?|undefined} */
Columns.prototype.headerActionTemplate;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function Config() { }
if (false) {
/** @type {?} */
Config.prototype.searchEnabled;
/** @type {?} */
Config.prototype.headerEnabled;
/** @type {?} */
Config.prototype.orderEnabled;
/** @type {?|undefined} */
Config.prototype.orderEventOnly;
/** @type {?} */
Config.prototype.paginationEnabled;
/** @type {?|undefined} */
Config.prototype.exportEnabled;
/** @type {?} */
Config.prototype.clickEvent;
/** @type {?} */
Config.prototype.selectRow;
/** @type {?} */
Config.prototype.selectCol;
/** @type {?} */
Config.prototype.selectCell;
/** @type {?} */
Config.prototype.rows;
/** @type {?} */
Config.prototype.additionalActions;
/** @type {?} */
Config.prototype.serverPagination;
/** @type {?} */
Config.prototype.isLoading;
/** @type {?} */
Config.prototype.detailsTemplate;
/** @type {?} */
Config.prototype.groupRows;
/** @type {?} */
Config.prototype.paginationRangeEnabled;
/** @type {?} */
Config.prototype.collapseAllRows;
/** @type {?} */
Config.prototype.checkboxes;
/** @type {?|undefined} */
Config.prototype.radio;
/** @type {?} */
Config.prototype.resizeColumn;
/** @type {?} */
Config.prototype.fixedColumnWidth;
/** @type {?} */
Config.prototype.horizontalScroll;
/** @type {?} */
Config.prototype.draggable;
/** @type {?} */
Config.prototype.logger;
/** @type {?|undefined} */
Config.prototype.showDetailsArrow;
/** @type {?|undefined} */
Config.prototype.showContextMenu;
/** @type {?|undefined} */
Config.prototype.persistState;
/** @type {?|undefined} */
Config.prototype.paginationMaxSize;
/** @type {?|undefined} */
Config.prototype.threeWaySort;
/** @type {?|undefined} */
Config.prototype.columnReorder;
/** @type {?|undefined} */
Config.prototype.rowReorder;
/** @type {?|undefined} */
Config.prototype.infiniteScroll;
/** @type {?|undefined} */
Config.prototype.infiniteScrollThrottleTime;
/** @type {?} */
Config.prototype.tableLayout;
}
/** @enum {string} */
var STYLE = {
TINY: 'tiny',
BIG: 'big',
NORMAL: 'normal',
};
/** @enum {string} */
var THEME = {
LIGHT: 'light',
DARK: 'dark',
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {string} */
var Event = {
onPagination: 'onPagination',
onOrder: 'onOrder',
onGlobalSearch: 'onGlobalSearch',
onSearch: 'onSearch',
onClick: 'onClick',
onDoubleClick: 'onDoubleClick',
onCheckboxSelect: 'onCheckboxSelect',
onRadioSelect: 'onRadioSelect',
onCheckboxToggle: 'onCheckboxToggle',
onSelectAll: 'onSelectAll',
onInfiniteScrollEnd: 'onInfiniteScrollEnd',
onColumnResizeMouseDown: 'onColumnResizeMouseDown',
onColumnResizeMouseUp: 'onColumnResizeMouseUp',
onRowDrop: 'onRowDrop',
onRowCollapsedShow: 'onRowCollapsedShow',
onRowCollapsedHide: 'onRowCollapsedHide',
onRowContextMenu: 'onRowContextMenu',
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function Pagination() { }
if (false) {
/** @type {?} */
Pagination.prototype.limit;
/** @type {?} */
Pagination.prototype.offset;
/** @type {?} */
Pagination.prototype.count;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {string} */
var API = {
rowContextMenuClicked: 'rowContextMenuClicked',
setInputValue: 'setInputValue',
toolPanelClicked: 'toolPanelClicked',
toggleRowIndex: 'toggleRowIndex',
toggleCheckbox: 'toggleCheckbox',
onGlobalSearch: 'onGlobalSearch',
setPaginationCurrentPage: 'setPaginationCurrentPage',
getPaginationCurrentPage: 'getPaginationCurrentPage',
getPaginationTotalItems: 'getPaginationTotalItems',
getNumberOfRowsPerPage: 'getNumberOfRowsPerPage',
getPaginationLastPage: 'getPaginationLastPage',
setPaginationRange: 'setPaginationRange',
setPaginationPreviousLabel: 'setPaginationPreviousLabel',
setPaginationNextLabel: 'setPaginationNextLabel',
setPaginationDisplayLimit: 'setPaginationDisplayLimit',
setTableClass: 'setTableClass',
setRowClass: 'setRowClass',
setCellClass: 'setCellClass',
setRowStyle: 'setRowStyle',
setCellStyle: 'setCellStyle',
sortBy: 'sortBy',
};
/**
* @record
*/
function RowClass() { }
if (false) {
/** @type {?} */
RowClass.prototype.row;
/** @type {?} */
RowClass.prototype.className;
}
/**
* @record
*/
function CellClass() { }
if (false) {
/** @type {?} */
CellClass.prototype.row;
/** @type {?} */
CellClass.prototype.cell;
/** @type {?} */
CellClass.prototype.className;
}
/**
* @record
*/
function RowStyle() { }
if (false) {
/** @type {?} */
RowStyle.prototype.row;
/** @type {?} */
RowStyle.prototype.attr;
/** @type {?} */
RowStyle.prototype.value;
}
/**
* @record
*/
function CellStyle() { }
if (false) {
/** @type {?} */
CellStyle.prototype.row;
/** @type {?} */
CellStyle.prototype.cell;
/** @type {?} */
CellStyle.prototype.attr;
/** @type {?} */
CellStyle.prototype.value;
}
/**
* @record
*/
function APIDefinition() { }
if (false) {
/**
* @template B
* @param {?} event
* @return {?}
*/
APIDefinition.prototype.apiEvent = function (event) { };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var DefaultConfig = {
searchEnabled: false,
headerEnabled: true,
orderEnabled: true,
orderEventOnly: false,
paginationEnabled: true,
exportEnabled: false,
clickEvent: true,
selectRow: false,
selectCol: false,
selectCell: false,
rows: 10,
additionalActions: false,
serverPagination: false,
isLoading: false,
detailsTemplate: false,
groupRows: false,
paginationRangeEnabled: true,
collapseAllRows: false,
checkboxes: false,
radio: false,
resizeColumn: false,
fixedColumnWidth: true,
horizontalScroll: false,
draggable: false,
logger: false,
showDetailsArrow: false,
showContextMenu: false,
persistState: false,
paginationMaxSize: 5,
threeWaySort: false,
tableLayout: {
style: STYLE.NORMAL,
theme: THEME.LIGHT,
borderless: false,
hover: true,
striped: false,
},
};
var DefaultConfigService = /** @class */ (function () {
function DefaultConfigService() {
}
DefaultConfigService.config = DefaultConfig;
DefaultConfigService.decorators = [
{ type: core.Injectable }
];
return DefaultConfigService;
}());
if (false) {
/** @type {?} */
DefaultConfigService.config;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function PaginationRange() { }
if (false) {
/** @type {?} */
PaginationRange.prototype.page;
/** @type {?} */
PaginationRange.prototype.limit;
}
var PaginationComponent = /** @class */ (function () {
function PaginationComponent() {
this.updateRange = new core.EventEmitter();
this.ranges = [5, 10, 25, 50, 100];
this.showRange = false;
this.screenReaderPaginationLabel = 'Pagination';
this.screenReaderPageLabel = 'page';
this.screenReaderCurrentLabel = 'You are on page';
this.previousLabel = '';
this.nextLabel = '';
this.directionLinks = true;
}
/**
* @param {?} targetElement
* @return {?}
*/
PaginationComponent.prototype.onClick = /**
* @param {?} targetElement
* @return {?}
*/
function (targetElement) {
if (this.paginationRange && !this.paginationRange.nativeElement.contains(targetElement)) {
this.showRange = false;
}
};
/**
* @param {?} changes
* @return {?}
*/
PaginationComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var config = changes.config;
if (config && config.currentValue) {
this.selectedLimit = this.config.rows;
}
};
/**
* @param {?} page
* @return {?}
*/
PaginationComponent.prototype.onPageChange = /**
* @param {?} page
* @return {?}
*/
function (page) {
this.updateRange.emit({
page: page,
limit: this.selectedLimit,
});
};
/**
* @param {?} limit
* @param {?} callFromAPI
* @return {?}
*/
PaginationComponent.prototype.changeLimit = /**
* @param {?} limit
* @param {?} callFromAPI
* @return {?}
*/
function (limit, callFromAPI) {
if (!callFromAPI) {
this.showRange = !this.showRange;
}
this.selectedLimit = limit;
this.updateRange.emit({
page: 1,
limit: limit,
});
};
PaginationComponent.decorators = [
{ type: core.Component, args: [{
selector: 'pagination',
template: "<div class=\"ngx-pagination-wrapper\"\n [style.display]=\"config.paginationEnabled ? '' : 'none'\"\n [class.ngx-table__table--dark-pagination-wrapper]=\"config.tableLayout.theme === 'dark'\">\n <div class=\"ngx-pagination-steps\">\n <pagination-template\n #paginationDirective=\"paginationApi\"\n id=\"pagination-controls\"\n [id]=\"id\"\n [class.ngx-table__table--dark-pagination]=\"config.tableLayout.theme === 'dark'\"\n [maxSize]=\"config.paginationMaxSize || 5\"\n (pageChange)=\"onPageChange($event)\">\n <ul class=\"ngx-pagination\"\n role=\"navigation\"\n [attr.aria-label]=\"screenReaderPaginationLabel\"\n [class.responsive]=\"true\">\n <li class=\"pagination-previous\" [class.disabled]=\"paginationDirective.isFirstPage()\" *ngIf=\"directionLinks\">\n <a tabindex=\"0\" *ngIf=\"1 < paginationDirective.getCurrent()\" (keyup.enter)=\"paginationDirective.previous()\"\n (click)=\"paginationDirective.previous()\"\n [attr.aria-label]=\"previousLabel + ' ' + screenReaderPageLabel\">\n {{ previousLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </a>\n <span *ngIf=\"paginationDirective.isFirstPage()\">\n {{ previousLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </span>\n </li>\n <li class=\"small-screen\">\n {{ paginationDirective.getCurrent() }} / {{ paginationDirective.getLastPage() }}\n </li>\n <li [class.current]=\"paginationDirective.getCurrent() === page.value\"\n [class.ellipsis]=\"page.label === '...'\"\n *ngFor=\"let page of paginationDirective.pages\">\n <a tabindex=\"0\" (keyup.enter)=\"paginationDirective.setCurrent(page.value)\"\n (click)=\"paginationDirective.setCurrent(page.value)\"\n *ngIf=\"paginationDirective.getCurrent() !== page.value\">\n <span class=\"show-for-sr\">{{ screenReaderPageLabel }} </span>\n <span>{{ page.label }}</span>\n </a>\n <ng-container *ngIf=\"paginationDirective.getCurrent() === page.value\">\n <span class=\"show-for-sr\">{{ screenReaderCurrentLabel }} </span>\n <span>{{ page.label }}</span>\n </ng-container>\n </li>\n <li class=\"pagination-next\" [class.disabled]=\"paginationDirective.isLastPage()\" *ngIf=\"directionLinks\">\n <a tabindex=\"0\" *ngIf=\"!paginationDirective.isLastPage()\" (keyup.enter)=\"paginationDirective.next()\"\n (click)=\"paginationDirective.next()\"\n [attr.aria-label]=\"nextLabel + ' ' + screenReaderPageLabel\">\n {{ nextLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </a>\n <span *ngIf=\"paginationDirective.isLastPage()\">\n {{ nextLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </span>\n </li>\n </ul>\n </pagination-template>\n </div>\n <div class=\"ngx-pagination-range\"\n #paginationRange\n [class.ngx-table__table--dark-pagination-range]=\"config.tableLayout.theme === 'dark'\"\n *ngIf=\"config.paginationRangeEnabled\">\n <div class=\"ngx-dropdown ngx-pagination-range-dropdown\"\n id=\"rowAmount\">\n <div class=\"ngx-btn-group\">\n <div class=\"ngx-pagination-range-dropdown-button\"\n (click)=\"showRange = !showRange\">\n {{selectedLimit}} <i class=\"ngx-icon ngx-icon-arrow-down\"></i>\n </div>\n <ul class=\"ngx-menu\" *ngIf=\"showRange\">\n <li class=\"ngx-pagination-range-dropdown-button-item\"\n [class.ngx-pagination-range--selected]=\"limit === selectedLimit\"\n (click)=\"changeLimit(limit, false)\"\n *ngFor=\"let limit of ranges\">\n <span>{{limit}}</span>\n </li>\n </ul>\n </div>\n </div>\n </div>\n</div>\n",
changeDetection: core.ChangeDetectionStrategy.OnPush
}] }
];
PaginationComponent.propDecorators = {
paginationDirective: [{ type: core.ViewChild, args: ['paginationDirective', { static: true },] }],
paginationRange: [{ type: core.ViewChild, args: ['paginationRange', { static: false },] }],
pagination: [{ type: core.Input }],
config: [{ type: core.Input }],
id: [{ type: core.Input }],
updateRange: [{ type: core.Output }],
onClick: [{ type: core.HostListener, args: ['document:click', ['$event.target'],] }]
};
return PaginationComponent;
}());
if (false) {
/** @type {?} */
PaginationComponent.prototype.paginationDirective;
/** @type {?} */
PaginationComponent.prototype.paginationRange;
/** @type {?} */
PaginationComponent.prototype.pagination;
/** @type {?} */
PaginationComponent.prototype.config;
/** @type {?} */
PaginationComponent.prototype.id;
/** @type {?} */
PaginationComponent.prototype.updateRange;
/** @type {?} */
PaginationComponent.prototype.ranges;
/** @type {?} */
PaginationComponent.prototype.selectedLimit;
/** @type {?} */
PaginationComponent.prototype.showRange;
/** @type {?} */
PaginationComponent.prototype.screenReaderPaginationLabel;
/** @type {?} */
PaginationComponent.prototype.screenReaderPageLabel;
/** @type {?} */
PaginationComponent.prototype.screenReaderCurrentLabel;
/** @type {?} */
PaginationComponent.prototype.previousLabel;
/** @type {?} */
PaginationComponent.prototype.nextLabel;
/** @type {?} */
PaginationComponent.prototype.directionLinks;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var GroupRowsService = /** @class */ (function () {
function GroupRowsService() {
}
/**
* @template T
* @param {?} data
* @param {?} groupRowsBy
* @return {?}
*/
GroupRowsService.doGroupRows = /**
* @template T
* @param {?} data
* @param {?} groupRowsBy
* @return {?}
*/
function (data, groupRowsBy) {
/** @type {?} */
var grouped = [];
rxjs.from(data).pipe(operators.groupBy((/**
* @param {?} row
* @return {?}
*/
function (row) { return row[groupRowsBy]; })), operators.flatMap((/**
* @param {?} group
* @return {?}
*/
function (group) { return group.pipe(operators.reduce((/**
* @param {?} acc
* @param {?} curr
* @return {?}
*/
function (acc, curr) { return __spread(acc, [curr]); }), [])); }))).subscribe((/**
* @param {?} row
* @return {?}
*/
function (row) { return grouped.push(row); }));
return grouped;
};
GroupRowsService.decorators = [
{ type: core.Injectable }
];
return GroupRowsService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/* tslint:disable:no-useless-cast */
var StyleService = /** @class */ (function () {
function StyleService() {
}
/**
* @param {?} val
* @return {?}
*/
StyleService.prototype.setRowClass = /**
* @param {?} val
* @return {?}
*/
function (val) {
/** @type {?} */
var selector = "#table > tbody > tr:nth-child(" + val.row + ")";
/** @type {?} */
var row = (/** @type {?} */ (document.querySelector(selector)));
if (row) {
row.classList.add(val.className);
}
};
/**
* @param {?} val
* @return {?}
*/
StyleService.prototype.setCellClass = /**
* @param {?} val
* @return {?}
*/
function (val) {
/** @type {?} */
var selector = "#table > tbody > tr:nth-child(" + val.row + ") > td:nth-child(" + val.cell + ")";
/** @type {?} */
var cell = (/** @type {?} */ (document.querySelector(selector)));
if (cell) {
cell.classList.add(val.className);
}
};
/**
* @param {?} val
* @return {?}
*/
StyleService.prototype.setRowStyle = /**
* @param {?} val
* @return {?}
*/
function (val) {
/** @type {?} */
var selector = "#table > tbody > tr:nth-child(" + val.row + ")";
/** @type {?} */
var row = (/** @type {?} */ (document.querySelector(selector)));
if (row) {
// tslint:disable-next-line:no-string-literal
row.style[val.attr] = val.value;
}
};
/**
* @param {?} val
* @return {?}
*/
StyleService.prototype.setCellStyle = /**
* @param {?} val
* @return {?}
*/
function (val) {
/** @type {?} */
var selector = "#table > tbody > tr:nth-child(" + val.row + ") > td:nth-child(" + val.cell + ")";
/** @type {?} */
var cell = (/** @type {?} */ (document.querySelector(selector)));
if (cell) {
// tslint:disable-next-line:no-string-literal
cell.style[val.attr] = val.value;
}
};
/**
* @param {?} pinned
* @param {?} column
* @return {?}
*/
StyleService.prototype.pinnedWidth = /**
* @param {?} pinned
* @param {?} column
* @return {?}
*/
function (pinned, column) {
if (pinned) {
return 150 * column + 'px';
}
};
StyleService.decorators = [
{ type: core.Injectable }
];
return StyleService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function RowContextMenuPosition() { }
if (false) {
/** @type {?} */
RowContextMenuPosition.prototype.top;
/** @type {?} */
RowContextMenuPosition.prototype.left;
/** @type {?} */
RowContextMenuPosition.prototype.value;
}
var BaseComponent = /** @class */ (function () {
function BaseComponent(cdr, scrollDispatcher, styleService) {
var _this = this;
this.cdr = cdr;
this.scrollDispatcher = scrollDispatcher;
this.styleService = styleService;
this.unsubscribe = new rxjs.Subject();
this.filterCount = -1;
this.filteredCountSubject = new rxjs.Subject();
this.tableClass = null;
this.grouped = [];
this.isSelected = false;
this.page = 1;
this.count = 0;
this.sortState = new Map();
this.sortKey = null;
this.rowContextMenuPosition = {
top: null,
left: null,
value: null,
};
this.sortBy = {
key: '',
order: 'asc',
};
this.selectedDetailsTemplateRowId = new Set();
this.selectedCheckboxes = new Set();
this.loadingHeight = '30px';
this.id = 'table';
this.event = new core.EventEmitter();
this.subscription = this.filteredCountSubject
.pipe(operators.takeUntil(this.unsubscribe))
.subscribe((/**
* @param {?} count
* @return {?}
*/
function (count) {
_this.filterCount = count;
_this.cdr.detectChanges();
}));
}
/**
* @param {?} targetElement
* @return {?}
*/
BaseComponent.prototype.onContextMenuClick = /**
* @param {?} targetElement
* @return {?}
*/
function (targetElement) {
if (this.contextMenu && !this.contextMenu.nativeElement.contains(targetElement)) {
this.rowContextMenuPosition = {
top: null,
left: null,
value: null,
};
}
};
/**
* @return {?}
*/
BaseComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if (!this.columns) {
console.error('[columns] property required!');
}
if (this.configuration) {
this.config = this.configuration;
}
else {
this.config = DefaultConfigService.config;
}
this.limit = this.config.rows;
if (this.groupRowsBy) {
this.grouped = GroupRowsService.doGroupRows(this.data, this.groupRowsBy);
}
this.doDecodePersistedState();
};
/**
* @return {?}
*/
BaseComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.unsubscribe.next();
this.unsubscribe.complete();
};
/**
* @return {?}
*/
BaseComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var throttleValue = this.config.infiniteScrollThrottleTime ?
this.config.infiniteScrollThrottleTime :
200;
this.scrollDispatcher.scrolled()
.pipe(operators.takeUntil(this.unsubscribe), operators.throttleTime(throttleValue), operators.filter((/**
* @param {?} event
* @return {?}
*/
function (event) {
return !!event && _this.viewPort && _this.viewPort.getRenderedRange().end === _this.viewPort.getDataLength();
})))
.subscribe((/**
* @return {?}
*/
function () {
_this.emitEvent(Event.onInfiniteScrollEnd, null);
}));
};
/**
* @param {?} changes
* @return {?}
*/
BaseComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var configuration = changes.configuration, data = changes.data, pagination = changes.pagination, groupRowsBy = changes.groupRowsBy;
this.toggleRowIndex = changes.toggleRowIndex;
if (configuration && configuration.currentValue) {
this.config = configuration.currentValue;
}
if (data && data.currentValue) {
this.doApplyData(data);
}
if (pagination && pagination.currentValue) {
var _a = (/** @type {?} */ (pagination.currentValue)), count = _a.count, limit = _a.limit, offset = _a.offset;
this.count = count;
this.limit = limit;
this.page = offset;
}
if (groupRowsBy && groupRowsBy.currentValue) {
this.grouped = GroupRowsService.doGroupRows(this.data, this.groupRowsBy);
}
if (this.toggleRowIndex && this.toggleRowIndex.currentValue) {
/** @type {?} */
var row = this.toggleRowIndex.currentValue;
this.collapseRow(row.index);
}
};
/**
* @param {?} column
* @return {?}
*/
BaseComponent.prototype.orderBy = /**
* @param {?} column
* @return {?}
*/
function (column) {
if (typeof column.orderEnabled !== 'undefined' && !column.orderEnabled) {
return;
}
this.sortKey = column.key;
if (!this.config.orderEnabled || this.sortKey === '') {
return;
}
this.setColumnOrder(this.sortKey);
if (!this.config.orderEventOnly && !column.orderEventOnly) {
this.sortBy.key = this.sortKey;
this.sortBy.order = this.sortState.get(this.sortKey);
}
else {
this.sortBy.key = '';
this.sortBy.order = '';
}
if (!this.config.serverPagination) {
this.data = __spread(this.data);
this.sortBy = __assign({}, this.sortBy);
}
/** @type {?} */
var value = {
key: this.sortKey,
order: this.sortState.get(this.sortKey),
};
this.emitEvent(Event.onOrder, value);
};
/**
* @param {?} $event
* @param {?} row
* @param {?} key
* @param {?} colIndex
* @param {?} rowIndex
* @return {?}
*/
BaseComponent.prototype.onClick = /**
* @param {?} $event
* @param {?} row
* @param {?} key
* @param {?} colIndex
* @param {?} rowIndex
* @return {?}
*/
function ($event, row, key, colIndex, rowIndex) {
if (this.config.selectRow) {
this.selectedRow = rowIndex;
}
if (this.config.selectCol && colIndex) {
this.selectedCol = colIndex;
}
if (this.config.selectCell && colIndex) {
this.selectedRow = rowIndex;
this.selectedCol = colIndex;
}
if (this.config.clickEvent) {
/** @type {?} */
var value = {
event: $event,
row: row,
key: key,
rowId: rowIndex,
colId: colIndex,
};
this.emitEvent(Event.onClick, value);
}
};
/**
* @param {?} $event
* @param {?} row
* @param {?} key
* @param {?} colIndex
* @param {?} rowIndex
* @return {?}
*/
BaseComponent.prototype.onDoubleClick = /**
* @param {?} $event
* @param {?} row
* @param {?} key
* @param {?} colIndex
* @param {?} rowIndex
* @return {?}
*/
function ($event, row, key, colIndex, rowIndex) {
/** @type {?} */
var value = {
event: $event,
row: row,
key: key,
rowId: rowIndex,
colId: colIndex,
};
this.emitEvent(Event.onDoubleClick, value);
};
/**
* @param {?} $event
* @param {?} row
* @param {?} rowIndex
* @return {?}
*/
BaseComponent.prototype.onCheckboxSelect = /**
* @param {?} $event
* @param {?} row
* @param {?} rowIndex
* @return {?}
*/
function ($event, row, rowIndex) {
/** @type {?} */
var value = {
event: $event,
row: row,
rowId: rowIndex,
};
this.emitEvent(Event.onCheckboxSelect, value);
};
/**
* @param {?} $event
* @param {?} row
* @param {?} rowIndex
* @return {?}
*/
BaseComponent.prototype.onRadioSelect = /**
* @param {?} $event
* @param {?} row
* @param {?} rowIndex
* @return {?}
*/
function ($event, row, rowIndex) {
/** @type {?} */
var value = {
event: $event,
row: row,
rowId: rowIndex,
};
this.emitEvent(Event.onRadioSelect, value);
};
/**
* @return {?}
*/
BaseComponent.prototype.onSelectAll = /**
* @return {?}
*/
function () {
this.isSelected = !this.isSelected;
this.emitEvent(Event.onSelectAll, this.isSelected);
};
/**
* @param {?} $event
* @return {?}
*/
BaseComponent.prototype.onSearch = /**
* @param {?} $event
* @return {?}
*/
function ($event) {
if (!this.config.serverPagination) {
this.term = $event;
}
this.emitEvent(Event.onSearch, $event);
};
/**
* @param {?} value
* @return {?}
*/
BaseComponent.prototype.onGlobalSearch = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (!this.config.serverPagination) {
this.globalSearchTerm = value;
}
this.emitEvent(Event.onGlobalSearch, value);
};
/**
* @param {?} pagination
* @return {?}
*/
BaseComponent.prototype.onPagination = /**
* @param {?} pagination
* @return {?}
*/
function (pagination) {
this.page = pagination.page;
this.limit = pagination.limit;
this.emitEvent(Event.onPagination, pagination);
};
/**
* @param {?} rowIndex
* @return {?}
*/
BaseComponent.prototype.toggleCheckbox = /**
* @param {?} rowIndex
* @return {?}
*/
function (rowIndex) {
this.selectedCheckboxes.has(rowIndex) ?
this.selectedCheckboxes.delete(rowIndex) :
this.selectedCheckboxes.add(rowIndex);
};
/**
* @param {?} rowIndex
* @return {?}
*/
BaseComponent.prototype.collapseRow = /**
* @param {?} rowIndex
* @return {?}
*/
function (rowIndex) {
if (this.selectedDetailsTemplateRowId.has(rowIndex)) {
this.selectedDetailsTemplateRowId.delete(rowIndex);
this.emitEvent(Event.onRowCollapsedHide, rowIndex);
}
else {
this.selectedDetailsTemplateRowId.add(rowIndex);
this.emitEvent(Event.onRowCollapsedShow, rowIndex);
}
};
/**
* @private
* @return {?}
*/
BaseComponent.prototype.doDecodePersistedState = /**
* @private
* @return {?}
*/
function () {
if (!this.config.persistState) {
return;
}
/** @type {?} */
var pagination = localStorage.getItem(Event.onPagination);
/** @type {?} */
var sort = localStorage.getItem(Event.onOrder);
/** @type {?} */
var search = localStorage.getItem(Event.onSearch);
if (pagination) {
this.onPagination(JSON.parse(pagination));
}
if (sort) {
var _a = JSON.parse(sort), key = _a.key, order = _a.order;
this.bindApi({
type: API.sortBy,
value: { column: key, order: order },
});
}
if (search) {
this.bindApi({
type: API.setInputValue,
value: JSON.parse(search),
});
}
};
/**
* @param {?} rowIndex
* @return {?}
*/
BaseComponent.prototype.isRowCollapsed = /**
* @param {?} rowIndex
* @return {?}
*/
function (rowIndex) {
if (this.config.collapseAllRows) {
return true;
}
return this.selectedDetailsTemplateRowId.has(rowIndex);
};
Object.defineProperty(BaseComponent.prototype, "isLoading", {
get: /**
* @return {?}
*/
function () {
/** @type {?} */
var table = (/** @type {?} */ (document.getElementById(this.id)));
if (table && table.rows && table.rows.length > 3) {
this.getLoadingHeight(table.rows);
}
return this.config.isLoading;
},
enumerable: true,
configurable: true
});
/**
* @param {?} rows
* @return {?}
*/
BaseComponent.prototype.getLoadingHeight = /**
* @param {?} rows
* @return {?}
*/
function (rows) {
/** @type {?} */
var searchEnabled = this.config.searchEnabled ? 1 : 0;
/** @type {?} */
var headerEnabled = this.config.headerEnabled ? 1 : 0;
/** @type {?} */
var borderTrHeight = 1;
/** @type {?} */
var borderDivHeight = 2;
this.loadingHeight = (rows.length - searchEnabled - headerEnabled) * (rows[3].offsetHeight - borderTrHeight) - borderDivHeight + 'px';
};
Object.defineProperty(BaseComponent.prototype, "arrowDefinition", {
get: /**
* @return {?}
*/
function () {
return this.config.showDetailsArrow || typeof this.config.showDetailsArrow === 'undefined';
},
enumerable: true,
configurable: true
});
/**
* @param {?} $event
* @param {?}