UNPKG

174 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/api'), require('primeng/paginator'), require('primeng/dom'), require('primeng/utils'), require('rxjs')) :
3 typeof define === 'function' && define.amd ? define('primeng/table', ['exports', '@angular/core', '@angular/common', 'primeng/api', 'primeng/paginator', 'primeng/dom', 'primeng/utils', 'rxjs'], factory) :
4 (global = global || self, factory((global.primeng = global.primeng || {}, global.primeng.table = {}), global.ng.core, global.ng.common, global.primeng.api, global.primeng.paginator, global.primeng.dom, global.primeng.utils, global.rxjs));
5}(this, (function (exports, core, common, api, paginator, dom, utils, rxjs) { 'use strict';
6
7 var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10 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;
11 return c > 3 && r && Object.defineProperty(target, key, r), r;
12 };
13 var __param = (this && this.__param) || function (paramIndex, decorator) {
14 return function (target, key) { decorator(target, key, paramIndex); }
15 };
16 var __values = (this && this.__values) || function(o) {
17 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
18 if (m) return m.call(o);
19 if (o && typeof o.length === "number") return {
20 next: function () {
21 if (o && i >= o.length) o = void 0;
22 return { value: o && o[i++], done: !o };
23 }
24 };
25 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
26 };
27 var __read = (this && this.__read) || function (o, n) {
28 var m = typeof Symbol === "function" && o[Symbol.iterator];
29 if (!m) return o;
30 var i = m.call(o), r, ar = [], e;
31 try {
32 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33 }
34 catch (error) { e = { error: error }; }
35 finally {
36 try {
37 if (r && !r.done && (m = i["return"])) m.call(i);
38 }
39 finally { if (e) throw e.error; }
40 }
41 return ar;
42 };
43 var __spread = (this && this.__spread) || function () {
44 for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
45 return ar;
46 };
47 var TableService = /** @class */ (function () {
48 function TableService() {
49 this.sortSource = new rxjs.Subject();
50 this.selectionSource = new rxjs.Subject();
51 this.contextMenuSource = new rxjs.Subject();
52 this.valueSource = new rxjs.Subject();
53 this.totalRecordsSource = new rxjs.Subject();
54 this.columnsSource = new rxjs.Subject();
55 this.sortSource$ = this.sortSource.asObservable();
56 this.selectionSource$ = this.selectionSource.asObservable();
57 this.contextMenuSource$ = this.contextMenuSource.asObservable();
58 this.valueSource$ = this.valueSource.asObservable();
59 this.totalRecordsSource$ = this.totalRecordsSource.asObservable();
60 this.columnsSource$ = this.columnsSource.asObservable();
61 }
62 TableService.prototype.onSort = function (sortMeta) {
63 this.sortSource.next(sortMeta);
64 };
65 TableService.prototype.onSelectionChange = function () {
66 this.selectionSource.next();
67 };
68 TableService.prototype.onContextMenu = function (data) {
69 this.contextMenuSource.next(data);
70 };
71 TableService.prototype.onValueChange = function (value) {
72 this.valueSource.next(value);
73 };
74 TableService.prototype.onTotalRecordsChange = function (value) {
75 this.totalRecordsSource.next(value);
76 };
77 TableService.prototype.onColumnsChange = function (columns) {
78 this.columnsSource.next(columns);
79 };
80 TableService = __decorate([
81 core.Injectable()
82 ], TableService);
83 return TableService;
84 }());
85 var Table = /** @class */ (function () {
86 function Table(el, zone, tableService, cd) {
87 this.el = el;
88 this.zone = zone;
89 this.tableService = tableService;
90 this.cd = cd;
91 this.pageLinks = 5;
92 this.alwaysShowPaginator = true;
93 this.paginatorPosition = 'bottom';
94 this.paginatorDropdownScrollHeight = '200px';
95 this.currentPageReportTemplate = '{currentPage} of {totalPages}';
96 this.defaultSortOrder = 1;
97 this.sortMode = 'single';
98 this.resetPageOnSort = true;
99 this.selectionChange = new core.EventEmitter();
100 this.contextMenuSelectionChange = new core.EventEmitter();
101 this.contextMenuSelectionMode = "separate";
102 this.rowTrackBy = function (index, item) { return item; };
103 this.lazy = false;
104 this.lazyLoadOnInit = true;
105 this.compareSelectionBy = 'deepEquals';
106 this.csvSeparator = ',';
107 this.exportFilename = 'download';
108 this.filters = {};
109 this.filterDelay = 300;
110 this.expandedRowKeys = {};
111 this.editingRowKeys = {};
112 this.rowExpandMode = 'multiple';
113 this.virtualScrollDelay = 150;
114 this.virtualRowHeight = 28;
115 this.columnResizeMode = 'fit';
116 this.loadingIcon = 'pi pi-spinner';
117 this.showLoader = true;
118 this.stateStorage = 'session';
119 this.editMode = 'cell';
120 this.onRowSelect = new core.EventEmitter();
121 this.onRowUnselect = new core.EventEmitter();
122 this.onPage = new core.EventEmitter();
123 this.onSort = new core.EventEmitter();
124 this.onFilter = new core.EventEmitter();
125 this.onLazyLoad = new core.EventEmitter();
126 this.onRowExpand = new core.EventEmitter();
127 this.onRowCollapse = new core.EventEmitter();
128 this.onContextMenuSelect = new core.EventEmitter();
129 this.onColResize = new core.EventEmitter();
130 this.onColReorder = new core.EventEmitter();
131 this.onRowReorder = new core.EventEmitter();
132 this.onEditInit = new core.EventEmitter();
133 this.onEditComplete = new core.EventEmitter();
134 this.onEditCancel = new core.EventEmitter();
135 this.onHeaderCheckboxToggle = new core.EventEmitter();
136 this.sortFunction = new core.EventEmitter();
137 this.firstChange = new core.EventEmitter();
138 this.rowsChange = new core.EventEmitter();
139 this.onStateSave = new core.EventEmitter();
140 this.onStateRestore = new core.EventEmitter();
141 this._value = [];
142 this._totalRecords = 0;
143 this._first = 0;
144 this.selectionKeys = {};
145 this._sortOrder = 1;
146 }
147 Table.prototype.ngOnInit = function () {
148 if (this.lazy && this.lazyLoadOnInit) {
149 this.onLazyLoad.emit(this.createLazyLoadMetadata());
150 if (this.restoringFilter) {
151 this.restoringFilter = false;
152 }
153 }
154 this.initialized = true;
155 };
156 Table.prototype.ngAfterContentInit = function () {
157 var _this = this;
158 this.templates.forEach(function (item) {
159 switch (item.getType()) {
160 case 'caption':
161 _this.captionTemplate = item.template;
162 break;
163 case 'header':
164 _this.headerTemplate = item.template;
165 break;
166 case 'body':
167 _this.bodyTemplate = item.template;
168 break;
169 case 'loadingbody':
170 _this.loadingBodyTemplate = item.template;
171 break;
172 case 'footer':
173 _this.footerTemplate = item.template;
174 break;
175 case 'summary':
176 _this.summaryTemplate = item.template;
177 break;
178 case 'colgroup':
179 _this.colGroupTemplate = item.template;
180 break;
181 case 'rowexpansion':
182 _this.expandedRowTemplate = item.template;
183 break;
184 case 'frozenrows':
185 _this.frozenRowsTemplate = item.template;
186 break;
187 case 'frozenheader':
188 _this.frozenHeaderTemplate = item.template;
189 break;
190 case 'frozenbody':
191 _this.frozenBodyTemplate = item.template;
192 break;
193 case 'frozenfooter':
194 _this.frozenFooterTemplate = item.template;
195 break;
196 case 'frozencolgroup':
197 _this.frozenColGroupTemplate = item.template;
198 break;
199 case 'emptymessage':
200 _this.emptyMessageTemplate = item.template;
201 break;
202 case 'paginatorleft':
203 _this.paginatorLeftTemplate = item.template;
204 break;
205 case 'paginatorright':
206 _this.paginatorRightTemplate = item.template;
207 break;
208 }
209 });
210 };
211 Table.prototype.ngAfterViewInit = function () {
212 if (this.isStateful() && this.resizableColumns) {
213 this.restoreColumnWidths();
214 }
215 };
216 Table.prototype.ngOnChanges = function (simpleChange) {
217 if (simpleChange.value) {
218 if (this.isStateful() && !this.stateRestored) {
219 this.restoreState();
220 }
221 this._value = simpleChange.value.currentValue;
222 if (!this.lazy) {
223 this.totalRecords = (this._value ? this._value.length : 0);
224 if (this.sortMode == 'single' && this.sortField)
225 this.sortSingle();
226 else if (this.sortMode == 'multiple' && this.multiSortMeta)
227 this.sortMultiple();
228 else if (this.hasFilter()) //sort already filters
229 this._filter();
230 }
231 if (this.virtualScroll && this.virtualScrollCallback) {
232 this.virtualScrollCallback();
233 }
234 this.tableService.onValueChange(simpleChange.value.currentValue);
235 }
236 if (simpleChange.columns) {
237 this._columns = simpleChange.columns.currentValue;
238 this.tableService.onColumnsChange(simpleChange.columns.currentValue);
239 if (this._columns && this.isStateful() && this.reorderableColumns && !this.columnOrderStateRestored) {
240 this.restoreColumnOrder();
241 }
242 }
243 if (simpleChange.sortField) {
244 this._sortField = simpleChange.sortField.currentValue;
245 //avoid triggering lazy load prior to lazy initialization at onInit
246 if (!this.lazy || this.initialized) {
247 if (this.sortMode === 'single') {
248 this.sortSingle();
249 }
250 }
251 }
252 if (simpleChange.sortOrder) {
253 this._sortOrder = simpleChange.sortOrder.currentValue;
254 //avoid triggering lazy load prior to lazy initialization at onInit
255 if (!this.lazy || this.initialized) {
256 if (this.sortMode === 'single') {
257 this.sortSingle();
258 }
259 }
260 }
261 if (simpleChange.multiSortMeta) {
262 this._multiSortMeta = simpleChange.multiSortMeta.currentValue;
263 if (this.sortMode === 'multiple') {
264 this.sortMultiple();
265 }
266 }
267 if (simpleChange.selection) {
268 this._selection = simpleChange.selection.currentValue;
269 if (!this.preventSelectionSetterPropagation) {
270 this.updateSelectionKeys();
271 this.tableService.onSelectionChange();
272 }
273 this.preventSelectionSetterPropagation = false;
274 }
275 };
276 Object.defineProperty(Table.prototype, "value", {
277 get: function () {
278 return this._value;
279 },
280 set: function (val) {
281 this._value = val;
282 },
283 enumerable: true,
284 configurable: true
285 });
286 Object.defineProperty(Table.prototype, "columns", {
287 get: function () {
288 return this._columns;
289 },
290 set: function (cols) {
291 this._columns = cols;
292 },
293 enumerable: true,
294 configurable: true
295 });
296 Object.defineProperty(Table.prototype, "first", {
297 get: function () {
298 return this._first;
299 },
300 set: function (val) {
301 this._first = val;
302 },
303 enumerable: true,
304 configurable: true
305 });
306 Object.defineProperty(Table.prototype, "rows", {
307 get: function () {
308 return this._rows;
309 },
310 set: function (val) {
311 this._rows = val;
312 },
313 enumerable: true,
314 configurable: true
315 });
316 Object.defineProperty(Table.prototype, "totalRecords", {
317 get: function () {
318 return this._totalRecords;
319 },
320 set: function (val) {
321 this._totalRecords = val;
322 this.tableService.onTotalRecordsChange(this._totalRecords);
323 },
324 enumerable: true,
325 configurable: true
326 });
327 Object.defineProperty(Table.prototype, "sortField", {
328 get: function () {
329 return this._sortField;
330 },
331 set: function (val) {
332 this._sortField = val;
333 },
334 enumerable: true,
335 configurable: true
336 });
337 Object.defineProperty(Table.prototype, "sortOrder", {
338 get: function () {
339 return this._sortOrder;
340 },
341 set: function (val) {
342 this._sortOrder = val;
343 },
344 enumerable: true,
345 configurable: true
346 });
347 Object.defineProperty(Table.prototype, "multiSortMeta", {
348 get: function () {
349 return this._multiSortMeta;
350 },
351 set: function (val) {
352 this._multiSortMeta = val;
353 },
354 enumerable: true,
355 configurable: true
356 });
357 Object.defineProperty(Table.prototype, "selection", {
358 get: function () {
359 return this._selection;
360 },
361 set: function (val) {
362 this._selection = val;
363 },
364 enumerable: true,
365 configurable: true
366 });
367 Table.prototype.updateSelectionKeys = function () {
368 var e_1, _a;
369 if (this.dataKey && this._selection) {
370 this.selectionKeys = {};
371 if (Array.isArray(this._selection)) {
372 try {
373 for (var _b = __values(this._selection), _c = _b.next(); !_c.done; _c = _b.next()) {
374 var data = _c.value;
375 this.selectionKeys[String(utils.ObjectUtils.resolveFieldData(data, this.dataKey))] = 1;
376 }
377 }
378 catch (e_1_1) { e_1 = { error: e_1_1 }; }
379 finally {
380 try {
381 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
382 }
383 finally { if (e_1) throw e_1.error; }
384 }
385 }
386 else {
387 this.selectionKeys[String(utils.ObjectUtils.resolveFieldData(this._selection, this.dataKey))] = 1;
388 }
389 }
390 };
391 Table.prototype.onPageChange = function (event) {
392 this.first = event.first;
393 this.rows = event.rows;
394 if (this.lazy) {
395 this.onLazyLoad.emit(this.createLazyLoadMetadata());
396 }
397 this.onPage.emit({
398 first: this.first,
399 rows: this.rows
400 });
401 this.firstChange.emit(this.first);
402 this.rowsChange.emit(this.rows);
403 this.tableService.onValueChange(this.value);
404 if (this.isStateful()) {
405 this.saveState();
406 }
407 this.anchorRowIndex = null;
408 };
409 Table.prototype.sort = function (event) {
410 var originalEvent = event.originalEvent;
411 if (this.sortMode === 'single') {
412 this._sortOrder = (this.sortField === event.field) ? this.sortOrder * -1 : this.defaultSortOrder;
413 this._sortField = event.field;
414 this.sortSingle();
415 if (this.resetPageOnSort) {
416 this._first = 0;
417 this.firstChange.emit(this._first);
418 }
419 }
420 if (this.sortMode === 'multiple') {
421 var metaKey = originalEvent.metaKey || originalEvent.ctrlKey;
422 var sortMeta = this.getSortMeta(event.field);
423 if (sortMeta) {
424 if (!metaKey) {
425 this._multiSortMeta = [{ field: event.field, order: sortMeta.order * -1 }];
426 if (this.resetPageOnSort) {
427 this._first = 0;
428 this.firstChange.emit(this._first);
429 }
430 }
431 else {
432 sortMeta.order = sortMeta.order * -1;
433 }
434 }
435 else {
436 if (!metaKey || !this.multiSortMeta) {
437 this._multiSortMeta = [];
438 if (this.resetPageOnSort) {
439 this._first = 0;
440 this.firstChange.emit(this._first);
441 }
442 }
443 this._multiSortMeta.push({ field: event.field, order: this.defaultSortOrder });
444 }
445 this.sortMultiple();
446 }
447 if (this.isStateful()) {
448 this.saveState();
449 }
450 this.anchorRowIndex = null;
451 };
452 Table.prototype.sortSingle = function () {
453 var _this = this;
454 if (this.sortField && this.sortOrder) {
455 if (this.restoringSort) {
456 this.restoringSort = false;
457 }
458 if (this.lazy) {
459 this.onLazyLoad.emit(this.createLazyLoadMetadata());
460 }
461 else if (this.value) {
462 if (this.customSort) {
463 this.sortFunction.emit({
464 data: this.value,
465 mode: this.sortMode,
466 field: this.sortField,
467 order: this.sortOrder
468 });
469 }
470 else {
471 this.value.sort(function (data1, data2) {
472 var value1 = utils.ObjectUtils.resolveFieldData(data1, _this.sortField);
473 var value2 = utils.ObjectUtils.resolveFieldData(data2, _this.sortField);
474 var result = null;
475 if (value1 == null && value2 != null)
476 result = -1;
477 else if (value1 != null && value2 == null)
478 result = 1;
479 else if (value1 == null && value2 == null)
480 result = 0;
481 else if (typeof value1 === 'string' && typeof value2 === 'string')
482 result = value1.localeCompare(value2);
483 else
484 result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;
485 return (_this.sortOrder * result);
486 });
487 }
488 if (this.hasFilter()) {
489 this._filter();
490 }
491 }
492 var sortMeta = {
493 field: this.sortField,
494 order: this.sortOrder
495 };
496 this.onSort.emit(sortMeta);
497 this.tableService.onSort(sortMeta);
498 }
499 };
500 Table.prototype.sortMultiple = function () {
501 var _this = this;
502 if (this.multiSortMeta) {
503 if (this.lazy) {
504 this.onLazyLoad.emit(this.createLazyLoadMetadata());
505 }
506 else if (this.value) {
507 if (this.customSort) {
508 this.sortFunction.emit({
509 data: this.value,
510 mode: this.sortMode,
511 multiSortMeta: this.multiSortMeta
512 });
513 }
514 else {
515 this.value.sort(function (data1, data2) {
516 return _this.multisortField(data1, data2, _this.multiSortMeta, 0);
517 });
518 }
519 if (this.hasFilter()) {
520 this._filter();
521 }
522 }
523 this.onSort.emit({
524 multisortmeta: this.multiSortMeta
525 });
526 this.tableService.onSort(this.multiSortMeta);
527 }
528 };
529 Table.prototype.multisortField = function (data1, data2, multiSortMeta, index) {
530 var value1 = utils.ObjectUtils.resolveFieldData(data1, multiSortMeta[index].field);
531 var value2 = utils.ObjectUtils.resolveFieldData(data2, multiSortMeta[index].field);
532 var result = null;
533 if (value1 == null && value2 != null)
534 result = -1;
535 else if (value1 != null && value2 == null)
536 result = 1;
537 else if (value1 == null && value2 == null)
538 result = 0;
539 else if (typeof value1 == 'string' || value1 instanceof String) {
540 if (value1.localeCompare && (value1 != value2)) {
541 return (multiSortMeta[index].order * value1.localeCompare(value2));
542 }
543 }
544 else {
545 result = (value1 < value2) ? -1 : 1;
546 }
547 if (value1 == value2) {
548 return (multiSortMeta.length - 1) > (index) ? (this.multisortField(data1, data2, multiSortMeta, index + 1)) : 0;
549 }
550 return (multiSortMeta[index].order * result);
551 };
552 Table.prototype.getSortMeta = function (field) {
553 if (this.multiSortMeta && this.multiSortMeta.length) {
554 for (var i = 0; i < this.multiSortMeta.length; i++) {
555 if (this.multiSortMeta[i].field === field) {
556 return this.multiSortMeta[i];
557 }
558 }
559 }
560 return null;
561 };
562 Table.prototype.isSorted = function (field) {
563 if (this.sortMode === 'single') {
564 return (this.sortField && this.sortField === field);
565 }
566 else if (this.sortMode === 'multiple') {
567 var sorted = false;
568 if (this.multiSortMeta) {
569 for (var i = 0; i < this.multiSortMeta.length; i++) {
570 if (this.multiSortMeta[i].field == field) {
571 sorted = true;
572 break;
573 }
574 }
575 }
576 return sorted;
577 }
578 };
579 Table.prototype.handleRowClick = function (event) {
580 var target = event.originalEvent.target;
581 var targetNode = target.nodeName;
582 var parentNode = target.parentElement && target.parentElement.nodeName;
583 if (targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A' ||
584 parentNode == 'INPUT' || parentNode == 'BUTTON' || parentNode == 'A' ||
585 (dom.DomHandler.hasClass(event.originalEvent.target, 'ui-clickable'))) {
586 return;
587 }
588 if (this.selectionMode) {
589 this.preventSelectionSetterPropagation = true;
590 if (this.isMultipleSelectionMode() && event.originalEvent.shiftKey && this.anchorRowIndex != null) {
591 dom.DomHandler.clearSelection();
592 if (this.rangeRowIndex != null) {
593 this.clearSelectionRange(event.originalEvent);
594 }
595 this.rangeRowIndex = event.rowIndex;
596 this.selectRange(event.originalEvent, event.rowIndex);
597 }
598 else {
599 var rowData = event.rowData;
600 var selected = this.isSelected(rowData);
601 var metaSelection = this.rowTouched ? false : this.metaKeySelection;
602 var dataKeyValue = this.dataKey ? String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey)) : null;
603 this.anchorRowIndex = event.rowIndex;
604 this.rangeRowIndex = event.rowIndex;
605 if (metaSelection) {
606 var metaKey = event.originalEvent.metaKey || event.originalEvent.ctrlKey;
607 if (selected && metaKey) {
608 if (this.isSingleSelectionMode()) {
609 this._selection = null;
610 this.selectionKeys = {};
611 this.selectionChange.emit(null);
612 }
613 else {
614 var selectionIndex_1 = this.findIndexInSelection(rowData);
615 this._selection = this.selection.filter(function (val, i) { return i != selectionIndex_1; });
616 this.selectionChange.emit(this.selection);
617 if (dataKeyValue) {
618 delete this.selectionKeys[dataKeyValue];
619 }
620 }
621 this.onRowUnselect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row' });
622 }
623 else {
624 if (this.isSingleSelectionMode()) {
625 this._selection = rowData;
626 this.selectionChange.emit(rowData);
627 if (dataKeyValue) {
628 this.selectionKeys = {};
629 this.selectionKeys[dataKeyValue] = 1;
630 }
631 }
632 else if (this.isMultipleSelectionMode()) {
633 if (metaKey) {
634 this._selection = this.selection || [];
635 }
636 else {
637 this._selection = [];
638 this.selectionKeys = {};
639 }
640 this._selection = __spread(this.selection, [rowData]);
641 this.selectionChange.emit(this.selection);
642 if (dataKeyValue) {
643 this.selectionKeys[dataKeyValue] = 1;
644 }
645 }
646 this.onRowSelect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
647 }
648 }
649 else {
650 if (this.selectionMode === 'single') {
651 if (selected) {
652 this._selection = null;
653 this.selectionKeys = {};
654 this.selectionChange.emit(this.selection);
655 this.onRowUnselect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row' });
656 }
657 else {
658 this._selection = rowData;
659 this.selectionChange.emit(this.selection);
660 this.onRowSelect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
661 if (dataKeyValue) {
662 this.selectionKeys = {};
663 this.selectionKeys[dataKeyValue] = 1;
664 }
665 }
666 }
667 else if (this.selectionMode === 'multiple') {
668 if (selected) {
669 var selectionIndex_2 = this.findIndexInSelection(rowData);
670 this._selection = this.selection.filter(function (val, i) { return i != selectionIndex_2; });
671 this.selectionChange.emit(this.selection);
672 this.onRowUnselect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row' });
673 if (dataKeyValue) {
674 delete this.selectionKeys[dataKeyValue];
675 }
676 }
677 else {
678 this._selection = this.selection ? __spread(this.selection, [rowData]) : [rowData];
679 this.selectionChange.emit(this.selection);
680 this.onRowSelect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
681 if (dataKeyValue) {
682 this.selectionKeys[dataKeyValue] = 1;
683 }
684 }
685 }
686 }
687 }
688 this.tableService.onSelectionChange();
689 if (this.isStateful()) {
690 this.saveState();
691 }
692 }
693 this.rowTouched = false;
694 };
695 Table.prototype.handleRowTouchEnd = function (event) {
696 this.rowTouched = true;
697 };
698 Table.prototype.handleRowRightClick = function (event) {
699 if (this.contextMenu) {
700 var rowData = event.rowData;
701 if (this.contextMenuSelectionMode === 'separate') {
702 this.contextMenuSelection = rowData;
703 this.contextMenuSelectionChange.emit(rowData);
704 this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, data: rowData, index: event.rowIndex });
705 this.contextMenu.show(event.originalEvent);
706 this.tableService.onContextMenu(rowData);
707 }
708 else if (this.contextMenuSelectionMode === 'joint') {
709 this.preventSelectionSetterPropagation = true;
710 var selected = this.isSelected(rowData);
711 var dataKeyValue = this.dataKey ? String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey)) : null;
712 if (!selected) {
713 if (this.isSingleSelectionMode()) {
714 this.selection = rowData;
715 this.selectionChange.emit(rowData);
716 }
717 else if (this.isMultipleSelectionMode()) {
718 this.selection = [rowData];
719 this.selectionChange.emit(this.selection);
720 }
721 if (dataKeyValue) {
722 this.selectionKeys[dataKeyValue] = 1;
723 }
724 }
725 this.contextMenu.show(event.originalEvent);
726 this.onContextMenuSelect.emit({ originalEvent: event, data: rowData, index: event.rowIndex });
727 }
728 }
729 };
730 Table.prototype.selectRange = function (event, rowIndex) {
731 var rangeStart, rangeEnd;
732 if (this.anchorRowIndex > rowIndex) {
733 rangeStart = rowIndex;
734 rangeEnd = this.anchorRowIndex;
735 }
736 else if (this.anchorRowIndex < rowIndex) {
737 rangeStart = this.anchorRowIndex;
738 rangeEnd = rowIndex;
739 }
740 else {
741 rangeStart = rowIndex;
742 rangeEnd = rowIndex;
743 }
744 if (this.lazy && this.paginator) {
745 rangeStart -= this.first;
746 rangeEnd -= this.first;
747 }
748 for (var i = rangeStart; i <= rangeEnd; i++) {
749 var rangeRowData = this.filteredValue ? this.filteredValue[i] : this.value[i];
750 if (!this.isSelected(rangeRowData)) {
751 this._selection = __spread(this.selection, [rangeRowData]);
752 var dataKeyValue = this.dataKey ? String(utils.ObjectUtils.resolveFieldData(rangeRowData, this.dataKey)) : null;
753 if (dataKeyValue) {
754 this.selectionKeys[dataKeyValue] = 1;
755 }
756 this.onRowSelect.emit({ originalEvent: event, data: rangeRowData, type: 'row' });
757 }
758 }
759 this.selectionChange.emit(this.selection);
760 };
761 Table.prototype.clearSelectionRange = function (event) {
762 var rangeStart, rangeEnd;
763 if (this.rangeRowIndex > this.anchorRowIndex) {
764 rangeStart = this.anchorRowIndex;
765 rangeEnd = this.rangeRowIndex;
766 }
767 else if (this.rangeRowIndex < this.anchorRowIndex) {
768 rangeStart = this.rangeRowIndex;
769 rangeEnd = this.anchorRowIndex;
770 }
771 else {
772 rangeStart = this.rangeRowIndex;
773 rangeEnd = this.rangeRowIndex;
774 }
775 var _loop_1 = function (i) {
776 var rangeRowData = this_1.value[i];
777 var selectionIndex = this_1.findIndexInSelection(rangeRowData);
778 this_1._selection = this_1.selection.filter(function (val, i) { return i != selectionIndex; });
779 var dataKeyValue = this_1.dataKey ? String(utils.ObjectUtils.resolveFieldData(rangeRowData, this_1.dataKey)) : null;
780 if (dataKeyValue) {
781 delete this_1.selectionKeys[dataKeyValue];
782 }
783 this_1.onRowUnselect.emit({ originalEvent: event, data: rangeRowData, type: 'row' });
784 };
785 var this_1 = this;
786 for (var i = rangeStart; i <= rangeEnd; i++) {
787 _loop_1(i);
788 }
789 };
790 Table.prototype.isSelected = function (rowData) {
791 if (rowData && this.selection) {
792 if (this.dataKey) {
793 return this.selectionKeys[utils.ObjectUtils.resolveFieldData(rowData, this.dataKey)] !== undefined;
794 }
795 else {
796 if (this.selection instanceof Array)
797 return this.findIndexInSelection(rowData) > -1;
798 else
799 return this.equals(rowData, this.selection);
800 }
801 }
802 return false;
803 };
804 Table.prototype.findIndexInSelection = function (rowData) {
805 var index = -1;
806 if (this.selection && this.selection.length) {
807 for (var i = 0; i < this.selection.length; i++) {
808 if (this.equals(rowData, this.selection[i])) {
809 index = i;
810 break;
811 }
812 }
813 }
814 return index;
815 };
816 Table.prototype.toggleRowWithRadio = function (event, rowData) {
817 this.preventSelectionSetterPropagation = true;
818 if (this.selection != rowData) {
819 this._selection = rowData;
820 this.selectionChange.emit(this.selection);
821 this.onRowSelect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'radiobutton' });
822 if (this.dataKey) {
823 this.selectionKeys = {};
824 this.selectionKeys[String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey))] = 1;
825 }
826 }
827 else {
828 this._selection = null;
829 this.selectionChange.emit(this.selection);
830 this.onRowUnselect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'radiobutton' });
831 }
832 this.tableService.onSelectionChange();
833 if (this.isStateful()) {
834 this.saveState();
835 }
836 };
837 Table.prototype.toggleRowWithCheckbox = function (event, rowData) {
838 this.selection = this.selection || [];
839 var selected = this.isSelected(rowData);
840 var dataKeyValue = this.dataKey ? String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey)) : null;
841 this.preventSelectionSetterPropagation = true;
842 if (selected) {
843 var selectionIndex_3 = this.findIndexInSelection(rowData);
844 this._selection = this.selection.filter(function (val, i) { return i != selectionIndex_3; });
845 this.selectionChange.emit(this.selection);
846 this.onRowUnselect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'checkbox' });
847 if (dataKeyValue) {
848 delete this.selectionKeys[dataKeyValue];
849 }
850 }
851 else {
852 this._selection = this.selection ? __spread(this.selection, [rowData]) : [rowData];
853 this.selectionChange.emit(this.selection);
854 this.onRowSelect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'checkbox' });
855 if (dataKeyValue) {
856 this.selectionKeys[dataKeyValue] = 1;
857 }
858 }
859 this.tableService.onSelectionChange();
860 if (this.isStateful()) {
861 this.saveState();
862 }
863 };
864 Table.prototype.toggleRowsWithCheckbox = function (event, check) {
865 this._selection = check ? this.filteredValue ? this.filteredValue.slice() : this.value.slice() : [];
866 this.preventSelectionSetterPropagation = true;
867 this.updateSelectionKeys();
868 this.selectionChange.emit(this._selection);
869 this.tableService.onSelectionChange();
870 this.onHeaderCheckboxToggle.emit({ originalEvent: event, checked: check });
871 if (this.isStateful()) {
872 this.saveState();
873 }
874 };
875 Table.prototype.equals = function (data1, data2) {
876 return this.compareSelectionBy === 'equals' ? (data1 === data2) : utils.ObjectUtils.equals(data1, data2, this.dataKey);
877 };
878 Table.prototype.filter = function (value, field, matchMode) {
879 var _this = this;
880 if (this.filterTimeout) {
881 clearTimeout(this.filterTimeout);
882 }
883 if (!this.isFilterBlank(value)) {
884 this.filters[field] = { value: value, matchMode: matchMode };
885 }
886 else if (this.filters[field]) {
887 delete this.filters[field];
888 }
889 this.filterTimeout = setTimeout(function () {
890 _this._filter();
891 _this.filterTimeout = null;
892 }, this.filterDelay);
893 this.anchorRowIndex = null;
894 };
895 Table.prototype.filterGlobal = function (value, matchMode) {
896 this.filter(value, 'global', matchMode);
897 };
898 Table.prototype.isFilterBlank = function (filter) {
899 if (filter !== null && filter !== undefined) {
900 if ((typeof filter === 'string' && filter.trim().length == 0) || (filter instanceof Array && filter.length == 0))
901 return true;
902 else
903 return false;
904 }
905 return true;
906 };
907 Table.prototype._filter = function () {
908 if (!this.restoringFilter) {
909 this.first = 0;
910 this.firstChange.emit(this.first);
911 }
912 if (this.lazy) {
913 this.onLazyLoad.emit(this.createLazyLoadMetadata());
914 }
915 else {
916 if (!this.value) {
917 return;
918 }
919 if (!this.hasFilter()) {
920 this.filteredValue = null;
921 if (this.paginator) {
922 this.totalRecords = this.value ? this.value.length : 0;
923 }
924 }
925 else {
926 var globalFilterFieldsArray = void 0;
927 if (this.filters['global']) {
928 if (!this.columns && !this.globalFilterFields)
929 throw new Error('Global filtering requires dynamic columns or globalFilterFields to be defined.');
930 else
931 globalFilterFieldsArray = this.globalFilterFields || this.columns;
932 }
933 this.filteredValue = [];
934 for (var i = 0; i < this.value.length; i++) {
935 var localMatch = true;
936 var globalMatch = false;
937 var localFiltered = false;
938 for (var prop in this.filters) {
939 if (this.filters.hasOwnProperty(prop) && prop !== 'global') {
940 localFiltered = true;
941 var filterMeta = this.filters[prop];
942 var filterField = prop;
943 var filterValue = filterMeta.value;
944 var filterMatchMode = filterMeta.matchMode || 'startsWith';
945 var dataFieldValue = utils.ObjectUtils.resolveFieldData(this.value[i], filterField);
946 var filterConstraint = utils.FilterUtils[filterMatchMode];
947 if (!filterConstraint(dataFieldValue, filterValue, this.filterLocale)) {
948 localMatch = false;
949 }
950 if (!localMatch) {
951 break;
952 }
953 }
954 }
955 if (this.filters['global'] && !globalMatch && globalFilterFieldsArray) {
956 for (var j = 0; j < globalFilterFieldsArray.length; j++) {
957 var globalFilterField = globalFilterFieldsArray[j].field || globalFilterFieldsArray[j];
958 globalMatch = utils.FilterUtils[this.filters['global'].matchMode](utils.ObjectUtils.resolveFieldData(this.value[i], globalFilterField), this.filters['global'].value, this.filterLocale);
959 if (globalMatch) {
960 break;
961 }
962 }
963 }
964 var matches = void 0;
965 if (this.filters['global']) {
966 matches = localFiltered ? (localFiltered && localMatch && globalMatch) : globalMatch;
967 }
968 else {
969 matches = localFiltered && localMatch;
970 }
971 if (matches) {
972 this.filteredValue.push(this.value[i]);
973 }
974 }
975 if (this.filteredValue.length === this.value.length) {
976 this.filteredValue = null;
977 }
978 if (this.paginator) {
979 this.totalRecords = this.filteredValue ? this.filteredValue.length : this.value ? this.value.length : 0;
980 }
981 }
982 }
983 this.onFilter.emit({
984 filters: this.filters,
985 filteredValue: this.filteredValue || this.value
986 });
987 this.tableService.onValueChange(this.value);
988 if (this.isStateful() && !this.restoringFilter) {
989 this.saveState();
990 }
991 if (this.restoringFilter) {
992 this.restoringFilter = false;
993 }
994 this.cd.markForCheck();
995 };
996 Table.prototype.hasFilter = function () {
997 var empty = true;
998 for (var prop in this.filters) {
999 if (this.filters.hasOwnProperty(prop)) {
1000 empty = false;
1001 break;
1002 }
1003 }
1004 return !empty;
1005 };
1006 Table.prototype.createLazyLoadMetadata = function () {
1007 return {
1008 first: this.first,
1009 rows: this.virtualScroll ? this.rows * 2 : this.rows,
1010 sortField: this.sortField,
1011 sortOrder: this.sortOrder,
1012 filters: this.filters,
1013 globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null,
1014 multiSortMeta: this.multiSortMeta
1015 };
1016 };
1017 Table.prototype.reset = function () {
1018 this._sortField = null;
1019 this._sortOrder = this.defaultSortOrder;
1020 this._multiSortMeta = null;
1021 this.tableService.onSort(null);
1022 this.filteredValue = null;
1023 this.filters = {};
1024 this.first = 0;
1025 this.firstChange.emit(this.first);
1026 if (this.lazy) {
1027 this.onLazyLoad.emit(this.createLazyLoadMetadata());
1028 }
1029 else {
1030 this.totalRecords = (this._value ? this._value.length : 0);
1031 }
1032 };
1033 Table.prototype.exportCSV = function (options) {
1034 var _this = this;
1035 var data = this.filteredValue || this.value;
1036 var csv = '';
1037 if (options && options.selectionOnly) {
1038 data = this.selection || [];
1039 }
1040 //headers
1041 for (var i = 0; i < this.columns.length; i++) {
1042 var column = this.columns[i];
1043 if (column.exportable !== false && column.field) {
1044 csv += '"' + (column.header || column.field) + '"';
1045 if (i < (this.columns.length - 1)) {
1046 csv += this.csvSeparator;
1047 }
1048 }
1049 }
1050 //body
1051 data.forEach(function (record, i) {
1052 csv += '\n';
1053 for (var i_1 = 0; i_1 < _this.columns.length; i_1++) {
1054 var column = _this.columns[i_1];
1055 if (column.exportable !== false && column.field) {
1056 var cellData = utils.ObjectUtils.resolveFieldData(record, column.field);
1057 if (cellData != null) {
1058 if (_this.exportFunction) {
1059 cellData = _this.exportFunction({
1060 data: cellData,
1061 field: column.field
1062 });
1063 }
1064 else
1065 cellData = String(cellData).replace(/"/g, '""');
1066 }
1067 else
1068 cellData = '';
1069 csv += '"' + cellData + '"';
1070 if (i_1 < (_this.columns.length - 1)) {
1071 csv += _this.csvSeparator;
1072 }
1073 }
1074 }
1075 });
1076 var blob = new Blob([csv], {
1077 type: 'text/csv;charset=utf-8;'
1078 });
1079 if (window.navigator.msSaveOrOpenBlob) {
1080 navigator.msSaveOrOpenBlob(blob, this.exportFilename + '.csv');
1081 }
1082 else {
1083 var link = document.createElement("a");
1084 link.style.display = 'none';
1085 document.body.appendChild(link);
1086 if (link.download !== undefined) {
1087 link.setAttribute('href', URL.createObjectURL(blob));
1088 link.setAttribute('download', this.exportFilename + '.csv');
1089 link.click();
1090 }
1091 else {
1092 csv = 'data:text/csv;charset=utf-8,' + csv;
1093 window.open(encodeURI(csv));
1094 }
1095 document.body.removeChild(link);
1096 }
1097 };
1098 Table.prototype.updateEditingCell = function (cell, data, field, index) {
1099 this.editingCell = cell;
1100 this.editingCellData = data;
1101 this.editingCellField = field;
1102 this.editingCellRowIndex = index;
1103 this.bindDocumentEditListener();
1104 };
1105 Table.prototype.isEditingCellValid = function () {
1106 return (this.editingCell && dom.DomHandler.find(this.editingCell, '.ng-invalid.ng-dirty').length === 0);
1107 };
1108 Table.prototype.bindDocumentEditListener = function () {
1109 var _this = this;
1110 if (!this.documentEditListener) {
1111 this.documentEditListener = function (event) {
1112 if (_this.editingCell && !_this.editingCellClick && _this.isEditingCellValid()) {
1113 dom.DomHandler.removeClass(_this.editingCell, 'ui-editing-cell');
1114 _this.editingCell = null;
1115 _this.onEditComplete.emit({ field: _this.editingCellField, data: _this.editingCellData, originalEvent: event, index: _this.editingCellRowIndex });
1116 _this.editingCellField = null;
1117 _this.editingCellData = null;
1118 _this.editingCellRowIndex = null;
1119 _this.unbindDocumentEditListener();
1120 }
1121 _this.editingCellClick = false;
1122 };
1123 document.addEventListener('click', this.documentEditListener);
1124 }
1125 };
1126 Table.prototype.unbindDocumentEditListener = function () {
1127 if (this.documentEditListener) {
1128 document.removeEventListener('click', this.documentEditListener);
1129 this.documentEditListener = null;
1130 }
1131 };
1132 Table.prototype.initRowEdit = function (rowData) {
1133 var dataKeyValue = String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey));
1134 this.editingRowKeys[dataKeyValue] = true;
1135 };
1136 Table.prototype.saveRowEdit = function (rowData, rowElement) {
1137 if (dom.DomHandler.find(rowElement, '.ng-invalid.ng-dirty').length === 0) {
1138 var dataKeyValue = String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey));
1139 delete this.editingRowKeys[dataKeyValue];
1140 }
1141 };
1142 Table.prototype.cancelRowEdit = function (rowData) {
1143 var dataKeyValue = String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey));
1144 delete this.editingRowKeys[dataKeyValue];
1145 };
1146 Table.prototype.toggleRow = function (rowData, event) {
1147 if (!this.dataKey) {
1148 throw new Error('dataKey must be defined to use row expansion');
1149 }
1150 var dataKeyValue = String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey));
1151 if (this.expandedRowKeys[dataKeyValue] != null) {
1152 delete this.expandedRowKeys[dataKeyValue];
1153 this.onRowCollapse.emit({
1154 originalEvent: event,
1155 data: rowData
1156 });
1157 }
1158 else {
1159 if (this.rowExpandMode === 'single') {
1160 this.expandedRowKeys = {};
1161 }
1162 this.expandedRowKeys[dataKeyValue] = true;
1163 this.onRowExpand.emit({
1164 originalEvent: event,
1165 data: rowData
1166 });
1167 }
1168 if (event) {
1169 event.preventDefault();
1170 }
1171 if (this.isStateful()) {
1172 this.saveState();
1173 }
1174 };
1175 Table.prototype.isRowExpanded = function (rowData) {
1176 return this.expandedRowKeys[String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey))] === true;
1177 };
1178 Table.prototype.isRowEditing = function (rowData) {
1179 return this.editingRowKeys[String(utils.ObjectUtils.resolveFieldData(rowData, this.dataKey))] === true;
1180 };
1181 Table.prototype.isSingleSelectionMode = function () {
1182 return this.selectionMode === 'single';
1183 };
1184 Table.prototype.isMultipleSelectionMode = function () {
1185 return this.selectionMode === 'multiple';
1186 };
1187 Table.prototype.onColumnResizeBegin = function (event) {
1188 var containerLeft = dom.DomHandler.getOffset(this.containerViewChild.nativeElement).left;
1189 this.lastResizerHelperX = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft);
1190 this.onColumnResize(event);
1191 event.preventDefault();
1192 };
1193 Table.prototype.onColumnResize = function (event) {
1194 var containerLeft = dom.DomHandler.getOffset(this.containerViewChild.nativeElement).left;
1195 dom.DomHandler.addClass(this.containerViewChild.nativeElement, 'ui-unselectable-text');
1196 this.resizeHelperViewChild.nativeElement.style.height = this.containerViewChild.nativeElement.offsetHeight + 'px';
1197 this.resizeHelperViewChild.nativeElement.style.top = 0 + 'px';
1198 this.resizeHelperViewChild.nativeElement.style.left = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft) + 'px';
1199 this.resizeHelperViewChild.nativeElement.style.display = 'block';
1200 };
1201 Table.prototype.onColumnResizeEnd = function (event, column) {
1202 var delta = this.resizeHelperViewChild.nativeElement.offsetLeft - this.lastResizerHelperX;
1203 var columnWidth = column.offsetWidth;
1204 var minWidth = parseInt(column.style.minWidth || 15);
1205 if (columnWidth + delta < minWidth) {
1206 delta = minWidth - columnWidth;
1207 }
1208 var newColumnWidth = columnWidth + delta;
1209 if (newColumnWidth >= minWidth) {
1210 if (this.columnResizeMode === 'fit') {
1211 var nextColumn = column.nextElementSibling;
1212 while (!nextColumn.offsetParent) {
1213 nextColumn = nextColumn.nextElementSibling;
1214 }
1215 if (nextColumn) {
1216 var nextColumnWidth = nextColumn.offsetWidth - delta;
1217 var nextColumnMinWidth = nextColumn.style.minWidth || 15;
1218 if (newColumnWidth > 15 && nextColumnWidth > parseInt(nextColumnMinWidth)) {
1219 if (this.scrollable) {
1220 var scrollableView = this.findParentScrollableView(column);
1221 var scrollableBodyTable = dom.DomHandler.findSingle(scrollableView, 'table.ui-table-scrollable-body-table');
1222 var scrollableHeaderTable = dom.DomHandler.findSingle(scrollableView, 'table.ui-table-scrollable-header-table');
1223 var scrollableFooterTable = dom.DomHandler.findSingle(scrollableView, 'table.ui-table-scrollable-footer-table');
1224 var resizeColumnIndex = dom.DomHandler.index(column);
1225 this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
1226 this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
1227 this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
1228 }
1229 else {
1230 column.style.width = newColumnWidth + 'px';
1231 if (nextColumn) {
1232 nextColumn.style.width = nextColumnWidth + 'px';
1233 }
1234 }
1235 }
1236 }
1237 }
1238 else if (this.columnResizeMode === 'expand') {
1239 if (newColumnWidth > minWidth) {
1240 if (this.scrollable) {
1241 this.setScrollableItemsWidthOnExpandResize(column, newColumnWidth, delta);
1242 }
1243 else {
1244 this.tableViewChild.nativeElement.style.width = this.tableViewChild.nativeElement.offsetWidth + delta + 'px';
1245 column.style.width = newColumnWidth + 'px';
1246 var containerWidth = this.tableViewChild.nativeElement.style.width;
1247 this.containerViewChild.nativeElement.style.width = containerWidth + 'px';
1248 }
1249 }
1250 }
1251 this.onColResize.emit({
1252 element: column,
1253 delta: delta
1254 });
1255 if (this.isStateful()) {
1256 this.saveState();
1257 }
1258 }
1259 this.resizeHelperViewChild.nativeElement.style.display = 'none';
1260 dom.DomHandler.removeClass(this.containerViewChild.nativeElement, 'ui-unselectable-text');
1261 };
1262 Table.prototype.setScrollableItemsWidthOnExpandResize = function (column, newColumnWidth, delta) {
1263 var scrollableView = column ? this.findParentScrollableView(column) : this.containerViewChild.nativeElement;
1264 var scrollableBody = dom.DomHandler.findSingle(scrollableView, '.ui-table-scrollable-body');
1265 var scrollableHeader = dom.DomHandler.findSingle(scrollableView, '.ui-table-scrollable-header');
1266 var scrollableFooter = dom.DomHandler.findSingle(scrollableView, '.ui-table-scrollable-footer');
1267 var scrollableBodyTable = dom.DomHandler.findSingle(scrollableBody, 'table.ui-table-scrollable-body-table');
1268 var scrollableHeaderTable = dom.DomHandler.findSingle(scrollableHeader, 'table.ui-table-scrollable-header-table');
1269 var scrollableFooterTable = dom.DomHandler.findSingle(scrollableFooter, 'table.ui-table-scrollable-footer-table');
1270 var scrollableBodyTableWidth = column ? scrollableBodyTable.offsetWidth + delta : newColumnWidth;
1271 var scrollableHeaderTableWidth = column ? scrollableHeaderTable.offsetWidth + delta : newColumnWidth;
1272 var isContainerInViewport = this.containerViewChild.nativeElement.offsetWidth >= scrollableBodyTableWidth;
1273 var setWidth = function (container, table, width, isContainerInViewport) {
1274 if (container && table) {
1275 container.style.width = isContainerInViewport ? width + dom.DomHandler.calculateScrollbarWidth(scrollableBody) + 'px' : 'auto';
1276 table.style.width = width + 'px';
1277 }
1278 };
1279 setWidth(scrollableBody, scrollableBodyTable, scrollableBodyTableWidth, isContainerInViewport);
1280 setWidth(scrollableHeader, scrollableHeaderTable, scrollableHeaderTableWidth, isContainerInViewport);
1281 setWidth(scrollableFooter, scrollableFooterTable, scrollableHeaderTableWidth, isContainerInViewport);
1282 if (column) {
1283 var resizeColumnIndex = dom.DomHandler.index(column);
1284 this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, null);
1285 this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, null);
1286 this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, null);
1287 }
1288 };
1289 Table.prototype.findParentScrollableView = function (column) {
1290 if (column) {
1291 var parent_1 = column.parentElement;
1292 while (parent_1 && !dom.DomHandler.hasClass(parent_1, 'ui-table-scrollable-view')) {
1293 parent_1 = parent_1.parentElement;
1294 }
1295 return parent_1;
1296 }
1297 else {
1298 return null;
1299 }
1300 };
1301 Table.prototype.resizeColGroup = function (table, resizeColumnIndex, newColumnWidth, nextColumnWidth) {
1302 if (table) {
1303 var colGroup = table.children[0].nodeName === 'COLGROUP' ? table.children[0] : null;
1304 if (colGroup) {
1305 var col = colGroup.children[resizeColumnIndex];
1306 var nextCol = col.nextElementSibling;
1307 col.style.width = newColumnWidth + 'px';
1308 if (nextCol && nextColumnWidth) {
1309 nextCol.style.width = nextColumnWidth + 'px';
1310 }
1311 }
1312 else {
1313 throw "Scrollable tables require a colgroup to support resizable columns";
1314 }
1315 }
1316 };
1317 Table.prototype.onColumnDragStart = function (event, columnElement) {
1318 this.reorderIconWidth = dom.DomHandler.getHiddenElementOuterWidth(this.reorderIndicatorUpViewChild.nativeElement);
1319 this.reorderIconHeight = dom.DomHandler.getHiddenElementOuterHeight(this.reorderIndicatorDownViewChild.nativeElement);
1320 this.draggedColumn = columnElement;
1321 event.dataTransfer.setData('text', 'b'); // For firefox
1322 };
1323 Table.prototype.onColumnDragEnter = function (event, dropHeader) {
1324 if (this.reorderableColumns && this.draggedColumn && dropHeader) {
1325 event.preventDefault();
1326 var containerOffset = dom.DomHandler.getOffset(this.containerViewChild.nativeElement);
1327 var dropHeaderOffset = dom.DomHandler.getOffset(dropHeader);
1328 if (this.draggedColumn != dropHeader) {
1329 var dragIndex = dom.DomHandler.indexWithinGroup(this.draggedColumn, 'preorderablecolumn');
1330 var dropIndex = dom.DomHandler.indexWithinGroup(dropHeader, 'preorderablecolumn');
1331 var targetLeft = dropHeaderOffset.left - containerOffset.left;
1332 var targetTop = containerOffset.top - dropHeaderOffset.top;
1333 var columnCenter = dropHeaderOffset.left + dropHeader.offsetWidth / 2;
1334 this.reorderIndicatorUpViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top - (this.reorderIconHeight - 1) + 'px';
1335 this.reorderIndicatorDownViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top + dropHeader.offsetHeight + 'px';
1336 if (event.pageX > columnCenter) {
1337 this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
1338 this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
1339 this.dropPosition = 1;
1340 }
1341 else {
1342 this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
1343 this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
1344 this.dropPosition = -1;
1345 }
1346 if ((dropIndex - dragIndex === 1 && this.dropPosition === -1) || (dropIndex - dragIndex === -1 && this.dropPosition === 1)) {
1347 this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
1348 this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
1349 }
1350 else {
1351 this.reorderIndicatorUpViewChild.nativeElement.style.display = 'block';
1352 this.reorderIndicatorDownViewChild.nativeElement.style.display = 'block';
1353 }
1354 }
1355 else {
1356 event.dataTransfer.dropEffect = 'none';
1357 }
1358 }
1359 };
1360 Table.prototype.onColumnDragLeave = function (event) {
1361 if (this.reorderableColumns && this.draggedColumn) {
1362 event.preventDefault();
1363 this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
1364 this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
1365 }
1366 };
1367 Table.prototype.onColumnDrop = function (event, dropColumn) {
1368 var _this = this;
1369 event.preventDefault();
1370 if (this.draggedColumn) {
1371 var dragIndex = dom.DomHandler.indexWithinGroup(this.draggedColumn, 'preorderablecolumn');
1372 var dropIndex = dom.DomHandler.indexWithinGroup(dropColumn, 'preorderablecolumn');
1373 var allowDrop = (dragIndex != dropIndex);
1374 if (allowDrop && ((dropIndex - dragIndex == 1 && this.dropPosition === -1) || (dragIndex - dropIndex == 1 && this.dropPosition === 1))) {
1375 allowDrop = false;
1376 }
1377 if (allowDrop && ((dropIndex < dragIndex && this.dropPosition === 1))) {
1378 dropIndex = dropIndex + 1;
1379 }
1380 if (allowDrop && ((dropIndex > dragIndex && this.dropPosition === -1))) {
1381 dropIndex = dropIndex - 1;
1382 }
1383 if (allowDrop) {
1384 utils.ObjectUtils.reorderArray(this.columns, dragIndex, dropIndex);
1385 this.onColReorder.emit({
1386 dragIndex: dragIndex,
1387 dropIndex: dropIndex,
1388 columns: this.columns
1389 });
1390 if (this.isStateful()) {
1391 this.zone.runOutsideAngular(function () {
1392 setTimeout(function () {
1393 _this.saveState();
1394 });
1395 });
1396 }
1397 }
1398 this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
1399 this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
1400 this.draggedColumn.draggable = false;
1401 this.draggedColumn = null;
1402 this.dropPosition = null;
1403 }
1404 };
1405 Table.prototype.onRowDragStart = function (event, index) {
1406 this.rowDragging = true;
1407 this.draggedRowIndex = index;
1408 event.dataTransfer.setData('text', 'b'); // For firefox
1409 };
1410 Table.prototype.onRowDragOver = function (event, index, rowElement) {
1411 if (this.rowDragging && this.draggedRowIndex !== index) {
1412 var rowY = dom.DomHandler.getOffset(rowElement).top + dom.DomHandler.getWindowScrollTop();
1413 var pageY = event.pageY;
1414 var rowMidY = rowY + dom.DomHandler.getOuterHeight(rowElement) / 2;
1415 var prevRowElement = rowElement.previousElementSibling;
1416 if (pageY < rowMidY) {
1417 dom.DomHandler.removeClass(rowElement, 'ui-table-dragpoint-bottom');
1418 this.droppedRowIndex = index;
1419 if (prevRowElement)
1420 dom.DomHandler.addClass(prevRowElement, 'ui-table-dragpoint-bottom');
1421 else
1422 dom.DomHandler.addClass(rowElement, 'ui-table-dragpoint-top');
1423 }
1424 else {
1425 if (prevRowElement)
1426 dom.DomHandler.removeClass(prevRowElement, 'ui-table-dragpoint-bottom');
1427 else
1428 dom.DomHandler.addClass(rowElement, 'ui-table-dragpoint-top');
1429 this.droppedRowIndex = index + 1;
1430 dom.DomHandler.addClass(rowElement, 'ui-table-dragpoint-bottom');
1431 }
1432 }
1433 };
1434 Table.prototype.onRowDragLeave = function (event, rowElement) {
1435 var prevRowElement = rowElement.previousElementSibling;
1436 if (prevRowElement) {
1437 dom.DomHandler.removeClass(prevRowElement, 'ui-table-dragpoint-bottom');
1438 }
1439 dom.DomHandler.removeClass(rowElement, 'ui-table-dragpoint-bottom');
1440 dom.DomHandler.removeClass(rowElement, 'ui-table-dragpoint-top');
1441 };
1442 Table.prototype.onRowDragEnd = function (event) {
1443 this.rowDragging = false;
1444 this.draggedRowIndex = null;
1445 this.droppedRowIndex = null;
1446 };
1447 Table.prototype.onRowDrop = function (event, rowElement) {
1448 if (this.droppedRowIndex != null) {
1449 var dropIndex = (this.draggedRowIndex > this.droppedRowIndex) ? this.droppedRowIndex : (this.droppedRowIndex === 0) ? 0 : this.droppedRowIndex - 1;
1450 utils.ObjectUtils.reorderArray(this.value, this.draggedRowIndex, dropIndex);
1451 this.onRowReorder.emit({
1452 dragIndex: this.draggedRowIndex,
1453 dropIndex: dropIndex
1454 });
1455 }
1456 //cleanup
1457 this.onRowDragLeave(event, rowElement);
1458 this.onRowDragEnd(event);
1459 };
1460 Table.prototype.handleVirtualScroll = function (event) {
1461 var _this = this;
1462 this.first = (event.page - 1) * this.rows;
1463 this.firstChange.emit(this.first);
1464 this.virtualScrollCallback = event.callback;
1465 this.zone.run(function () {
1466 if (_this.virtualScrollTimer) {
1467 clearTimeout(_this.virtualScrollTimer);
1468 }
1469 _this.virtualScrollTimer = setTimeout(function () {
1470 _this.onLazyLoad.emit(_this.createLazyLoadMetadata());
1471 }, _this.virtualScrollDelay);
1472 });
1473 };
1474 Table.prototype.isEmpty = function () {
1475 var data = this.filteredValue || this.value;
1476 return data == null || data.length == 0;
1477 };
1478 Table.prototype.getBlockableElement = function () {
1479 return this.el.nativeElement.children[0];
1480 };
1481 Table.prototype.getStorage = function () {
1482 switch (this.stateStorage) {
1483 case 'local':
1484 return window.localStorage;
1485 case 'session':
1486 return window.sessionStorage;
1487 default:
1488 throw new Error(this.stateStorage + ' is not a valid value for the state storage, supported values are "local" and "session".');
1489 }
1490 };
1491 Table.prototype.isStateful = function () {
1492 return this.stateKey != null;
1493 };
1494 Table.prototype.saveState = function () {
1495 var storage = this.getStorage();
1496 var state = {};
1497 if (this.paginator) {
1498 state.first = this.first;
1499 state.rows = this.rows;
1500 }
1501 if (this.sortField) {
1502 state.sortField = this.sortField;
1503 state.sortOrder = this.sortOrder;
1504 }
1505 if (this.multiSortMeta) {
1506 state.multiSortMeta = this.multiSortMeta;
1507 }
1508 if (this.hasFilter()) {
1509 state.filters = this.filters;
1510 }
1511 if (this.resizableColumns) {
1512 this.saveColumnWidths(state);
1513 }
1514 if (this.reorderableColumns) {
1515 this.saveColumnOrder(state);
1516 }
1517 if (this.selection) {
1518 state.selection = this.selection;
1519 }
1520 if (Object.keys(this.expandedRowKeys).length) {
1521 state.expandedRowKeys = this.expandedRowKeys;
1522 }
1523 if (Object.keys(state).length) {
1524 storage.setItem(this.stateKey, JSON.stringify(state));
1525 }
1526 this.onStateSave.emit(state);
1527 };
1528 Table.prototype.clearState = function () {
1529 var storage = this.getStorage();
1530 if (this.stateKey) {
1531 storage.removeItem(this.stateKey);
1532 }
1533 };
1534 Table.prototype.restoreState = function () {
1535 var _this = this;
1536 var storage = this.getStorage();
1537 var stateString = storage.getItem(this.stateKey);
1538 if (stateString) {
1539 var state_1 = JSON.parse(stateString);
1540 if (this.paginator) {
1541 this.first = state_1.first;
1542 this.rows = state_1.rows;
1543 this.firstChange.emit(this.first);
1544 this.rowsChange.emit(this.rows);
1545 }
1546 if (state_1.sortField) {
1547 this.restoringSort = true;
1548 this._sortField = state_1.sortField;
1549 this._sortOrder = state_1.sortOrder;
1550 }
1551 if (state_1.multiSortMeta) {
1552 this.restoringSort = true;
1553 this._multiSortMeta = state_1.multiSortMeta;
1554 }
1555 if (state_1.filters) {
1556 this.restoringFilter = true;
1557 this.filters = state_1.filters;
1558 }
1559 if (this.resizableColumns) {
1560 this.columnWidthsState = state_1.columnWidths;
1561 this.tableWidthState = state_1.tableWidth;
1562 }
1563 if (state_1.expandedRowKeys) {
1564 this.expandedRowKeys = state_1.expandedRowKeys;
1565 }
1566 if (state_1.selection) {
1567 Promise.resolve(null).then(function () { return _this.selectionChange.emit(state_1.selection); });
1568 }
1569 this.stateRestored = true;
1570 this.onStateRestore.emit(state_1);
1571 }
1572 };
1573 Table.prototype.saveColumnWidths = function (state) {
1574 var widths = [];
1575 var headers = dom.DomHandler.find(this.containerViewChild.nativeElement, '.ui-table-thead > tr:first-child > th');
1576 headers.map(function (header) { return widths.push(dom.DomHandler.getOuterWidth(header)); });
1577 state.columnWidths = widths.join(',');
1578 if (this.columnResizeMode === 'expand') {
1579 state.tableWidth = this.scrollable ? dom.DomHandler.findSingle(this.containerViewChild.nativeElement, '.ui-table-scrollable-header-table').style.width :
1580 dom.DomHandler.getOuterWidth(this.tableViewChild.nativeElement) + 'px';
1581 }
1582 };
1583 Table.prototype.restoreColumnWidths = function () {
1584 if (this.columnWidthsState) {
1585 var widths_1 = this.columnWidthsState.split(',');
1586 if (this.columnResizeMode === 'expand' && this.tableWidthState) {
1587 if (this.scrollable) {
1588 this.setScrollableItemsWidthOnExpandResize(null, this.tableWidthState, 0);
1589 }
1590 else {
1591 this.tableViewChild.nativeElement.style.width = this.tableWidthState;
1592 this.containerViewChild.nativeElement.style.width = this.tableWidthState;
1593 }
1594 }
1595 if (this.scrollable) {
1596 var headerCols = dom.DomHandler.find(this.containerViewChild.nativeElement, '.ui-table-scrollable-header-table > colgroup > col');
1597 var bodyCols = dom.DomHandler.find(this.containerViewChild.nativeElement, '.ui-table-scrollable-body-table > colgroup > col');
1598 headerCols.map(function (col, index) { return col.style.width = widths_1[index] + 'px'; });
1599 bodyCols.map(function (col, index) { return col.style.width = widths_1[index] + 'px'; });
1600 }
1601 else {
1602 var headers = dom.DomHandler.find(this.tableViewChild.nativeElement, '.ui-table-thead > tr:first-child > th');
1603 headers.map(function (header, index) { return header.style.width = widths_1[index] + 'px'; });
1604 }
1605 }
1606 };
1607 Table.prototype.saveColumnOrder = function (state) {
1608 if (this.columns) {
1609 var columnOrder_1 = [];
1610 this.columns.map(function (column) {
1611 columnOrder_1.push(column.field || column.key);
1612 });
1613 state.columnOrder = columnOrder_1;
1614 }
1615 };
1616 Table.prototype.restoreColumnOrder = function () {
1617 var _this = this;
1618 var storage = this.getStorage();
1619 var stateString = storage.getItem(this.stateKey);
1620 if (stateString) {
1621 var state = JSON.parse(stateString);
1622 var columnOrder = state.columnOrder;
1623 if (columnOrder) {
1624 var reorderedColumns_1 = [];
1625 columnOrder.map(function (key) { return reorderedColumns_1.push(_this.findColumnByKey(key)); });
1626 this.columnOrderStateRestored = true;
1627 this.columns = reorderedColumns_1;
1628 }
1629 }
1630 };
1631 Table.prototype.findColumnByKey = function (key) {
1632 var e_2, _a;
1633 if (this.columns) {
1634 try {
1635 for (var _b = __values(this.columns), _c = _b.next(); !_c.done; _c = _b.next()) {
1636 var col = _c.value;
1637 if (col.key === key || col.field === key)
1638 return col;
1639 else
1640 continue;
1641 }
1642 }
1643 catch (e_2_1) { e_2 = { error: e_2_1 }; }
1644 finally {
1645 try {
1646 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1647 }
1648 finally { if (e_2) throw e_2.error; }
1649 }
1650 }
1651 else {
1652 return null;
1653 }
1654 };
1655 Table.prototype.ngOnDestroy = function () {
1656 this.unbindDocumentEditListener();
1657 this.editingCell = null;
1658 this.initialized = null;
1659 };
1660 Table.ctorParameters = function () { return [
1661 { type: core.ElementRef },
1662 { type: core.NgZone },
1663 { type: TableService },
1664 { type: core.ChangeDetectorRef }
1665 ]; };
1666 __decorate([
1667 core.Input()
1668 ], Table.prototype, "frozenColumns", void 0);
1669 __decorate([
1670 core.Input()
1671 ], Table.prototype, "frozenValue", void 0);
1672 __decorate([
1673 core.Input()
1674 ], Table.prototype, "style", void 0);
1675 __decorate([
1676 core.Input()
1677 ], Table.prototype, "styleClass", void 0);
1678 __decorate([
1679 core.Input()
1680 ], Table.prototype, "tableStyle", void 0);
1681 __decorate([
1682 core.Input()
1683 ], Table.prototype, "tableStyleClass", void 0);
1684 __decorate([
1685 core.Input()
1686 ], Table.prototype, "paginator", void 0);
1687 __decorate([
1688 core.Input()
1689 ], Table.prototype, "pageLinks", void 0);
1690 __decorate([
1691 core.Input()
1692 ], Table.prototype, "rowsPerPageOptions", void 0);
1693 __decorate([
1694 core.Input()
1695 ], Table.prototype, "alwaysShowPaginator", void 0);
1696 __decorate([
1697 core.Input()
1698 ], Table.prototype, "paginatorPosition", void 0);
1699 __decorate([
1700 core.Input()
1701 ], Table.prototype, "paginatorDropdownAppendTo", void 0);
1702 __decorate([
1703 core.Input()
1704 ], Table.prototype, "paginatorDropdownScrollHeight", void 0);
1705 __decorate([
1706 core.Input()
1707 ], Table.prototype, "currentPageReportTemplate", void 0);
1708 __decorate([
1709 core.Input()
1710 ], Table.prototype, "showCurrentPageReport", void 0);
1711 __decorate([
1712 core.Input()
1713 ], Table.prototype, "defaultSortOrder", void 0);
1714 __decorate([
1715 core.Input()
1716 ], Table.prototype, "sortMode", void 0);
1717 __decorate([
1718 core.Input()
1719 ], Table.prototype, "resetPageOnSort", void 0);
1720 __decorate([
1721 core.Input()
1722 ], Table.prototype, "selectionMode", void 0);
1723 __decorate([
1724 core.Output()
1725 ], Table.prototype, "selectionChange", void 0);
1726 __decorate([
1727 core.Input()
1728 ], Table.prototype, "contextMenuSelection", void 0);
1729 __decorate([
1730 core.Output()
1731 ], Table.prototype, "contextMenuSelectionChange", void 0);
1732 __decorate([
1733 core.Input()
1734 ], Table.prototype, "contextMenuSelectionMode", void 0);
1735 __decorate([
1736 core.Input()
1737 ], Table.prototype, "dataKey", void 0);
1738 __decorate([
1739 core.Input()
1740 ], Table.prototype, "metaKeySelection", void 0);
1741 __decorate([
1742 core.Input()
1743 ], Table.prototype, "rowTrackBy", void 0);
1744 __decorate([
1745 core.Input()
1746 ], Table.prototype, "lazy", void 0);
1747 __decorate([
1748 core.Input()
1749 ], Table.prototype, "lazyLoadOnInit", void 0);
1750 __decorate([
1751 core.Input()
1752 ], Table.prototype, "compareSelectionBy", void 0);
1753 __decorate([
1754 core.Input()
1755 ], Table.prototype, "csvSeparator", void 0);
1756 __decorate([
1757 core.Input()
1758 ], Table.prototype, "exportFilename", void 0);
1759 __decorate([
1760 core.Input()
1761 ], Table.prototype, "filters", void 0);
1762 __decorate([
1763 core.Input()
1764 ], Table.prototype, "globalFilterFields", void 0);
1765 __decorate([
1766 core.Input()
1767 ], Table.prototype, "filterDelay", void 0);
1768 __decorate([
1769 core.Input()
1770 ], Table.prototype, "filterLocale", void 0);
1771 __decorate([
1772 core.Input()
1773 ], Table.prototype, "expandedRowKeys", void 0);
1774 __decorate([
1775 core.Input()
1776 ], Table.prototype, "editingRowKeys", void 0);
1777 __decorate([
1778 core.Input()
1779 ], Table.prototype, "rowExpandMode", void 0);
1780 __decorate([
1781 core.Input()
1782 ], Table.prototype, "scrollable", void 0);
1783 __decorate([
1784 core.Input()
1785 ], Table.prototype, "scrollHeight", void 0);
1786 __decorate([
1787 core.Input()
1788 ], Table.prototype, "virtualScroll", void 0);
1789 __decorate([
1790 core.Input()
1791 ], Table.prototype, "virtualScrollDelay", void 0);
1792 __decorate([
1793 core.Input()
1794 ], Table.prototype, "virtualRowHeight", void 0);
1795 __decorate([
1796 core.Input()
1797 ], Table.prototype, "frozenWidth", void 0);
1798 __decorate([
1799 core.Input()
1800 ], Table.prototype, "responsive", void 0);
1801 __decorate([
1802 core.Input()
1803 ], Table.prototype, "contextMenu", void 0);
1804 __decorate([
1805 core.Input()
1806 ], Table.prototype, "resizableColumns", void 0);
1807 __decorate([
1808 core.Input()
1809 ], Table.prototype, "columnResizeMode", void 0);
1810 __decorate([
1811 core.Input()
1812 ], Table.prototype, "reorderableColumns", void 0);
1813 __decorate([
1814 core.Input()
1815 ], Table.prototype, "loading", void 0);
1816 __decorate([
1817 core.Input()
1818 ], Table.prototype, "loadingIcon", void 0);
1819 __decorate([
1820 core.Input()
1821 ], Table.prototype, "showLoader", void 0);
1822 __decorate([
1823 core.Input()
1824 ], Table.prototype, "rowHover", void 0);
1825 __decorate([
1826 core.Input()
1827 ], Table.prototype, "customSort", void 0);
1828 __decorate([
1829 core.Input()
1830 ], Table.prototype, "autoLayout", void 0);
1831 __decorate([
1832 core.Input()
1833 ], Table.prototype, "exportFunction", void 0);
1834 __decorate([
1835 core.Input()
1836 ], Table.prototype, "stateKey", void 0);
1837 __decorate([
1838 core.Input()
1839 ], Table.prototype, "stateStorage", void 0);
1840 __decorate([
1841 core.Input()
1842 ], Table.prototype, "editMode", void 0);
1843 __decorate([
1844 core.Output()
1845 ], Table.prototype, "onRowSelect", void 0);
1846 __decorate([
1847 core.Output()
1848 ], Table.prototype, "onRowUnselect", void 0);
1849 __decorate([
1850 core.Output()
1851 ], Table.prototype, "onPage", void 0);
1852 __decorate([
1853 core.Output()
1854 ], Table.prototype, "onSort", void 0);
1855 __decorate([
1856 core.Output()
1857 ], Table.prototype, "onFilter", void 0);
1858 __decorate([
1859 core.Output()
1860 ], Table.prototype, "onLazyLoad", void 0);
1861 __decorate([
1862 core.Output()
1863 ], Table.prototype, "onRowExpand", void 0);
1864 __decorate([
1865 core.Output()
1866 ], Table.prototype, "onRowCollapse", void 0);
1867 __decorate([
1868 core.Output()
1869 ], Table.prototype, "onContextMenuSelect", void 0);
1870 __decorate([
1871 core.Output()
1872 ], Table.prototype, "onColResize", void 0);
1873 __decorate([
1874 core.Output()
1875 ], Table.prototype, "onColReorder", void 0);
1876 __decorate([
1877 core.Output()
1878 ], Table.prototype, "onRowReorder", void 0);
1879 __decorate([
1880 core.Output()
1881 ], Table.prototype, "onEditInit", void 0);
1882 __decorate([
1883 core.Output()
1884 ], Table.prototype, "onEditComplete", void 0);
1885 __decorate([
1886 core.Output()
1887 ], Table.prototype, "onEditCancel", void 0);
1888 __decorate([
1889 core.Output()
1890 ], Table.prototype, "onHeaderCheckboxToggle", void 0);
1891 __decorate([
1892 core.Output()
1893 ], Table.prototype, "sortFunction", void 0);
1894 __decorate([
1895 core.Output()
1896 ], Table.prototype, "firstChange", void 0);
1897 __decorate([
1898 core.Output()
1899 ], Table.prototype, "rowsChange", void 0);
1900 __decorate([
1901 core.Output()
1902 ], Table.prototype, "onStateSave", void 0);
1903 __decorate([
1904 core.Output()
1905 ], Table.prototype, "onStateRestore", void 0);
1906 __decorate([
1907 core.ViewChild('container')
1908 ], Table.prototype, "containerViewChild", void 0);
1909 __decorate([
1910 core.ViewChild('resizeHelper')
1911 ], Table.prototype, "resizeHelperViewChild", void 0);
1912 __decorate([
1913 core.ViewChild('reorderIndicatorUp')
1914 ], Table.prototype, "reorderIndicatorUpViewChild", void 0);
1915 __decorate([
1916 core.ViewChild('reorderIndicatorDown')
1917 ], Table.prototype, "reorderIndicatorDownViewChild", void 0);
1918 __decorate([
1919 core.ViewChild('table')
1920 ], Table.prototype, "tableViewChild", void 0);
1921 __decorate([
1922 core.ContentChildren(api.PrimeTemplate)
1923 ], Table.prototype, "templates", void 0);
1924 __decorate([
1925 core.Input()
1926 ], Table.prototype, "value", null);
1927 __decorate([
1928 core.Input()
1929 ], Table.prototype, "columns", null);
1930 __decorate([
1931 core.Input()
1932 ], Table.prototype, "first", null);
1933 __decorate([
1934 core.Input()
1935 ], Table.prototype, "rows", null);
1936 __decorate([
1937 core.Input()
1938 ], Table.prototype, "totalRecords", null);
1939 __decorate([
1940 core.Input()
1941 ], Table.prototype, "sortField", null);
1942 __decorate([
1943 core.Input()
1944 ], Table.prototype, "sortOrder", null);
1945 __decorate([
1946 core.Input()
1947 ], Table.prototype, "multiSortMeta", null);
1948 __decorate([
1949 core.Input()
1950 ], Table.prototype, "selection", null);
1951 Table = __decorate([
1952 core.Component({
1953 selector: 'p-table',
1954 template: "\n <div #container [ngStyle]=\"style\" [class]=\"styleClass\"\n [ngClass]=\"{'ui-table ui-widget': true, 'ui-table-responsive': responsive, 'ui-table-resizable': resizableColumns,\n 'ui-table-resizable-fit': (resizableColumns && columnResizeMode === 'fit'),\n 'ui-table-hoverable-rows': (rowHover||selectionMode), 'ui-table-auto-layout': autoLayout}\">\n <div class=\"ui-table-loading ui-widget-overlay\" *ngIf=\"loading && showLoader\"></div>\n <div class=\"ui-table-loading-content\" *ngIf=\"loading && showLoader\">\n <i [class]=\"'ui-table-loading-icon pi-spin ' + loadingIcon\"></i>\n </div>\n <div *ngIf=\"captionTemplate\" class=\"ui-table-caption ui-widget-header\">\n <ng-container *ngTemplateOutlet=\"captionTemplate\"></ng-container>\n </div>\n <p-paginator [rows]=\"rows\" [first]=\"first\" [totalRecords]=\"totalRecords\" [pageLinkSize]=\"pageLinks\" styleClass=\"ui-paginator-top\" [alwaysShow]=\"alwaysShowPaginator\"\n (onPageChange)=\"onPageChange($event)\" [rowsPerPageOptions]=\"rowsPerPageOptions\" *ngIf=\"paginator && (paginatorPosition === 'top' || paginatorPosition =='both')\"\n [templateLeft]=\"paginatorLeftTemplate\" [templateRight]=\"paginatorRightTemplate\" [dropdownAppendTo]=\"paginatorDropdownAppendTo\" [dropdownScrollHeight]=\"paginatorDropdownScrollHeight\"\n [currentPageReportTemplate]=\"currentPageReportTemplate\" [showCurrentPageReport]=\"showCurrentPageReport\"></p-paginator>\n\n <div class=\"ui-table-wrapper\" *ngIf=\"!scrollable\">\n <table role=\"grid\" #table [ngClass]=\"tableStyleClass\" [ngStyle]=\"tableStyle\">\n <ng-container *ngTemplateOutlet=\"colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <thead class=\"ui-table-thead\">\n <ng-container *ngTemplateOutlet=\"headerTemplate; context: {$implicit: columns}\"></ng-container>\n </thead>\n <tbody class=\"ui-table-tbody\" [pTableBody]=\"columns\" [pTableBodyTemplate]=\"bodyTemplate\"></tbody>\n <tfoot *ngIf=\"footerTemplate\" class=\"ui-table-tfoot\">\n <ng-container *ngTemplateOutlet=\"footerTemplate; context {$implicit: columns}\"></ng-container>\n </tfoot>\n </table>\n </div>\n\n <div class=\"ui-table-scrollable-wrapper\" *ngIf=\"scrollable\">\n <div class=\"ui-table-scrollable-view ui-table-frozen-view\" *ngIf=\"frozenColumns||frozenBodyTemplate\" [pScrollableView]=\"frozenColumns\" [frozen]=\"true\" [ngStyle]=\"{width: frozenWidth}\" [scrollHeight]=\"scrollHeight\"></div>\n <div class=\"ui-table-scrollable-view\" [pScrollableView]=\"columns\" [frozen]=\"false\" [scrollHeight]=\"scrollHeight\" [ngStyle]=\"{left: frozenWidth, width: 'calc(100% - '+frozenWidth+')'}\"></div>\n </div>\n\n <p-paginator [rows]=\"rows\" [first]=\"first\" [totalRecords]=\"totalRecords\" [pageLinkSize]=\"pageLinks\" styleClass=\"ui-paginator-bottom\" [alwaysShow]=\"alwaysShowPaginator\"\n (onPageChange)=\"onPageChange($event)\" [rowsPerPageOptions]=\"rowsPerPageOptions\" *ngIf=\"paginator && (paginatorPosition === 'bottom' || paginatorPosition =='both')\"\n [templateLeft]=\"paginatorLeftTemplate\" [templateRight]=\"paginatorRightTemplate\" [dropdownAppendTo]=\"paginatorDropdownAppendTo\" [dropdownScrollHeight]=\"paginatorDropdownScrollHeight\"\n [currentPageReportTemplate]=\"currentPageReportTemplate\" [showCurrentPageReport]=\"showCurrentPageReport\"></p-paginator>\n\n <div *ngIf=\"summaryTemplate\" class=\"ui-table-summary ui-widget-header\">\n <ng-container *ngTemplateOutlet=\"summaryTemplate\"></ng-container>\n </div>\n\n <div #resizeHelper class=\"ui-column-resizer-helper ui-state-highlight\" style=\"display:none\" *ngIf=\"resizableColumns\"></div>\n\n <span #reorderIndicatorUp class=\"pi pi-arrow-down ui-table-reorder-indicator-up\" style=\"display:none\" *ngIf=\"reorderableColumns\"></span>\n <span #reorderIndicatorDown class=\"pi pi-arrow-up ui-table-reorder-indicator-down\" style=\"display:none\" *ngIf=\"reorderableColumns\"></span>\n </div>\n ",
1955 providers: [TableService],
1956 changeDetection: core.ChangeDetectionStrategy.Default
1957 })
1958 ], Table);
1959 return Table;
1960 }());
1961 var TableBody = /** @class */ (function () {
1962 function TableBody(dt) {
1963 this.dt = dt;
1964 }
1965 TableBody.ctorParameters = function () { return [
1966 { type: Table }
1967 ]; };
1968 __decorate([
1969 core.Input("pTableBody")
1970 ], TableBody.prototype, "columns", void 0);
1971 __decorate([
1972 core.Input("pTableBodyTemplate")
1973 ], TableBody.prototype, "template", void 0);
1974 __decorate([
1975 core.Input()
1976 ], TableBody.prototype, "frozen", void 0);
1977 TableBody = __decorate([
1978 core.Component({
1979 selector: '[pTableBody]',
1980 template: "\n <ng-container *ngIf=\"!dt.expandedRowTemplate\">\n <ng-template ngFor let-rowData let-rowIndex=\"index\" [ngForOf]=\"(dt.paginator && !dt.lazy) ? ((dt.filteredValue||dt.value) | slice:dt.first:(dt.first + dt.rows)) : (dt.filteredValue||dt.value)\" [ngForTrackBy]=\"dt.rowTrackBy\">\n <ng-container *ngTemplateOutlet=\"template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData))}\"></ng-container>\n </ng-template>\n </ng-container>\n <ng-container *ngIf=\"dt.expandedRowTemplate\">\n <ng-template ngFor let-rowData let-rowIndex=\"index\" [ngForOf]=\"(dt.paginator && !dt.lazy) ? ((dt.filteredValue||dt.value) | slice:dt.first:(dt.first + dt.rows)) : (dt.filteredValue||dt.value)\" [ngForTrackBy]=\"dt.rowTrackBy\">\n <ng-container *ngTemplateOutlet=\"template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData))}\"></ng-container>\n <ng-container *ngIf=\"dt.isRowExpanded(rowData)\">\n <ng-container *ngTemplateOutlet=\"dt.expandedRowTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns}\"></ng-container>\n </ng-container>\n </ng-template>\n </ng-container>\n <ng-container *ngIf=\"dt.loading\">\n <ng-container *ngTemplateOutlet=\"dt.loadingBodyTemplate; context: {$implicit: columns, frozen: frozen}\"></ng-container>\n </ng-container>\n <ng-container *ngIf=\"dt.isEmpty() && !dt.loading\">\n <ng-container *ngTemplateOutlet=\"dt.emptyMessageTemplate; context: {$implicit: columns, frozen: frozen}\"></ng-container>\n </ng-container>\n "
1981 })
1982 ], TableBody);
1983 return TableBody;
1984 }());
1985 var ScrollableView = /** @class */ (function () {
1986 function ScrollableView(dt, el, zone) {
1987 var _this = this;
1988 this.dt = dt;
1989 this.el = el;
1990 this.zone = zone;
1991 this.loadingArray = [];
1992 this.lastBodyScrollTop = 0;
1993 this.subscription = this.dt.tableService.valueSource$.subscribe(function () {
1994 _this.zone.runOutsideAngular(function () {
1995 setTimeout(function () {
1996 _this.alignScrollBar();
1997 if (_this.scrollLoadingTableViewChild && _this.scrollLoadingTableViewChild.nativeElement) {
1998 _this.scrollLoadingTableViewChild.nativeElement.style.display = 'none';
1999 }
2000 }, 50);
2001 });
2002 });
2003 if (this.dt.virtualScroll) {
2004 this.totalRecordsSubscription = this.dt.tableService.totalRecordsSource$.subscribe(function () {
2005 _this.zone.runOutsideAngular(function () {
2006 setTimeout(function () {
2007 _this.setVirtualScrollerHeight();
2008 }, 50);
2009 });
2010 });
2011 }
2012 this.loadingArray = Array(this.dt.rows).fill(1);
2013 this.initialized = false;
2014 }
2015 Object.defineProperty(ScrollableView.prototype, "scrollHeight", {
2016 get: function () {
2017 return this._scrollHeight;
2018 },
2019 set: function (val) {
2020 this._scrollHeight = val;
2021 this.setScrollHeight();
2022 },
2023 enumerable: true,
2024 configurable: true
2025 });
2026 ScrollableView.prototype.ngAfterViewChecked = function () {
2027 if (!this.initialized && this.el.nativeElement.offsetParent) {
2028 this.alignScrollBar();
2029 this.setScrollHeight();
2030 this.initialized = true;
2031 }
2032 };
2033 ScrollableView.prototype.ngAfterViewInit = function () {
2034 var _this = this;
2035 if (!this.frozen) {
2036 if (this.dt.frozenColumns || this.dt.frozenBodyTemplate) {
2037 dom.DomHandler.addClass(this.el.nativeElement, 'ui-table-unfrozen-view');
2038 }
2039 var frozenView = this.el.nativeElement.previousElementSibling;
2040 if (frozenView) {
2041 this.frozenSiblingBody = dom.DomHandler.findSingle(frozenView, '.ui-table-scrollable-body');
2042 }
2043 }
2044 else {
2045 if (this.scrollableAlignerViewChild && this.scrollableAlignerViewChild.nativeElement) {
2046 this.scrollableAlignerViewChild.nativeElement.style.height = dom.DomHandler.calculateScrollbarHeight() + 'px';
2047 }
2048 var scrollableView = this.el.nativeElement.nextElementSibling;
2049 if (scrollableView) {
2050 this.scrollableSiblingBody = dom.DomHandler.findSingle(scrollableView, '.ui-table-scrollable-body');
2051 }
2052 }
2053 this.bindEvents();
2054 this.setScrollHeight();
2055 this.alignScrollBar();
2056 if (this.frozen) {
2057 this.columnsSubscription = this.dt.tableService.columnsSource$.subscribe(function () {
2058 _this.zone.runOutsideAngular(function () {
2059 setTimeout(function () {
2060 _this.setScrollHeight();
2061 }, 50);
2062 });
2063 });
2064 }
2065 if (this.dt.virtualScroll) {
2066 this.setVirtualScrollerHeight();
2067 if (this.scrollLoadingTableViewChild && this.scrollLoadingTableViewChild.nativeElement) {
2068 this.scrollLoadingTableViewChild.nativeElement.style.display = 'table';
2069 }
2070 }
2071 };
2072 ScrollableView.prototype.bindEvents = function () {
2073 var _this = this;
2074 this.zone.runOutsideAngular(function () {
2075 if (_this.scrollHeaderViewChild && _this.scrollHeaderViewChild.nativeElement) {
2076 _this.headerScrollListener = _this.onHeaderScroll.bind(_this);
2077 _this.scrollHeaderViewChild.nativeElement.addEventListener('scroll', _this.headerScrollListener);
2078 }
2079 if (_this.scrollFooterViewChild && _this.scrollFooterViewChild.nativeElement) {
2080 _this.footerScrollListener = _this.onFooterScroll.bind(_this);
2081 _this.scrollFooterViewChild.nativeElement.addEventListener('scroll', _this.footerScrollListener);
2082 }
2083 if (!_this.frozen) {
2084 _this.bodyScrollListener = _this.onBodyScroll.bind(_this);
2085 _this.scrollBodyViewChild.nativeElement.addEventListener('scroll', _this.bodyScrollListener);
2086 }
2087 });
2088 };
2089 ScrollableView.prototype.unbindEvents = function () {
2090 if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
2091 this.scrollHeaderViewChild.nativeElement.removeEventListener('scroll', this.headerScrollListener);
2092 }
2093 if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
2094 this.scrollFooterViewChild.nativeElement.removeEventListener('scroll', this.footerScrollListener);
2095 }
2096 this.scrollBodyViewChild.nativeElement.removeEventListener('scroll', this.bodyScrollListener);
2097 };
2098 ScrollableView.prototype.onHeaderScroll = function (event) {
2099 var scrollLeft = this.scrollHeaderViewChild.nativeElement.scrollLeft;
2100 this.scrollBodyViewChild.nativeElement.scrollLeft = scrollLeft;
2101 if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
2102 this.scrollFooterViewChild.nativeElement.scrollLeft = scrollLeft;
2103 }
2104 this.preventBodyScrollPropagation = true;
2105 };
2106 ScrollableView.prototype.onFooterScroll = function (event) {
2107 var scrollLeft = this.scrollFooterViewChild.nativeElement.scrollLeft;
2108 this.scrollBodyViewChild.nativeElement.scrollLeft = scrollLeft;
2109 if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
2110 this.scrollHeaderViewChild.nativeElement.scrollLeft = scrollLeft;
2111 }
2112 this.preventBodyScrollPropagation = true;
2113 };
2114 ScrollableView.prototype.onBodyScroll = function (event) {
2115 var _this = this;
2116 if (this.preventBodyScrollPropagation) {
2117 this.preventBodyScrollPropagation = false;
2118 return;
2119 }
2120 if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
2121 this.scrollHeaderBoxViewChild.nativeElement.style.marginLeft = -1 * this.scrollBodyViewChild.nativeElement.scrollLeft + 'px';
2122 }
2123 if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
2124 this.scrollFooterBoxViewChild.nativeElement.style.marginLeft = -1 * this.scrollBodyViewChild.nativeElement.scrollLeft + 'px';
2125 }
2126 if (this.frozenSiblingBody) {
2127 this.frozenSiblingBody.scrollTop = this.scrollBodyViewChild.nativeElement.scrollTop;
2128 }
2129 if (this.dt.virtualScroll) {
2130 requestAnimationFrame(function () {
2131 if (_this.lastBodyScrollTop !== _this.scrollBodyViewChild.nativeElement.scrollTop) {
2132 _this.lastBodyScrollTop = _this.scrollBodyViewChild.nativeElement.scrollTop;
2133 var viewport = dom.DomHandler.getOuterHeight(_this.scrollBodyViewChild.nativeElement);
2134 var tableHeight = dom.DomHandler.getOuterHeight(_this.scrollTableViewChild.nativeElement);
2135 var pageHeight_1 = _this.dt.virtualRowHeight * _this.dt.rows;
2136 var virtualTableHeight = dom.DomHandler.getOuterHeight(_this.virtualScrollerViewChild.nativeElement);
2137 var pageCount = (virtualTableHeight / pageHeight_1) || 1;
2138 var scrollBodyTop = _this.scrollTableViewChild.nativeElement.style.top || '0';
2139 if ((_this.scrollBodyViewChild.nativeElement.scrollTop + viewport > parseFloat(scrollBodyTop) + tableHeight) || (_this.scrollBodyViewChild.nativeElement.scrollTop < parseFloat(scrollBodyTop))) {
2140 if (_this.scrollLoadingTableViewChild && _this.scrollLoadingTableViewChild.nativeElement) {
2141 _this.scrollLoadingTableViewChild.nativeElement.style.display = 'table';
2142 _this.scrollLoadingTableViewChild.nativeElement.style.top = _this.scrollBodyViewChild.nativeElement.scrollTop + 'px';
2143 }
2144 var page_1 = Math.floor((_this.scrollBodyViewChild.nativeElement.scrollTop * pageCount) / (_this.scrollBodyViewChild.nativeElement.scrollHeight)) + 1;
2145 _this.dt.handleVirtualScroll({
2146 page: page_1,
2147 callback: function () {
2148 if (_this.scrollLoadingTableViewChild && _this.scrollLoadingTableViewChild.nativeElement) {
2149 _this.scrollLoadingTableViewChild.nativeElement.style.display = 'none';
2150 }
2151 _this.scrollTableViewChild.nativeElement.style.top = ((page_1 - 1) * pageHeight_1) + 'px';
2152 if (_this.frozenSiblingBody) {
2153 _this.frozenSiblingBody.children[0].style.top = _this.scrollTableViewChild.nativeElement.style.top;
2154 }
2155 _this.dt.anchorRowIndex = null;
2156 }
2157 });
2158 }
2159 }
2160 });
2161 }
2162 };
2163 ScrollableView.prototype.setScrollHeight = function () {
2164 if (this.scrollHeight && this.scrollBodyViewChild && this.scrollBodyViewChild.nativeElement) {
2165 if (this.frozenSiblingBody) {
2166 this.scrollBodyViewChild.nativeElement.style.maxHeight = this.frozenSiblingBody.style.maxHeight;
2167 }
2168 else {
2169 if (this.scrollHeight.indexOf('%') !== -1) {
2170 var relativeHeight = void 0;
2171 this.scrollBodyViewChild.nativeElement.style.visibility = 'hidden';
2172 this.scrollBodyViewChild.nativeElement.style.height = '100px'; //temporary height to calculate static height
2173 var containerHeight = dom.DomHandler.getOuterHeight(this.dt.el.nativeElement.children[0]);
2174 if (this.scrollHeight.includes("calc")) {
2175 var percentHeight = parseInt(this.scrollHeight.slice(this.scrollHeight.indexOf("(") + 1, this.scrollHeight.indexOf("%")));
2176 var diffValue = parseInt(this.scrollHeight.slice(this.scrollHeight.indexOf("-") + 1, this.scrollHeight.indexOf(")")));
2177 relativeHeight = (dom.DomHandler.getOuterHeight(this.dt.el.nativeElement.parentElement) * percentHeight / 100) - diffValue;
2178 }
2179 else {
2180 relativeHeight = dom.DomHandler.getOuterHeight(this.dt.el.nativeElement.parentElement) * parseInt(this.scrollHeight) / 100;
2181 }
2182 var staticHeight = containerHeight - 100; //total height of headers, footers, paginators
2183 var scrollBodyHeight = (relativeHeight - staticHeight);
2184 if (this.frozen) {
2185 scrollBodyHeight -= dom.DomHandler.calculateScrollbarWidth();
2186 }
2187 this.scrollBodyViewChild.nativeElement.style.height = 'auto';
2188 this.scrollBodyViewChild.nativeElement.style.maxHeight = scrollBodyHeight + 'px';
2189 this.scrollBodyViewChild.nativeElement.style.visibility = 'visible';
2190 }
2191 else {
2192 this.scrollBodyViewChild.nativeElement.style.maxHeight = this.scrollHeight;
2193 }
2194 }
2195 }
2196 };
2197 ScrollableView.prototype.setVirtualScrollerHeight = function () {
2198 if (this.virtualScrollerViewChild.nativeElement) {
2199 this.virtualScrollerViewChild.nativeElement.style.height = this.dt.totalRecords * this.dt.virtualRowHeight + 'px';
2200 }
2201 };
2202 ScrollableView.prototype.hasVerticalOverflow = function () {
2203 return dom.DomHandler.getOuterHeight(this.scrollTableViewChild.nativeElement) > dom.DomHandler.getOuterHeight(this.scrollBodyViewChild.nativeElement);
2204 };
2205 ScrollableView.prototype.alignScrollBar = function () {
2206 if (!this.frozen) {
2207 var scrollBarWidth = this.hasVerticalOverflow() ? dom.DomHandler.calculateScrollbarWidth() : 0;
2208 this.scrollHeaderBoxViewChild.nativeElement.style.marginRight = scrollBarWidth + 'px';
2209 if (this.scrollFooterBoxViewChild && this.scrollFooterBoxViewChild.nativeElement) {
2210 this.scrollFooterBoxViewChild.nativeElement.style.marginRight = scrollBarWidth + 'px';
2211 }
2212 }
2213 this.initialized = false;
2214 };
2215 ScrollableView.prototype.ngOnDestroy = function () {
2216 this.unbindEvents();
2217 this.frozenSiblingBody = null;
2218 if (this.subscription) {
2219 this.subscription.unsubscribe();
2220 }
2221 if (this.totalRecordsSubscription) {
2222 this.totalRecordsSubscription.unsubscribe();
2223 }
2224 if (this.columnsSubscription) {
2225 this.columnsSubscription.unsubscribe();
2226 }
2227 this.initialized = false;
2228 };
2229 ScrollableView.ctorParameters = function () { return [
2230 { type: Table },
2231 { type: core.ElementRef },
2232 { type: core.NgZone }
2233 ]; };
2234 __decorate([
2235 core.Input("pScrollableView")
2236 ], ScrollableView.prototype, "columns", void 0);
2237 __decorate([
2238 core.Input()
2239 ], ScrollableView.prototype, "frozen", void 0);
2240 __decorate([
2241 core.ViewChild('scrollHeader')
2242 ], ScrollableView.prototype, "scrollHeaderViewChild", void 0);
2243 __decorate([
2244 core.ViewChild('scrollHeaderBox')
2245 ], ScrollableView.prototype, "scrollHeaderBoxViewChild", void 0);
2246 __decorate([
2247 core.ViewChild('scrollBody')
2248 ], ScrollableView.prototype, "scrollBodyViewChild", void 0);
2249 __decorate([
2250 core.ViewChild('scrollTable')
2251 ], ScrollableView.prototype, "scrollTableViewChild", void 0);
2252 __decorate([
2253 core.ViewChild('loadingTable')
2254 ], ScrollableView.prototype, "scrollLoadingTableViewChild", void 0);
2255 __decorate([
2256 core.ViewChild('scrollFooter')
2257 ], ScrollableView.prototype, "scrollFooterViewChild", void 0);
2258 __decorate([
2259 core.ViewChild('scrollFooterBox')
2260 ], ScrollableView.prototype, "scrollFooterBoxViewChild", void 0);
2261 __decorate([
2262 core.ViewChild('virtualScroller')
2263 ], ScrollableView.prototype, "virtualScrollerViewChild", void 0);
2264 __decorate([
2265 core.ViewChild('scrollableAligner')
2266 ], ScrollableView.prototype, "scrollableAlignerViewChild", void 0);
2267 __decorate([
2268 core.Input()
2269 ], ScrollableView.prototype, "scrollHeight", null);
2270 ScrollableView = __decorate([
2271 core.Component({
2272 selector: '[pScrollableView]',
2273 template: "\n <div #scrollHeader class=\"ui-table-scrollable-header ui-widget-header\">\n <div #scrollHeaderBox class=\"ui-table-scrollable-header-box\">\n <table class=\"ui-table-scrollable-header-table\" [ngClass]=\"dt.tableStyleClass\" [ngStyle]=\"dt.tableStyle\">\n <ng-container *ngTemplateOutlet=\"frozen ? dt.frozenColGroupTemplate||dt.colGroupTemplate : dt.colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <thead class=\"ui-table-thead\">\n <ng-container *ngTemplateOutlet=\"frozen ? dt.frozenHeaderTemplate||dt.headerTemplate : dt.headerTemplate; context {$implicit: columns}\"></ng-container>\n </thead>\n <tbody class=\"ui-table-tbody\">\n <ng-template ngFor let-rowData let-rowIndex=\"index\" [ngForOf]=\"dt.frozenValue\" [ngForTrackBy]=\"dt.rowTrackBy\">\n <ng-container *ngTemplateOutlet=\"dt.frozenRowsTemplate; context: {$implicit: rowData, rowIndex: rowIndex, columns: columns}\"></ng-container>\n </ng-template>\n </tbody>\n </table>\n </div>\n </div>\n <div #scrollBody class=\"ui-table-scrollable-body\">\n <table #scrollTable [ngClass]=\"{'ui-table-scrollable-body-table': true, 'ui-table-virtual-table': dt.virtualScroll}\" [class]=\"dt.tableStyleClass\" [ngStyle]=\"dt.tableStyle\">\n <ng-container *ngTemplateOutlet=\"frozen ? dt.frozenColGroupTemplate||dt.colGroupTemplate : dt.colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <tbody class=\"ui-table-tbody\" [pTableBody]=\"columns\" [pTableBodyTemplate]=\"frozen ? dt.frozenBodyTemplate||dt.bodyTemplate : dt.bodyTemplate\" [frozen]=\"frozen\"></tbody>\n </table>\n <table #loadingTable *ngIf=\"dt.virtualScroll && dt.loadingBodyTemplate != null\" [ngClass]=\"{'ui-table-scrollable-body-table ui-table-loading-virtual-table': true, 'ui-table-virtual-table': dt.virtualScroll}\">\n <tbody class=\"ui-table-tbody\">\n <ng-template ngFor [ngForOf]=\"loadingArray\">\n <ng-container *ngTemplateOutlet=\"dt.loadingBodyTemplate; context: {columns: columns}\"></ng-container>\n </ng-template>\n </tbody>\n </table>\n <div #scrollableAligner style=\"background-color:transparent\" *ngIf=\"frozen\"></div>\n <div #virtualScroller class=\"ui-table-virtual-scroller\" *ngIf=\"dt.virtualScroll\"></div>\n </div>\n <div #scrollFooter class=\"ui-table-scrollable-footer ui-widget-header\">\n <div #scrollFooterBox class=\"ui-table-scrollable-footer-box\">\n <table class=\"ui-table-scrollable-footer-table\" [ngClass]=\"dt.tableStyleClass\" [ngStyle]=\"dt.tableStyle\">\n <ng-container *ngTemplateOutlet=\"frozen ? dt.frozenColGroupTemplate||dt.colGroupTemplate : dt.colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <tfoot class=\"ui-table-tfoot\">\n <ng-container *ngTemplateOutlet=\"frozen ? dt.frozenFooterTemplate||dt.footerTemplate : dt.footerTemplate; context {$implicit: columns}\"></ng-container>\n </tfoot>\n </table>\n </div>\n </div>\n "
2274 })
2275 ], ScrollableView);
2276 return ScrollableView;
2277 }());
2278 var SortableColumn = /** @class */ (function () {
2279 function SortableColumn(dt) {
2280 var _this = this;
2281 this.dt = dt;
2282 if (this.isEnabled()) {
2283 this.subscription = this.dt.tableService.sortSource$.subscribe(function (sortMeta) {
2284 _this.updateSortState();
2285 });
2286 }
2287 }
2288 SortableColumn.prototype.ngOnInit = function () {
2289 if (this.isEnabled()) {
2290 this.updateSortState();
2291 }
2292 };
2293 SortableColumn.prototype.updateSortState = function () {
2294 this.sorted = this.dt.isSorted(this.field);
2295 this.sortOrder = this.sorted ? (this.dt.sortOrder === 1 ? 'ascending' : 'descending') : 'none';
2296 };
2297 SortableColumn.prototype.onClick = function (event) {
2298 if (this.isEnabled()) {
2299 this.updateSortState();
2300 this.dt.sort({
2301 originalEvent: event,
2302 field: this.field
2303 });
2304 dom.DomHandler.clearSelection();
2305 }
2306 };
2307 SortableColumn.prototype.onEnterKey = function (event) {
2308 this.onClick(event);
2309 };
2310 SortableColumn.prototype.isEnabled = function () {
2311 return this.pSortableColumnDisabled !== true;
2312 };
2313 SortableColumn.prototype.ngOnDestroy = function () {
2314 if (this.subscription) {
2315 this.subscription.unsubscribe();
2316 }
2317 };
2318 SortableColumn.ctorParameters = function () { return [
2319 { type: Table }
2320 ]; };
2321 __decorate([
2322 core.Input("pSortableColumn")
2323 ], SortableColumn.prototype, "field", void 0);
2324 __decorate([
2325 core.Input()
2326 ], SortableColumn.prototype, "pSortableColumnDisabled", void 0);
2327 __decorate([
2328 core.HostListener('click', ['$event'])
2329 ], SortableColumn.prototype, "onClick", null);
2330 __decorate([
2331 core.HostListener('keydown.enter', ['$event'])
2332 ], SortableColumn.prototype, "onEnterKey", null);
2333 SortableColumn = __decorate([
2334 core.Directive({
2335 selector: '[pSortableColumn]',
2336 host: {
2337 '[class.ui-sortable-column]': 'isEnabled()',
2338 '[class.ui-state-highlight]': 'sorted',
2339 '[attr.tabindex]': 'isEnabled() ? "0" : null',
2340 '[attr.role]': '"columnheader"',
2341 '[attr.aria-sort]': 'sortOrder'
2342 }
2343 })
2344 ], SortableColumn);
2345 return SortableColumn;
2346 }());
2347 var SortIcon = /** @class */ (function () {
2348 function SortIcon(dt) {
2349 var _this = this;
2350 this.dt = dt;
2351 this.subscription = this.dt.tableService.sortSource$.subscribe(function (sortMeta) {
2352 _this.updateSortState();
2353 });
2354 }
2355 SortIcon.prototype.ngOnInit = function () {
2356 this.updateSortState();
2357 };
2358 SortIcon.prototype.onClick = function (event) {
2359 event.preventDefault();
2360 };
2361 SortIcon.prototype.updateSortState = function () {
2362 if (this.dt.sortMode === 'single') {
2363 this.sortOrder = this.dt.isSorted(this.field) ? this.dt.sortOrder : 0;
2364 }
2365 else if (this.dt.sortMode === 'multiple') {
2366 var sortMeta = this.dt.getSortMeta(this.field);
2367 this.sortOrder = sortMeta ? sortMeta.order : 0;
2368 }
2369 };
2370 SortIcon.prototype.ngOnDestroy = function () {
2371 if (this.subscription) {
2372 this.subscription.unsubscribe();
2373 }
2374 };
2375 SortIcon.ctorParameters = function () { return [
2376 { type: Table }
2377 ]; };
2378 __decorate([
2379 core.Input()
2380 ], SortIcon.prototype, "field", void 0);
2381 SortIcon = __decorate([
2382 core.Component({
2383 selector: 'p-sortIcon',
2384 template: "\n <i class=\"ui-sortable-column-icon pi pi-fw\" [ngClass]=\"{'pi-sort-amount-up-alt': sortOrder === 1, 'pi-sort-amount-down': sortOrder === -1, 'pi-sort-alt': sortOrder === 0}\"></i>\n "
2385 })
2386 ], SortIcon);
2387 return SortIcon;
2388 }());
2389 var SelectableRow = /** @class */ (function () {
2390 function SelectableRow(dt, tableService) {
2391 var _this = this;
2392 this.dt = dt;
2393 this.tableService = tableService;
2394 if (this.isEnabled()) {
2395 this.subscription = this.dt.tableService.selectionSource$.subscribe(function () {
2396 _this.selected = _this.dt.isSelected(_this.data);
2397 });
2398 }
2399 }
2400 SelectableRow.prototype.ngOnInit = function () {
2401 if (this.isEnabled()) {
2402 this.selected = this.dt.isSelected(this.data);
2403 }
2404 };
2405 SelectableRow.prototype.onClick = function (event) {
2406 if (this.isEnabled()) {
2407 this.dt.handleRowClick({
2408 originalEvent: event,
2409 rowData: this.data,
2410 rowIndex: this.index
2411 });
2412 }
2413 };
2414 SelectableRow.prototype.onTouchEnd = function (event) {
2415 if (this.isEnabled()) {
2416 this.dt.handleRowTouchEnd(event);
2417 }
2418 };
2419 SelectableRow.prototype.onArrowDownKeyDown = function (event) {
2420 if (!this.isEnabled()) {
2421 return;
2422 }
2423 var row = event.currentTarget;
2424 var nextRow = this.findNextSelectableRow(row);
2425 if (nextRow) {
2426 nextRow.focus();
2427 }
2428 event.preventDefault();
2429 };
2430 SelectableRow.prototype.onArrowUpKeyDown = function (event) {
2431 if (!this.isEnabled()) {
2432 return;
2433 }
2434 var row = event.currentTarget;
2435 var prevRow = this.findPrevSelectableRow(row);
2436 if (prevRow) {
2437 prevRow.focus();
2438 }
2439 event.preventDefault();
2440 };
2441 SelectableRow.prototype.onEnterKeyDown = function (event) {
2442 if (!this.isEnabled()) {
2443 return;
2444 }
2445 this.dt.handleRowClick({
2446 originalEvent: event,
2447 rowData: this.data,
2448 rowIndex: this.index
2449 });
2450 };
2451 SelectableRow.prototype.findNextSelectableRow = function (row) {
2452 var nextRow = row.nextElementSibling;
2453 if (nextRow) {
2454 if (dom.DomHandler.hasClass(nextRow, 'ui-selectable-row'))
2455 return nextRow;
2456 else
2457 return this.findNextSelectableRow(nextRow);
2458 }
2459 else {
2460 return null;
2461 }
2462 };
2463 SelectableRow.prototype.findPrevSelectableRow = function (row) {
2464 var prevRow = row.previousElementSibling;
2465 if (prevRow) {
2466 if (dom.DomHandler.hasClass(prevRow, 'ui-selectable-row'))
2467 return prevRow;
2468 else
2469 return this.findPrevSelectableRow(prevRow);
2470 }
2471 else {
2472 return null;
2473 }
2474 };
2475 SelectableRow.prototype.isEnabled = function () {
2476 return this.pSelectableRowDisabled !== true;
2477 };
2478 SelectableRow.prototype.ngOnDestroy = function () {
2479 if (this.subscription) {
2480 this.subscription.unsubscribe();
2481 }
2482 };
2483 SelectableRow.ctorParameters = function () { return [
2484 { type: Table },
2485 { type: TableService }
2486 ]; };
2487 __decorate([
2488 core.Input("pSelectableRow")
2489 ], SelectableRow.prototype, "data", void 0);
2490 __decorate([
2491 core.Input("pSelectableRowIndex")
2492 ], SelectableRow.prototype, "index", void 0);
2493 __decorate([
2494 core.Input()
2495 ], SelectableRow.prototype, "pSelectableRowDisabled", void 0);
2496 __decorate([
2497 core.HostListener('click', ['$event'])
2498 ], SelectableRow.prototype, "onClick", null);
2499 __decorate([
2500 core.HostListener('touchend', ['$event'])
2501 ], SelectableRow.prototype, "onTouchEnd", null);
2502 __decorate([
2503 core.HostListener('keydown.arrowdown', ['$event'])
2504 ], SelectableRow.prototype, "onArrowDownKeyDown", null);
2505 __decorate([
2506 core.HostListener('keydown.arrowup', ['$event'])
2507 ], SelectableRow.prototype, "onArrowUpKeyDown", null);
2508 __decorate([
2509 core.HostListener('keydown.enter', ['$event'])
2510 ], SelectableRow.prototype, "onEnterKeyDown", null);
2511 SelectableRow = __decorate([
2512 core.Directive({
2513 selector: '[pSelectableRow]',
2514 host: {
2515 '[class.ui-selectable-row]': 'isEnabled()',
2516 '[class.ui-state-highlight]': 'selected',
2517 '[attr.tabindex]': 'isEnabled() ? 0 : undefined'
2518 }
2519 })
2520 ], SelectableRow);
2521 return SelectableRow;
2522 }());
2523 var SelectableRowDblClick = /** @class */ (function () {
2524 function SelectableRowDblClick(dt, tableService) {
2525 var _this = this;
2526 this.dt = dt;
2527 this.tableService = tableService;
2528 if (this.isEnabled()) {
2529 this.subscription = this.dt.tableService.selectionSource$.subscribe(function () {
2530 _this.selected = _this.dt.isSelected(_this.data);
2531 });
2532 }
2533 }
2534 SelectableRowDblClick.prototype.ngOnInit = function () {
2535 if (this.isEnabled()) {
2536 this.selected = this.dt.isSelected(this.data);
2537 }
2538 };
2539 SelectableRowDblClick.prototype.onClick = function (event) {
2540 if (this.isEnabled()) {
2541 this.dt.handleRowClick({
2542 originalEvent: event,
2543 rowData: this.data,
2544 rowIndex: this.index
2545 });
2546 }
2547 };
2548 SelectableRowDblClick.prototype.isEnabled = function () {
2549 return this.pSelectableRowDisabled !== true;
2550 };
2551 SelectableRowDblClick.prototype.ngOnDestroy = function () {
2552 if (this.subscription) {
2553 this.subscription.unsubscribe();
2554 }
2555 };
2556 SelectableRowDblClick.ctorParameters = function () { return [
2557 { type: Table },
2558 { type: TableService }
2559 ]; };
2560 __decorate([
2561 core.Input("pSelectableRowDblClick")
2562 ], SelectableRowDblClick.prototype, "data", void 0);
2563 __decorate([
2564 core.Input("pSelectableRowIndex")
2565 ], SelectableRowDblClick.prototype, "index", void 0);
2566 __decorate([
2567 core.Input()
2568 ], SelectableRowDblClick.prototype, "pSelectableRowDisabled", void 0);
2569 __decorate([
2570 core.HostListener('dblclick', ['$event'])
2571 ], SelectableRowDblClick.prototype, "onClick", null);
2572 SelectableRowDblClick = __decorate([
2573 core.Directive({
2574 selector: '[pSelectableRowDblClick]',
2575 host: {
2576 '[class.ui-selectable-row]': 'isEnabled()',
2577 '[class.ui-state-highlight]': 'selected'
2578 }
2579 })
2580 ], SelectableRowDblClick);
2581 return SelectableRowDblClick;
2582 }());
2583 var ContextMenuRow = /** @class */ (function () {
2584 function ContextMenuRow(dt, tableService, el) {
2585 var _this = this;
2586 this.dt = dt;
2587 this.tableService = tableService;
2588 this.el = el;
2589 if (this.isEnabled()) {
2590 this.subscription = this.dt.tableService.contextMenuSource$.subscribe(function (data) {
2591 _this.selected = _this.dt.equals(_this.data, data);
2592 });
2593 }
2594 }
2595 ContextMenuRow.prototype.onContextMenu = function (event) {
2596 if (this.isEnabled()) {
2597 this.dt.handleRowRightClick({
2598 originalEvent: event,
2599 rowData: this.data,
2600 rowIndex: this.index
2601 });
2602 this.el.nativeElement.focus();
2603 event.preventDefault();
2604 }
2605 };
2606 ContextMenuRow.prototype.isEnabled = function () {
2607 return this.pContextMenuRowDisabled !== true;
2608 };
2609 ContextMenuRow.prototype.ngOnDestroy = function () {
2610 if (this.subscription) {
2611 this.subscription.unsubscribe();
2612 }
2613 };
2614 ContextMenuRow.ctorParameters = function () { return [
2615 { type: Table },
2616 { type: TableService },
2617 { type: core.ElementRef }
2618 ]; };
2619 __decorate([
2620 core.Input("pContextMenuRow")
2621 ], ContextMenuRow.prototype, "data", void 0);
2622 __decorate([
2623 core.Input("pContextMenuRowIndex")
2624 ], ContextMenuRow.prototype, "index", void 0);
2625 __decorate([
2626 core.Input()
2627 ], ContextMenuRow.prototype, "pContextMenuRowDisabled", void 0);
2628 __decorate([
2629 core.HostListener('contextmenu', ['$event'])
2630 ], ContextMenuRow.prototype, "onContextMenu", null);
2631 ContextMenuRow = __decorate([
2632 core.Directive({
2633 selector: '[pContextMenuRow]',
2634 host: {
2635 '[class.ui-contextmenu-selected]': 'selected',
2636 '[attr.tabindex]': 'isEnabled() ? 0 : undefined'
2637 }
2638 })
2639 ], ContextMenuRow);
2640 return ContextMenuRow;
2641 }());
2642 var RowToggler = /** @class */ (function () {
2643 function RowToggler(dt) {
2644 this.dt = dt;
2645 }
2646 RowToggler.prototype.onClick = function (event) {
2647 if (this.isEnabled()) {
2648 this.dt.toggleRow(this.data, event);
2649 event.preventDefault();
2650 }
2651 };
2652 RowToggler.prototype.isEnabled = function () {
2653 return this.pRowTogglerDisabled !== true;
2654 };
2655 RowToggler.ctorParameters = function () { return [
2656 { type: Table }
2657 ]; };
2658 __decorate([
2659 core.Input('pRowToggler')
2660 ], RowToggler.prototype, "data", void 0);
2661 __decorate([
2662 core.Input()
2663 ], RowToggler.prototype, "pRowTogglerDisabled", void 0);
2664 __decorate([
2665 core.HostListener('click', ['$event'])
2666 ], RowToggler.prototype, "onClick", null);
2667 RowToggler = __decorate([
2668 core.Directive({
2669 selector: '[pRowToggler]'
2670 })
2671 ], RowToggler);
2672 return RowToggler;
2673 }());
2674 var ResizableColumn = /** @class */ (function () {
2675 function ResizableColumn(dt, el, zone) {
2676 this.dt = dt;
2677 this.el = el;
2678 this.zone = zone;
2679 }
2680 ResizableColumn.prototype.ngAfterViewInit = function () {
2681 var _this = this;
2682 if (this.isEnabled()) {
2683 dom.DomHandler.addClass(this.el.nativeElement, 'ui-resizable-column');
2684 this.resizer = document.createElement('span');
2685 this.resizer.className = 'ui-column-resizer ui-clickable';
2686 this.el.nativeElement.appendChild(this.resizer);
2687 this.zone.runOutsideAngular(function () {
2688 _this.resizerMouseDownListener = _this.onMouseDown.bind(_this);
2689 _this.resizer.addEventListener('mousedown', _this.resizerMouseDownListener);
2690 });
2691 }
2692 };
2693 ResizableColumn.prototype.bindDocumentEvents = function () {
2694 var _this = this;
2695 this.zone.runOutsideAngular(function () {
2696 _this.documentMouseMoveListener = _this.onDocumentMouseMove.bind(_this);
2697 document.addEventListener('mousemove', _this.documentMouseMoveListener);
2698 _this.documentMouseUpListener = _this.onDocumentMouseUp.bind(_this);
2699 document.addEventListener('mouseup', _this.documentMouseUpListener);
2700 });
2701 };
2702 ResizableColumn.prototype.unbindDocumentEvents = function () {
2703 if (this.documentMouseMoveListener) {
2704 document.removeEventListener('mousemove', this.documentMouseMoveListener);
2705 this.documentMouseMoveListener = null;
2706 }
2707 if (this.documentMouseUpListener) {
2708 document.removeEventListener('mouseup', this.documentMouseUpListener);
2709 this.documentMouseUpListener = null;
2710 }
2711 };
2712 ResizableColumn.prototype.onMouseDown = function (event) {
2713 if (event.which === 1) {
2714 this.dt.onColumnResizeBegin(event);
2715 this.bindDocumentEvents();
2716 }
2717 };
2718 ResizableColumn.prototype.onDocumentMouseMove = function (event) {
2719 this.dt.onColumnResize(event);
2720 };
2721 ResizableColumn.prototype.onDocumentMouseUp = function (event) {
2722 this.dt.onColumnResizeEnd(event, this.el.nativeElement);
2723 this.unbindDocumentEvents();
2724 };
2725 ResizableColumn.prototype.isEnabled = function () {
2726 return this.pResizableColumnDisabled !== true;
2727 };
2728 ResizableColumn.prototype.ngOnDestroy = function () {
2729 if (this.resizerMouseDownListener) {
2730 this.resizer.removeEventListener('mousedown', this.resizerMouseDownListener);
2731 }
2732 this.unbindDocumentEvents();
2733 };
2734 ResizableColumn.ctorParameters = function () { return [
2735 { type: Table },
2736 { type: core.ElementRef },
2737 { type: core.NgZone }
2738 ]; };
2739 __decorate([
2740 core.Input()
2741 ], ResizableColumn.prototype, "pResizableColumnDisabled", void 0);
2742 ResizableColumn = __decorate([
2743 core.Directive({
2744 selector: '[pResizableColumn]'
2745 })
2746 ], ResizableColumn);
2747 return ResizableColumn;
2748 }());
2749 var ReorderableColumn = /** @class */ (function () {
2750 function ReorderableColumn(dt, el, zone) {
2751 this.dt = dt;
2752 this.el = el;
2753 this.zone = zone;
2754 }
2755 ReorderableColumn.prototype.ngAfterViewInit = function () {
2756 if (this.isEnabled()) {
2757 this.bindEvents();
2758 }
2759 };
2760 ReorderableColumn.prototype.bindEvents = function () {
2761 var _this = this;
2762 this.zone.runOutsideAngular(function () {
2763 _this.mouseDownListener = _this.onMouseDown.bind(_this);
2764 _this.el.nativeElement.addEventListener('mousedown', _this.mouseDownListener);
2765 _this.dragStartListener = _this.onDragStart.bind(_this);
2766 _this.el.nativeElement.addEventListener('dragstart', _this.dragStartListener);
2767 _this.dragOverListener = _this.onDragEnter.bind(_this);
2768 _this.el.nativeElement.addEventListener('dragover', _this.dragOverListener);
2769 _this.dragEnterListener = _this.onDragEnter.bind(_this);
2770 _this.el.nativeElement.addEventListener('dragenter', _this.dragEnterListener);
2771 _this.dragLeaveListener = _this.onDragLeave.bind(_this);
2772 _this.el.nativeElement.addEventListener('dragleave', _this.dragLeaveListener);
2773 });
2774 };
2775 ReorderableColumn.prototype.unbindEvents = function () {
2776 if (this.mouseDownListener) {
2777 document.removeEventListener('mousedown', this.mouseDownListener);
2778 this.mouseDownListener = null;
2779 }
2780 if (this.dragOverListener) {
2781 document.removeEventListener('dragover', this.dragOverListener);
2782 this.dragOverListener = null;
2783 }
2784 if (this.dragEnterListener) {
2785 document.removeEventListener('dragenter', this.dragEnterListener);
2786 this.dragEnterListener = null;
2787 }
2788 if (this.dragEnterListener) {
2789 document.removeEventListener('dragenter', this.dragEnterListener);
2790 this.dragEnterListener = null;
2791 }
2792 if (this.dragLeaveListener) {
2793 document.removeEventListener('dragleave', this.dragLeaveListener);
2794 this.dragLeaveListener = null;
2795 }
2796 };
2797 ReorderableColumn.prototype.onMouseDown = function (event) {
2798 if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' || dom.DomHandler.hasClass(event.target, 'ui-column-resizer'))
2799 this.el.nativeElement.draggable = false;
2800 else
2801 this.el.nativeElement.draggable = true;
2802 };
2803 ReorderableColumn.prototype.onDragStart = function (event) {
2804 this.dt.onColumnDragStart(event, this.el.nativeElement);
2805 };
2806 ReorderableColumn.prototype.onDragOver = function (event) {
2807 event.preventDefault();
2808 };
2809 ReorderableColumn.prototype.onDragEnter = function (event) {
2810 this.dt.onColumnDragEnter(event, this.el.nativeElement);
2811 };
2812 ReorderableColumn.prototype.onDragLeave = function (event) {
2813 this.dt.onColumnDragLeave(event);
2814 };
2815 ReorderableColumn.prototype.onDrop = function (event) {
2816 if (this.isEnabled()) {
2817 this.dt.onColumnDrop(event, this.el.nativeElement);
2818 }
2819 };
2820 ReorderableColumn.prototype.isEnabled = function () {
2821 return this.pReorderableColumnDisabled !== true;
2822 };
2823 ReorderableColumn.prototype.ngOnDestroy = function () {
2824 this.unbindEvents();
2825 };
2826 ReorderableColumn.ctorParameters = function () { return [
2827 { type: Table },
2828 { type: core.ElementRef },
2829 { type: core.NgZone }
2830 ]; };
2831 __decorate([
2832 core.Input()
2833 ], ReorderableColumn.prototype, "pReorderableColumnDisabled", void 0);
2834 __decorate([
2835 core.HostListener('drop', ['$event'])
2836 ], ReorderableColumn.prototype, "onDrop", null);
2837 ReorderableColumn = __decorate([
2838 core.Directive({
2839 selector: '[pReorderableColumn]'
2840 })
2841 ], ReorderableColumn);
2842 return ReorderableColumn;
2843 }());
2844 var EditableColumn = /** @class */ (function () {
2845 function EditableColumn(dt, el, zone) {
2846 this.dt = dt;
2847 this.el = el;
2848 this.zone = zone;
2849 }
2850 EditableColumn.prototype.ngAfterViewInit = function () {
2851 if (this.isEnabled()) {
2852 dom.DomHandler.addClass(this.el.nativeElement, 'ui-editable-column');
2853 }
2854 };
2855 EditableColumn.prototype.onClick = function (event) {
2856 if (this.isEnabled()) {
2857 this.dt.editingCellClick = true;
2858 if (this.dt.editingCell) {
2859 if (this.dt.editingCell !== this.el.nativeElement) {
2860 if (!this.dt.isEditingCellValid()) {
2861 return;
2862 }
2863 this.closeEditingCell(true, event);
2864 this.openCell();
2865 }
2866 }
2867 else {
2868 this.openCell();
2869 }
2870 }
2871 };
2872 EditableColumn.prototype.openCell = function () {
2873 var _this = this;
2874 this.dt.updateEditingCell(this.el.nativeElement, this.data, this.field, this.rowIndex);
2875 dom.DomHandler.addClass(this.el.nativeElement, 'ui-editing-cell');
2876 this.dt.onEditInit.emit({ field: this.field, data: this.data, index: this.rowIndex });
2877 this.zone.runOutsideAngular(function () {
2878 setTimeout(function () {
2879 var focusCellSelector = _this.pFocusCellSelector || 'input, textarea, select';
2880 var focusableElement = dom.DomHandler.findSingle(_this.el.nativeElement, focusCellSelector);
2881 if (focusableElement) {
2882 focusableElement.focus();
2883 }
2884 }, 50);
2885 });
2886 };
2887 EditableColumn.prototype.closeEditingCell = function (completed, event) {
2888 if (completed)
2889 this.dt.onEditComplete.emit({ field: this.dt.editingCellField, data: this.dt.editingCellData, originalEvent: event, index: this.rowIndex });
2890 else
2891 this.dt.onEditCancel.emit({ field: this.dt.editingCellField, data: this.dt.editingCellData, originalEvent: event, index: this.rowIndex });
2892 dom.DomHandler.removeClass(this.dt.editingCell, 'ui-editing-cell');
2893 this.dt.editingCell = null;
2894 this.dt.editingCellData = null;
2895 this.dt.editingCellField = null;
2896 this.dt.unbindDocumentEditListener();
2897 };
2898 EditableColumn.prototype.onEnterKeyDown = function (event) {
2899 if (this.isEnabled()) {
2900 if (this.dt.isEditingCellValid()) {
2901 this.closeEditingCell(true, event);
2902 }
2903 event.preventDefault();
2904 }
2905 };
2906 EditableColumn.prototype.onEscapeKeyDown = function (event) {
2907 if (this.isEnabled()) {
2908 if (this.dt.isEditingCellValid()) {
2909 this.closeEditingCell(false, event);
2910 }
2911 event.preventDefault();
2912 }
2913 };
2914 EditableColumn.prototype.onShiftKeyDown = function (event) {
2915 if (this.isEnabled()) {
2916 if (event.shiftKey)
2917 this.moveToPreviousCell(event);
2918 else {
2919 this.moveToNextCell(event);
2920 }
2921 }
2922 };
2923 EditableColumn.prototype.findCell = function (element) {
2924 if (element) {
2925 var cell = element;
2926 while (cell && !dom.DomHandler.hasClass(cell, 'ui-editing-cell')) {
2927 cell = cell.parentElement;
2928 }
2929 return cell;
2930 }
2931 else {
2932 return null;
2933 }
2934 };
2935 EditableColumn.prototype.moveToPreviousCell = function (event) {
2936 var currentCell = this.findCell(event.target);
2937 if (currentCell) {
2938 var targetCell = this.findPreviousEditableColumn(currentCell);
2939 if (targetCell) {
2940 if (this.dt.isEditingCellValid()) {
2941 this.closeEditingCell(true, event);
2942 }
2943 dom.DomHandler.invokeElementMethod(event.target, 'blur');
2944 dom.DomHandler.invokeElementMethod(targetCell, 'click');
2945 event.preventDefault();
2946 }
2947 }
2948 };
2949 EditableColumn.prototype.moveToNextCell = function (event) {
2950 var currentCell = this.findCell(event.target);
2951 if (currentCell) {
2952 var targetCell = this.findNextEditableColumn(currentCell);
2953 if (targetCell) {
2954 if (this.dt.isEditingCellValid()) {
2955 this.closeEditingCell(true, event);
2956 }
2957 dom.DomHandler.invokeElementMethod(event.target, 'blur');
2958 dom.DomHandler.invokeElementMethod(targetCell, 'click');
2959 event.preventDefault();
2960 }
2961 }
2962 };
2963 EditableColumn.prototype.findPreviousEditableColumn = function (cell) {
2964 var prevCell = cell.previousElementSibling;
2965 if (!prevCell) {
2966 var previousRow = cell.parentElement.previousElementSibling;
2967 if (previousRow) {
2968 prevCell = previousRow.lastElementChild;
2969 }
2970 }
2971 if (prevCell) {
2972 if (dom.DomHandler.hasClass(prevCell, 'ui-editable-column'))
2973 return prevCell;
2974 else
2975 return this.findPreviousEditableColumn(prevCell);
2976 }
2977 else {
2978 return null;
2979 }
2980 };
2981 EditableColumn.prototype.findNextEditableColumn = function (cell) {
2982 var nextCell = cell.nextElementSibling;
2983 if (!nextCell) {
2984 var nextRow = cell.parentElement.nextElementSibling;
2985 if (nextRow) {
2986 nextCell = nextRow.firstElementChild;
2987 }
2988 }
2989 if (nextCell) {
2990 if (dom.DomHandler.hasClass(nextCell, 'ui-editable-column'))
2991 return nextCell;
2992 else
2993 return this.findNextEditableColumn(nextCell);
2994 }
2995 else {
2996 return null;
2997 }
2998 };
2999 EditableColumn.prototype.isEnabled = function () {
3000 return this.pEditableColumnDisabled !== true;
3001 };
3002 EditableColumn.ctorParameters = function () { return [
3003 { type: Table },
3004 { type: core.ElementRef },
3005 { type: core.NgZone }
3006 ]; };
3007 __decorate([
3008 core.Input("pEditableColumn")
3009 ], EditableColumn.prototype, "data", void 0);
3010 __decorate([
3011 core.Input("pEditableColumnField")
3012 ], EditableColumn.prototype, "field", void 0);
3013 __decorate([
3014 core.Input("pEditableColumnRowIndex")
3015 ], EditableColumn.prototype, "rowIndex", void 0);
3016 __decorate([
3017 core.Input()
3018 ], EditableColumn.prototype, "pEditableColumnDisabled", void 0);
3019 __decorate([
3020 core.Input()
3021 ], EditableColumn.prototype, "pFocusCellSelector", void 0);
3022 __decorate([
3023 core.HostListener('click', ['$event'])
3024 ], EditableColumn.prototype, "onClick", null);
3025 __decorate([
3026 core.HostListener('keydown.enter', ['$event'])
3027 ], EditableColumn.prototype, "onEnterKeyDown", null);
3028 __decorate([
3029 core.HostListener('keydown.escape', ['$event'])
3030 ], EditableColumn.prototype, "onEscapeKeyDown", null);
3031 __decorate([
3032 core.HostListener('keydown.tab', ['$event']),
3033 core.HostListener('keydown.shift.tab', ['$event']),
3034 core.HostListener('keydown.meta.tab', ['$event'])
3035 ], EditableColumn.prototype, "onShiftKeyDown", null);
3036 EditableColumn = __decorate([
3037 core.Directive({
3038 selector: '[pEditableColumn]'
3039 })
3040 ], EditableColumn);
3041 return EditableColumn;
3042 }());
3043 var EditableRow = /** @class */ (function () {
3044 function EditableRow(el) {
3045 this.el = el;
3046 }
3047 EditableRow.prototype.isEnabled = function () {
3048 return this.pEditableRowDisabled !== true;
3049 };
3050 EditableRow.ctorParameters = function () { return [
3051 { type: core.ElementRef }
3052 ]; };
3053 __decorate([
3054 core.Input("pEditableRow")
3055 ], EditableRow.prototype, "data", void 0);
3056 __decorate([
3057 core.Input()
3058 ], EditableRow.prototype, "pEditableRowDisabled", void 0);
3059 EditableRow = __decorate([
3060 core.Directive({
3061 selector: '[pEditableRow]'
3062 })
3063 ], EditableRow);
3064 return EditableRow;
3065 }());
3066 var InitEditableRow = /** @class */ (function () {
3067 function InitEditableRow(dt, editableRow) {
3068 this.dt = dt;
3069 this.editableRow = editableRow;
3070 }
3071 InitEditableRow.prototype.onClick = function (event) {
3072 this.dt.initRowEdit(this.editableRow.data);
3073 event.preventDefault();
3074 };
3075 InitEditableRow.ctorParameters = function () { return [
3076 { type: Table },
3077 { type: EditableRow }
3078 ]; };
3079 __decorate([
3080 core.HostListener('click', ['$event'])
3081 ], InitEditableRow.prototype, "onClick", null);
3082 InitEditableRow = __decorate([
3083 core.Directive({
3084 selector: '[pInitEditableRow]'
3085 })
3086 ], InitEditableRow);
3087 return InitEditableRow;
3088 }());
3089 var SaveEditableRow = /** @class */ (function () {
3090 function SaveEditableRow(dt, editableRow) {
3091 this.dt = dt;
3092 this.editableRow = editableRow;
3093 }
3094 SaveEditableRow.prototype.onClick = function (event) {
3095 this.dt.saveRowEdit(this.editableRow.data, this.editableRow.el.nativeElement);
3096 event.preventDefault();
3097 };
3098 SaveEditableRow.ctorParameters = function () { return [
3099 { type: Table },
3100 { type: EditableRow }
3101 ]; };
3102 __decorate([
3103 core.HostListener('click', ['$event'])
3104 ], SaveEditableRow.prototype, "onClick", null);
3105 SaveEditableRow = __decorate([
3106 core.Directive({
3107 selector: '[pSaveEditableRow]'
3108 })
3109 ], SaveEditableRow);
3110 return SaveEditableRow;
3111 }());
3112 var CancelEditableRow = /** @class */ (function () {
3113 function CancelEditableRow(dt, editableRow) {
3114 this.dt = dt;
3115 this.editableRow = editableRow;
3116 }
3117 CancelEditableRow.prototype.onClick = function (event) {
3118 this.dt.cancelRowEdit(this.editableRow.data);
3119 event.preventDefault();
3120 };
3121 CancelEditableRow.ctorParameters = function () { return [
3122 { type: Table },
3123 { type: EditableRow }
3124 ]; };
3125 __decorate([
3126 core.HostListener('click', ['$event'])
3127 ], CancelEditableRow.prototype, "onClick", null);
3128 CancelEditableRow = __decorate([
3129 core.Directive({
3130 selector: '[pCancelEditableRow]'
3131 })
3132 ], CancelEditableRow);
3133 return CancelEditableRow;
3134 }());
3135 var CellEditor = /** @class */ (function () {
3136 function CellEditor(dt, editableColumn, editableRow) {
3137 this.dt = dt;
3138 this.editableColumn = editableColumn;
3139 this.editableRow = editableRow;
3140 }
3141 CellEditor.prototype.ngAfterContentInit = function () {
3142 var _this = this;
3143 this.templates.forEach(function (item) {
3144 switch (item.getType()) {
3145 case 'input':
3146 _this.inputTemplate = item.template;
3147 break;
3148 case 'output':
3149 _this.outputTemplate = item.template;
3150 break;
3151 }
3152 });
3153 };
3154 Object.defineProperty(CellEditor.prototype, "editing", {
3155 get: function () {
3156 return (this.dt.editingCell && this.editableColumn && this.dt.editingCell === this.editableColumn.el.nativeElement) ||
3157 (this.editableRow && this.dt.editMode === 'row' && this.dt.isRowEditing(this.editableRow.data));
3158 },
3159 enumerable: true,
3160 configurable: true
3161 });
3162 CellEditor.ctorParameters = function () { return [
3163 { type: Table },
3164 { type: EditableColumn, decorators: [{ type: core.Optional }] },
3165 { type: EditableRow, decorators: [{ type: core.Optional }] }
3166 ]; };
3167 __decorate([
3168 core.ContentChildren(api.PrimeTemplate)
3169 ], CellEditor.prototype, "templates", void 0);
3170 CellEditor = __decorate([
3171 core.Component({
3172 selector: 'p-cellEditor',
3173 template: "\n <ng-container *ngIf=\"editing\">\n <ng-container *ngTemplateOutlet=\"inputTemplate\"></ng-container>\n </ng-container>\n <ng-container *ngIf=\"!editing\">\n <ng-container *ngTemplateOutlet=\"outputTemplate\"></ng-container>\n </ng-container>\n "
3174 }),
3175 __param(1, core.Optional()), __param(2, core.Optional())
3176 ], CellEditor);
3177 return CellEditor;
3178 }());
3179 var TableRadioButton = /** @class */ (function () {
3180 function TableRadioButton(dt, tableService) {
3181 var _this = this;
3182 this.dt = dt;
3183 this.tableService = tableService;
3184 this.subscription = this.dt.tableService.selectionSource$.subscribe(function () {
3185 _this.checked = _this.dt.isSelected(_this.value);
3186 });
3187 }
3188 TableRadioButton.prototype.ngOnInit = function () {
3189 this.checked = this.dt.isSelected(this.value);
3190 };
3191 TableRadioButton.prototype.onClick = function (event) {
3192 if (!this.disabled) {
3193 this.dt.toggleRowWithRadio({
3194 originalEvent: event,
3195 rowIndex: this.index
3196 }, this.value);
3197 }
3198 dom.DomHandler.clearSelection();
3199 };
3200 TableRadioButton.prototype.onFocus = function () {
3201 dom.DomHandler.addClass(this.boxViewChild.nativeElement, 'ui-state-focus');
3202 };
3203 TableRadioButton.prototype.onBlur = function () {
3204 dom.DomHandler.removeClass(this.boxViewChild.nativeElement, 'ui-state-focus');
3205 };
3206 TableRadioButton.prototype.ngOnDestroy = function () {
3207 if (this.subscription) {
3208 this.subscription.unsubscribe();
3209 }
3210 };
3211 TableRadioButton.ctorParameters = function () { return [
3212 { type: Table },
3213 { type: TableService }
3214 ]; };
3215 __decorate([
3216 core.Input()
3217 ], TableRadioButton.prototype, "disabled", void 0);
3218 __decorate([
3219 core.Input()
3220 ], TableRadioButton.prototype, "value", void 0);
3221 __decorate([
3222 core.Input()
3223 ], TableRadioButton.prototype, "index", void 0);
3224 __decorate([
3225 core.Input()
3226 ], TableRadioButton.prototype, "inputId", void 0);
3227 __decorate([
3228 core.Input()
3229 ], TableRadioButton.prototype, "name", void 0);
3230 __decorate([
3231 core.Input()
3232 ], TableRadioButton.prototype, "ariaLabel", void 0);
3233 __decorate([
3234 core.ViewChild('box')
3235 ], TableRadioButton.prototype, "boxViewChild", void 0);
3236 TableRadioButton = __decorate([
3237 core.Component({
3238 selector: 'p-tableRadioButton',
3239 template: "\n <div class=\"ui-radiobutton ui-widget\" (click)=\"onClick($event)\">\n <div class=\"ui-helper-hidden-accessible\">\n <input type=\"radio\" [attr.id]=\"inputId\" [attr.name]=\"name\" [checked]=\"checked\" (focus)=\"onFocus()\" (blur)=\"onBlur()\"\n [disabled]=\"disabled\" [attr.aria-label]=\"ariaLabel\">\n </div>\n <div #box [ngClass]=\"{'ui-radiobutton-box ui-widget ui-state-default':true,\n 'ui-state-active':checked, 'ui-state-disabled':disabled}\" role=\"radio\" [attr.aria-checked]=\"checked\">\n <span class=\"ui-radiobutton-icon ui-clickable\" [ngClass]=\"{'pi pi-circle-on':checked}\"></span>\n </div>\n </div>\n "
3240 })
3241 ], TableRadioButton);
3242 return TableRadioButton;
3243 }());
3244 var TableCheckbox = /** @class */ (function () {
3245 function TableCheckbox(dt, tableService) {
3246 var _this = this;
3247 this.dt = dt;
3248 this.tableService = tableService;
3249 this.subscription = this.dt.tableService.selectionSource$.subscribe(function () {
3250 _this.checked = _this.dt.isSelected(_this.value);
3251 });
3252 }
3253 TableCheckbox.prototype.ngOnInit = function () {
3254 this.checked = this.dt.isSelected(this.value);
3255 };
3256 TableCheckbox.prototype.onClick = function (event) {
3257 if (!this.disabled) {
3258 this.dt.toggleRowWithCheckbox({
3259 originalEvent: event,
3260 rowIndex: this.index
3261 }, this.value);
3262 }
3263 dom.DomHandler.clearSelection();
3264 };
3265 TableCheckbox.prototype.onFocus = function () {
3266 dom.DomHandler.addClass(this.boxViewChild.nativeElement, 'ui-state-focus');
3267 };
3268 TableCheckbox.prototype.onBlur = function () {
3269 dom.DomHandler.removeClass(this.boxViewChild.nativeElement, 'ui-state-focus');
3270 };
3271 TableCheckbox.prototype.ngOnDestroy = function () {
3272 if (this.subscription) {
3273 this.subscription.unsubscribe();
3274 }
3275 };
3276 TableCheckbox.ctorParameters = function () { return [
3277 { type: Table },
3278 { type: TableService }
3279 ]; };
3280 __decorate([
3281 core.Input()
3282 ], TableCheckbox.prototype, "disabled", void 0);
3283 __decorate([
3284 core.Input()
3285 ], TableCheckbox.prototype, "value", void 0);
3286 __decorate([
3287 core.Input()
3288 ], TableCheckbox.prototype, "index", void 0);
3289 __decorate([
3290 core.Input()
3291 ], TableCheckbox.prototype, "inputId", void 0);
3292 __decorate([
3293 core.Input()
3294 ], TableCheckbox.prototype, "name", void 0);
3295 __decorate([
3296 core.Input()
3297 ], TableCheckbox.prototype, "required", void 0);
3298 __decorate([
3299 core.Input()
3300 ], TableCheckbox.prototype, "ariaLabel", void 0);
3301 __decorate([
3302 core.ViewChild('box')
3303 ], TableCheckbox.prototype, "boxViewChild", void 0);
3304 TableCheckbox = __decorate([
3305 core.Component({
3306 selector: 'p-tableCheckbox',
3307 template: "\n <div class=\"ui-chkbox ui-widget\" (click)=\"onClick($event)\">\n <div class=\"ui-helper-hidden-accessible\">\n <input type=\"checkbox\" [attr.id]=\"inputId\" [attr.name]=\"name\" [checked]=\"checked\" (focus)=\"onFocus()\" (blur)=\"onBlur()\" [disabled]=\"disabled\"\n [attr.required]=\"required\" [attr.aria-label]=\"ariaLabel\">\n </div>\n <div #box [ngClass]=\"{'ui-chkbox-box ui-widget ui-state-default':true,\n 'ui-state-active':checked, 'ui-state-disabled':disabled}\" role=\"checkbox\" [attr.aria-checked]=\"checked\">\n <span class=\"ui-chkbox-icon ui-clickable\" [ngClass]=\"{'pi pi-check':checked}\"></span>\n </div>\n </div>\n "
3308 })
3309 ], TableCheckbox);
3310 return TableCheckbox;
3311 }());
3312 var TableHeaderCheckbox = /** @class */ (function () {
3313 function TableHeaderCheckbox(dt, tableService) {
3314 var _this = this;
3315 this.dt = dt;
3316 this.tableService = tableService;
3317 this.valueChangeSubscription = this.dt.tableService.valueSource$.subscribe(function () {
3318 _this.checked = _this.updateCheckedState();
3319 });
3320 this.selectionChangeSubscription = this.dt.tableService.selectionSource$.subscribe(function () {
3321 _this.checked = _this.updateCheckedState();
3322 });
3323 }
3324 TableHeaderCheckbox.prototype.ngOnInit = function () {
3325 this.checked = this.updateCheckedState();
3326 };
3327 TableHeaderCheckbox.prototype.onClick = function (event) {
3328 if (!this.disabled) {
3329 if (this.dt.value && this.dt.value.length > 0) {
3330 this.dt.toggleRowsWithCheckbox(event, !this.checked);
3331 }
3332 }
3333 dom.DomHandler.clearSelection();
3334 };
3335 TableHeaderCheckbox.prototype.onFocus = function () {
3336 dom.DomHandler.addClass(this.boxViewChild.nativeElement, 'ui-state-focus');
3337 };
3338 TableHeaderCheckbox.prototype.onBlur = function () {
3339 dom.DomHandler.removeClass(this.boxViewChild.nativeElement, 'ui-state-focus');
3340 };
3341 TableHeaderCheckbox.prototype.isDisabled = function () {
3342 return this.disabled || !this.dt.value || !this.dt.value.length;
3343 };
3344 TableHeaderCheckbox.prototype.ngOnDestroy = function () {
3345 if (this.selectionChangeSubscription) {
3346 this.selectionChangeSubscription.unsubscribe();
3347 }
3348 if (this.valueChangeSubscription) {
3349 this.valueChangeSubscription.unsubscribe();
3350 }
3351 };
3352 TableHeaderCheckbox.prototype.updateCheckedState = function () {
3353 if (this.dt.filteredValue) {
3354 var val = this.dt.filteredValue;
3355 return (val && val.length > 0 && this.dt.selection && this.dt.selection.length > 0 && this.isAllFilteredValuesChecked());
3356 }
3357 else {
3358 var val = this.dt.value;
3359 return (val && val.length > 0 && this.dt.selection && this.dt.selection.length > 0 && this.dt.selection.length === val.length);
3360 }
3361 };
3362 TableHeaderCheckbox.prototype.isAllFilteredValuesChecked = function () {
3363 var e_3, _a;
3364 if (!this.dt.filteredValue) {
3365 return false;
3366 }
3367 else {
3368 try {
3369 for (var _b = __values(this.dt.filteredValue), _c = _b.next(); !_c.done; _c = _b.next()) {
3370 var rowData = _c.value;
3371 if (!this.dt.isSelected(rowData)) {
3372 return false;
3373 }
3374 }
3375 }
3376 catch (e_3_1) { e_3 = { error: e_3_1 }; }
3377 finally {
3378 try {
3379 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3380 }
3381 finally { if (e_3) throw e_3.error; }
3382 }
3383 return true;
3384 }
3385 };
3386 TableHeaderCheckbox.ctorParameters = function () { return [
3387 { type: Table },
3388 { type: TableService }
3389 ]; };
3390 __decorate([
3391 core.ViewChild('box')
3392 ], TableHeaderCheckbox.prototype, "boxViewChild", void 0);
3393 __decorate([
3394 core.Input()
3395 ], TableHeaderCheckbox.prototype, "disabled", void 0);
3396 __decorate([
3397 core.Input()
3398 ], TableHeaderCheckbox.prototype, "inputId", void 0);
3399 __decorate([
3400 core.Input()
3401 ], TableHeaderCheckbox.prototype, "name", void 0);
3402 __decorate([
3403 core.Input()
3404 ], TableHeaderCheckbox.prototype, "ariaLabel", void 0);
3405 TableHeaderCheckbox = __decorate([
3406 core.Component({
3407 selector: 'p-tableHeaderCheckbox',
3408 template: "\n <div class=\"ui-chkbox ui-widget\" (click)=\"onClick($event)\">\n <div class=\"ui-helper-hidden-accessible\">\n <input #cb type=\"checkbox\" [attr.id]=\"inputId\" [attr.name]=\"name\" [checked]=\"checked\" (focus)=\"onFocus()\" (blur)=\"onBlur()\"\n [disabled]=\"isDisabled()\" [attr.aria-label]=\"ariaLabel\">\n </div>\n <div #box [ngClass]=\"{'ui-chkbox-box ui-widget ui-state-default':true,\n 'ui-state-active':checked, 'ui-state-disabled': isDisabled()}\" role=\"checkbox\" [attr.aria-checked]=\"checked\">\n <span class=\"ui-chkbox-icon ui-clickable\" [ngClass]=\"{'pi pi-check':checked}\"></span>\n </div>\n </div>\n "
3409 })
3410 ], TableHeaderCheckbox);
3411 return TableHeaderCheckbox;
3412 }());
3413 var ReorderableRowHandle = /** @class */ (function () {
3414 function ReorderableRowHandle(el) {
3415 this.el = el;
3416 }
3417 ReorderableRowHandle.prototype.ngAfterViewInit = function () {
3418 dom.DomHandler.addClass(this.el.nativeElement, 'ui-table-reorderablerow-handle');
3419 };
3420 ReorderableRowHandle.ctorParameters = function () { return [
3421 { type: core.ElementRef }
3422 ]; };
3423 __decorate([
3424 core.Input("pReorderableRowHandle")
3425 ], ReorderableRowHandle.prototype, "index", void 0);
3426 ReorderableRowHandle = __decorate([
3427 core.Directive({
3428 selector: '[pReorderableRowHandle]'
3429 })
3430 ], ReorderableRowHandle);
3431 return ReorderableRowHandle;
3432 }());
3433 var ReorderableRow = /** @class */ (function () {
3434 function ReorderableRow(dt, el, zone) {
3435 this.dt = dt;
3436 this.el = el;
3437 this.zone = zone;
3438 }
3439 ReorderableRow.prototype.ngAfterViewInit = function () {
3440 if (this.isEnabled()) {
3441 this.el.nativeElement.droppable = true;
3442 this.bindEvents();
3443 }
3444 };
3445 ReorderableRow.prototype.bindEvents = function () {
3446 var _this = this;
3447 this.zone.runOutsideAngular(function () {
3448 _this.mouseDownListener = _this.onMouseDown.bind(_this);
3449 _this.el.nativeElement.addEventListener('mousedown', _this.mouseDownListener);
3450 _this.dragStartListener = _this.onDragStart.bind(_this);
3451 _this.el.nativeElement.addEventListener('dragstart', _this.dragStartListener);
3452 _this.dragEndListener = _this.onDragEnd.bind(_this);
3453 _this.el.nativeElement.addEventListener('dragend', _this.dragEndListener);
3454 _this.dragOverListener = _this.onDragOver.bind(_this);
3455 _this.el.nativeElement.addEventListener('dragover', _this.dragOverListener);
3456 _this.dragLeaveListener = _this.onDragLeave.bind(_this);
3457 _this.el.nativeElement.addEventListener('dragleave', _this.dragLeaveListener);
3458 });
3459 };
3460 ReorderableRow.prototype.unbindEvents = function () {
3461 if (this.mouseDownListener) {
3462 document.removeEventListener('mousedown', this.mouseDownListener);
3463 this.mouseDownListener = null;
3464 }
3465 if (this.dragStartListener) {
3466 document.removeEventListener('dragstart', this.dragStartListener);
3467 this.dragStartListener = null;
3468 }
3469 if (this.dragEndListener) {
3470 document.removeEventListener('dragend', this.dragEndListener);
3471 this.dragEndListener = null;
3472 }
3473 if (this.dragOverListener) {
3474 document.removeEventListener('dragover', this.dragOverListener);
3475 this.dragOverListener = null;
3476 }
3477 if (this.dragLeaveListener) {
3478 document.removeEventListener('dragleave', this.dragLeaveListener);
3479 this.dragLeaveListener = null;
3480 }
3481 };
3482 ReorderableRow.prototype.onMouseDown = function (event) {
3483 if (dom.DomHandler.hasClass(event.target, 'ui-table-reorderablerow-handle'))
3484 this.el.nativeElement.draggable = true;
3485 else
3486 this.el.nativeElement.draggable = false;
3487 };
3488 ReorderableRow.prototype.onDragStart = function (event) {
3489 this.dt.onRowDragStart(event, this.index);
3490 };
3491 ReorderableRow.prototype.onDragEnd = function (event) {
3492 this.dt.onRowDragEnd(event);
3493 this.el.nativeElement.draggable = false;
3494 };
3495 ReorderableRow.prototype.onDragOver = function (event) {
3496 this.dt.onRowDragOver(event, this.index, this.el.nativeElement);
3497 event.preventDefault();
3498 };
3499 ReorderableRow.prototype.onDragLeave = function (event) {
3500 this.dt.onRowDragLeave(event, this.el.nativeElement);
3501 };
3502 ReorderableRow.prototype.isEnabled = function () {
3503 return this.pReorderableRowDisabled !== true;
3504 };
3505 ReorderableRow.prototype.onDrop = function (event) {
3506 if (this.isEnabled() && this.dt.rowDragging) {
3507 this.dt.onRowDrop(event, this.el.nativeElement);
3508 }
3509 event.preventDefault();
3510 };
3511 ReorderableRow.ctorParameters = function () { return [
3512 { type: Table },
3513 { type: core.ElementRef },
3514 { type: core.NgZone }
3515 ]; };
3516 __decorate([
3517 core.Input("pReorderableRow")
3518 ], ReorderableRow.prototype, "index", void 0);
3519 __decorate([
3520 core.Input()
3521 ], ReorderableRow.prototype, "pReorderableRowDisabled", void 0);
3522 __decorate([
3523 core.HostListener('drop', ['$event'])
3524 ], ReorderableRow.prototype, "onDrop", null);
3525 ReorderableRow = __decorate([
3526 core.Directive({
3527 selector: '[pReorderableRow]'
3528 })
3529 ], ReorderableRow);
3530 return ReorderableRow;
3531 }());
3532 var TableModule = /** @class */ (function () {
3533 function TableModule() {
3534 }
3535 TableModule = __decorate([
3536 core.NgModule({
3537 imports: [common.CommonModule, paginator.PaginatorModule],
3538 exports: [Table, api.SharedModule, SortableColumn, SelectableRow, RowToggler, ContextMenuRow, ResizableColumn, ReorderableColumn, EditableColumn, CellEditor, SortIcon, TableRadioButton, TableCheckbox, TableHeaderCheckbox, ReorderableRowHandle, ReorderableRow, SelectableRowDblClick, EditableRow, InitEditableRow, SaveEditableRow, CancelEditableRow],
3539 declarations: [Table, SortableColumn, SelectableRow, RowToggler, ContextMenuRow, ResizableColumn, ReorderableColumn, EditableColumn, CellEditor, TableBody, ScrollableView, SortIcon, TableRadioButton, TableCheckbox, TableHeaderCheckbox, ReorderableRowHandle, ReorderableRow, SelectableRowDblClick, EditableRow, InitEditableRow, SaveEditableRow, CancelEditableRow]
3540 })
3541 ], TableModule);
3542 return TableModule;
3543 }());
3544
3545 exports.CancelEditableRow = CancelEditableRow;
3546 exports.CellEditor = CellEditor;
3547 exports.ContextMenuRow = ContextMenuRow;
3548 exports.EditableColumn = EditableColumn;
3549 exports.EditableRow = EditableRow;
3550 exports.InitEditableRow = InitEditableRow;
3551 exports.ReorderableColumn = ReorderableColumn;
3552 exports.ReorderableRow = ReorderableRow;
3553 exports.ReorderableRowHandle = ReorderableRowHandle;
3554 exports.ResizableColumn = ResizableColumn;
3555 exports.RowToggler = RowToggler;
3556 exports.SaveEditableRow = SaveEditableRow;
3557 exports.ScrollableView = ScrollableView;
3558 exports.SelectableRow = SelectableRow;
3559 exports.SelectableRowDblClick = SelectableRowDblClick;
3560 exports.SortIcon = SortIcon;
3561 exports.SortableColumn = SortableColumn;
3562 exports.Table = Table;
3563 exports.TableBody = TableBody;
3564 exports.TableCheckbox = TableCheckbox;
3565 exports.TableHeaderCheckbox = TableHeaderCheckbox;
3566 exports.TableModule = TableModule;
3567 exports.TableRadioButton = TableRadioButton;
3568 exports.TableService = TableService;
3569
3570 Object.defineProperty(exports, '__esModule', { value: true });
3571
3572})));
3573//# sourceMappingURL=primeng-table.umd.js.map