import * as i0 from '@angular/core'; import { Injectable, EventEmitter, Component, ViewEncapsulation, Input, Output, ViewChild, ContentChildren, Directive, HostListener, ChangeDetectionStrategy, NgModule } from '@angular/core'; import * as i3 from '@angular/common'; import { CommonModule } from '@angular/common'; import { Subject } from 'rxjs'; import { DomHandler } from 'primeng/dom'; import * as i2 from 'primeng/paginator'; import { PaginatorModule } from 'primeng/paginator'; import * as i1 from 'primeng/api'; import { PrimeTemplate, SharedModule } from 'primeng/api'; import { ObjectUtils } from 'primeng/utils'; import * as i5 from 'primeng/ripple'; import { RippleModule } from 'primeng/ripple'; import * as i4 from '@angular/cdk/scrolling'; import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling'; class TreeTableService { constructor() { this.sortSource = new Subject(); this.selectionSource = new Subject(); this.contextMenuSource = new Subject(); this.uiUpdateSource = new Subject(); this.totalRecordsSource = new Subject(); this.sortSource$ = this.sortSource.asObservable(); this.selectionSource$ = this.selectionSource.asObservable(); this.contextMenuSource$ = this.contextMenuSource.asObservable(); this.uiUpdateSource$ = this.uiUpdateSource.asObservable(); this.totalRecordsSource$ = this.totalRecordsSource.asObservable(); } onSort(sortMeta) { this.sortSource.next(sortMeta); } onSelectionChange() { this.selectionSource.next(null); } onContextMenu(node) { this.contextMenuSource.next(node); } onUIUpdate(value) { this.uiUpdateSource.next(value); } onTotalRecordsChange(value) { this.totalRecordsSource.next(value); } } TreeTableService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); TreeTableService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableService }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableService, decorators: [{ type: Injectable }] }); class TreeTable { constructor(el, zone, tableService, filterService) { this.el = el; this.zone = zone; this.tableService = tableService; this.filterService = filterService; this.lazy = false; this.lazyLoadOnInit = true; this.first = 0; this.pageLinks = 5; this.alwaysShowPaginator = true; this.paginatorPosition = 'bottom'; this.currentPageReportTemplate = '{currentPage} of {totalPages}'; this.showFirstLastIcon = true; this.showPageLinks = true; this.defaultSortOrder = 1; this.sortMode = 'single'; this.resetPageOnSort = true; this.selectionChange = new EventEmitter(); this.contextMenuSelectionChange = new EventEmitter(); this.contextMenuSelectionMode = "separate"; this.compareSelectionBy = 'deepEquals'; this.loadingIcon = 'pi pi-spinner'; this.showLoader = true; this.virtualScrollDelay = 150; this.virtualRowHeight = 28; this.columnResizeMode = 'fit'; this.rowTrackBy = (index, item) => item; this.filters = {}; this.filterDelay = 300; this.filterMode = 'lenient'; this.onFilter = new EventEmitter(); this.onNodeExpand = new EventEmitter(); this.onNodeCollapse = new EventEmitter(); this.onPage = new EventEmitter(); this.onSort = new EventEmitter(); this.onLazyLoad = new EventEmitter(); this.sortFunction = new EventEmitter(); this.onColResize = new EventEmitter(); this.onColReorder = new EventEmitter(); this.onNodeSelect = new EventEmitter(); this.onNodeUnselect = new EventEmitter(); this.onContextMenuSelect = new EventEmitter(); this.onHeaderCheckboxToggle = new EventEmitter(); this.onEditInit = new EventEmitter(); this.onEditComplete = new EventEmitter(); this.onEditCancel = new EventEmitter(); this._value = []; this._totalRecords = 0; this._sortOrder = 1; this.selectionKeys = {}; } ngOnInit() { if (this.lazy && this.lazyLoadOnInit) { this.onLazyLoad.emit(this.createLazyLoadMetadata()); } this.initialized = true; } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'caption': this.captionTemplate = item.template; break; case 'header': this.headerTemplate = item.template; break; case 'body': this.bodyTemplate = item.template; break; case 'loadingbody': this.loadingBodyTemplate = item.template; break; case 'footer': this.footerTemplate = item.template; break; case 'summary': this.summaryTemplate = item.template; break; case 'colgroup': this.colGroupTemplate = item.template; break; case 'emptymessage': this.emptyMessageTemplate = item.template; break; case 'paginatorleft': this.paginatorLeftTemplate = item.template; break; case 'paginatorright': this.paginatorRightTemplate = item.template; break; case 'paginatordropdownitem': this.paginatorDropdownItemTemplate = item.template; break; case 'frozenheader': this.frozenHeaderTemplate = item.template; break; case 'frozenbody': this.frozenBodyTemplate = item.template; break; case 'frozenfooter': this.frozenFooterTemplate = item.template; break; case 'frozencolgroup': this.frozenColGroupTemplate = item.template; break; } }); } ngOnChanges(simpleChange) { if (simpleChange.value) { this._value = simpleChange.value.currentValue; if (!this.lazy) { this.totalRecords = (this._value ? this._value.length : 0); if (this.sortMode == 'single' && this.sortField) this.sortSingle(); else if (this.sortMode == 'multiple' && this.multiSortMeta) this.sortMultiple(); else if (this.hasFilter()) //sort already filters this._filter(); } this.updateSerializedValue(); this.tableService.onUIUpdate(this.value); } if (simpleChange.sortField) { this._sortField = simpleChange.sortField.currentValue; //avoid triggering lazy load prior to lazy initialization at onInit if (!this.lazy || this.initialized) { if (this.sortMode === 'single') { this.sortSingle(); } } } if (simpleChange.sortOrder) { this._sortOrder = simpleChange.sortOrder.currentValue; //avoid triggering lazy load prior to lazy initialization at onInit if (!this.lazy || this.initialized) { if (this.sortMode === 'single') { this.sortSingle(); } } } if (simpleChange.multiSortMeta) { this._multiSortMeta = simpleChange.multiSortMeta.currentValue; if (this.sortMode === 'multiple') { this.sortMultiple(); } } if (simpleChange.selection) { this._selection = simpleChange.selection.currentValue; if (!this.preventSelectionSetterPropagation) { this.updateSelectionKeys(); this.tableService.onSelectionChange(); } this.preventSelectionSetterPropagation = false; } } get value() { return this._value; } set value(val) { this._value = val; } updateSerializedValue() { this.serializedValue = []; if (this.paginator) this.serializePageNodes(); else this.serializeNodes(null, this.filteredNodes || this.value, 0, true); } serializeNodes(parent, nodes, level, visible) { if (nodes && nodes.length) { for (let node of nodes) { node.parent = parent; const rowNode = { node: node, parent: parent, level: level, visible: visible && (parent ? parent.expanded : true) }; this.serializedValue.push(rowNode); if (rowNode.visible && node.expanded) { this.serializeNodes(node, node.children, level + 1, rowNode.visible); } } } } serializePageNodes() { let data = this.filteredNodes || this.value; this.serializedValue = []; if (data && data.length) { const first = this.lazy ? 0 : this.first; for (let i = first; i < (first + this.rows); i++) { let node = data[i]; if (node) { this.serializedValue.push({ node: node, parent: null, level: 0, visible: true }); this.serializeNodes(node, node.children, 1, true); } } } } get totalRecords() { return this._totalRecords; } set totalRecords(val) { this._totalRecords = val; this.tableService.onTotalRecordsChange(this._totalRecords); } get sortField() { return this._sortField; } set sortField(val) { this._sortField = val; } get sortOrder() { return this._sortOrder; } set sortOrder(val) { this._sortOrder = val; } get multiSortMeta() { return this._multiSortMeta; } set multiSortMeta(val) { this._multiSortMeta = val; } get selection() { return this._selection; } set selection(val) { this._selection = val; } updateSelectionKeys() { if (this.dataKey && this._selection) { this.selectionKeys = {}; if (Array.isArray(this._selection)) { for (let node of this._selection) { this.selectionKeys[String(ObjectUtils.resolveFieldData(node.data, this.dataKey))] = 1; } } else { this.selectionKeys[String(ObjectUtils.resolveFieldData(this._selection.data, this.dataKey))] = 1; } } } onPageChange(event) { this.first = event.first; this.rows = event.rows; if (this.lazy) this.onLazyLoad.emit(this.createLazyLoadMetadata()); else this.serializePageNodes(); this.onPage.emit({ first: this.first, rows: this.rows }); this.tableService.onUIUpdate(this.value); if (this.scrollable) { this.resetScrollTop(); } } sort(event) { let originalEvent = event.originalEvent; if (this.sortMode === 'single') { this._sortOrder = (this.sortField === event.field) ? this.sortOrder * -1 : this.defaultSortOrder; this._sortField = event.field; this.sortSingle(); if (this.resetPageOnSort && this.scrollable) { this.resetScrollTop(); } } if (this.sortMode === 'multiple') { let metaKey = originalEvent.metaKey || originalEvent.ctrlKey; let sortMeta = this.getSortMeta(event.field); if (sortMeta) { if (!metaKey) { this._multiSortMeta = [{ field: event.field, order: sortMeta.order * -1 }]; if (this.resetPageOnSort && this.scrollable) { this.resetScrollTop(); } } else { sortMeta.order = sortMeta.order * -1; } } else { if (!metaKey || !this.multiSortMeta) { this._multiSortMeta = []; if (this.resetPageOnSort && this.scrollable) { this.resetScrollTop(); } } this.multiSortMeta.push({ field: event.field, order: this.defaultSortOrder }); } this.sortMultiple(); } } sortSingle() { if (this.sortField && this.sortOrder) { if (this.lazy) { this.onLazyLoad.emit(this.createLazyLoadMetadata()); } else if (this.value) { this.sortNodes(this.value); if (this.hasFilter()) { this._filter(); } } let sortMeta = { field: this.sortField, order: this.sortOrder }; this.onSort.emit(sortMeta); this.tableService.onSort(sortMeta); this.updateSerializedValue(); } } sortNodes(nodes) { if (!nodes || nodes.length === 0) { return; } if (this.customSort) { this.sortFunction.emit({ data: nodes, mode: this.sortMode, field: this.sortField, order: this.sortOrder }); } else { nodes.sort((node1, node2) => { let value1 = ObjectUtils.resolveFieldData(node1.data, this.sortField); let value2 = ObjectUtils.resolveFieldData(node2.data, this.sortField); let result = null; if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true }); else result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0; return (this.sortOrder * result); }); } for (let node of nodes) { this.sortNodes(node.children); } } sortMultiple() { if (this.multiSortMeta) { if (this.lazy) { this.onLazyLoad.emit(this.createLazyLoadMetadata()); } else if (this.value) { this.sortMultipleNodes(this.value); if (this.hasFilter()) { this._filter(); } } this.onSort.emit({ multisortmeta: this.multiSortMeta }); this.updateSerializedValue(); this.tableService.onSort(this.multiSortMeta); } } sortMultipleNodes(nodes) { if (!nodes || nodes.length === 0) { return; } if (this.customSort) { this.sortFunction.emit({ data: this.value, mode: this.sortMode, multiSortMeta: this.multiSortMeta }); } else { nodes.sort((node1, node2) => { return this.multisortField(node1, node2, this.multiSortMeta, 0); }); } for (let node of nodes) { this.sortMultipleNodes(node.children); } } multisortField(node1, node2, multiSortMeta, index) { let value1 = ObjectUtils.resolveFieldData(node1.data, multiSortMeta[index].field); let value2 = ObjectUtils.resolveFieldData(node2.data, multiSortMeta[index].field); let result = null; if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; if (typeof value1 == 'string' || value1 instanceof String) { if (value1.localeCompare && (value1 != value2)) { return (multiSortMeta[index].order * value1.localeCompare(value2, undefined, { numeric: true })); } } else { result = (value1 < value2) ? -1 : 1; } if (value1 == value2) { return (multiSortMeta.length - 1) > (index) ? (this.multisortField(node1, node2, multiSortMeta, index + 1)) : 0; } return (multiSortMeta[index].order * result); } getSortMeta(field) { if (this.multiSortMeta && this.multiSortMeta.length) { for (let i = 0; i < this.multiSortMeta.length; i++) { if (this.multiSortMeta[i].field === field) { return this.multiSortMeta[i]; } } } return null; } isSorted(field) { if (this.sortMode === 'single') { return (this.sortField && this.sortField === field); } else if (this.sortMode === 'multiple') { let sorted = false; if (this.multiSortMeta) { for (let i = 0; i < this.multiSortMeta.length; i++) { if (this.multiSortMeta[i].field == field) { sorted = true; break; } } } return sorted; } } createLazyLoadMetadata() { return { first: this.first, rows: this.rows, sortField: this.sortField, sortOrder: this.sortOrder, filters: this.filters, globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null, multiSortMeta: this.multiSortMeta }; } resetScrollTop() { if (this.virtualScroll) this.scrollToVirtualIndex(0); else this.scrollTo({ top: 0 }); } scrollToVirtualIndex(index) { if (this.scrollableViewChild) { this.scrollableViewChild.scrollToVirtualIndex(index); } if (this.scrollableFrozenViewChild) { this.scrollableFrozenViewChild.scrollToVirtualIndex(index); } } scrollTo(options) { if (this.scrollableViewChild) { this.scrollableViewChild.scrollTo(options); } if (this.scrollableFrozenViewChild) { this.scrollableFrozenViewChild.scrollTo(options); } } isEmpty() { let data = this.filteredNodes || this.value; return data == null || data.length == 0; } getBlockableElement() { return this.el.nativeElement.children[0]; } onColumnResizeBegin(event) { let containerLeft = DomHandler.getOffset(this.containerViewChild.nativeElement).left; this.lastResizerHelperX = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft); event.preventDefault(); } onColumnResize(event) { let containerLeft = DomHandler.getOffset(this.containerViewChild.nativeElement).left; DomHandler.addClass(this.containerViewChild.nativeElement, 'p-unselectable-text'); this.resizeHelperViewChild.nativeElement.style.height = this.containerViewChild.nativeElement.offsetHeight + 'px'; this.resizeHelperViewChild.nativeElement.style.top = 0 + 'px'; this.resizeHelperViewChild.nativeElement.style.left = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft) + 'px'; this.resizeHelperViewChild.nativeElement.style.display = 'block'; } onColumnResizeEnd(event, column) { let delta = this.resizeHelperViewChild.nativeElement.offsetLeft - this.lastResizerHelperX; let columnWidth = column.offsetWidth; let newColumnWidth = columnWidth + delta; let minWidth = column.style.minWidth || 15; if (columnWidth + delta > parseInt(minWidth)) { if (this.columnResizeMode === 'fit') { let nextColumn = column.nextElementSibling; while (!nextColumn.offsetParent) { nextColumn = nextColumn.nextElementSibling; } if (nextColumn) { let nextColumnWidth = nextColumn.offsetWidth - delta; let nextColumnMinWidth = nextColumn.style.minWidth || 15; if (newColumnWidth > 15 && nextColumnWidth > parseInt(nextColumnMinWidth)) { if (this.scrollable) { let scrollableView = this.findParentScrollableView(column); let scrollableBodyTable = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-body table') || DomHandler.findSingle(scrollableView, '.p-treetable-virtual-scrollable-body table'); let scrollableHeaderTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-header-table'); let scrollableFooterTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-footer-table'); let resizeColumnIndex = DomHandler.index(column); this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, nextColumnWidth); this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, nextColumnWidth); this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, nextColumnWidth); } else { column.style.width = newColumnWidth + 'px'; if (nextColumn) { nextColumn.style.width = nextColumnWidth + 'px'; } } } } } else if (this.columnResizeMode === 'expand') { if (this.scrollable) { let scrollableView = this.findParentScrollableView(column); let scrollableBody = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-body') || DomHandler.findSingle(scrollableView, 'cdk-virtual-scroll-viewport'); let scrollableHeader = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-header'); let scrollableFooter = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-footer'); let scrollableBodyTable = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-body table') || DomHandler.findSingle(scrollableView, 'cdk-virtual-scroll-viewport table'); let scrollableHeaderTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-header-table'); let scrollableFooterTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-footer-table'); scrollableBodyTable.style.width = scrollableBodyTable.offsetWidth + delta + 'px'; scrollableHeaderTable.style.width = scrollableHeaderTable.offsetWidth + delta + 'px'; if (scrollableFooterTable) { scrollableFooterTable.style.width = scrollableFooterTable.offsetWidth + delta + 'px'; } let resizeColumnIndex = DomHandler.index(column); const scrollableBodyTableWidth = column ? scrollableBodyTable.offsetWidth + delta : newColumnWidth; const scrollableHeaderTableWidth = column ? scrollableHeaderTable.offsetWidth + delta : newColumnWidth; const isContainerInViewport = this.containerViewChild.nativeElement.offsetWidth >= scrollableBodyTableWidth; let setWidth = (container, table, width, isContainerInViewport) => { if (container && table) { container.style.width = isContainerInViewport ? width + DomHandler.calculateScrollbarWidth(scrollableBody) + 'px' : 'auto'; table.style.width = width + 'px'; } }; setWidth(scrollableBody, scrollableBodyTable, scrollableBodyTableWidth, isContainerInViewport); setWidth(scrollableHeader, scrollableHeaderTable, scrollableHeaderTableWidth, isContainerInViewport); setWidth(scrollableFooter, scrollableFooterTable, scrollableHeaderTableWidth, isContainerInViewport); this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, null); this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, null); this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, null); } else { this.tableViewChild.nativeElement.style.width = this.tableViewChild.nativeElement.offsetWidth + delta + 'px'; column.style.width = newColumnWidth + 'px'; let containerWidth = this.tableViewChild.nativeElement.style.width; this.containerViewChild.nativeElement.style.width = containerWidth + 'px'; } } this.onColResize.emit({ element: column, delta: delta }); } this.resizeHelperViewChild.nativeElement.style.display = 'none'; DomHandler.removeClass(this.containerViewChild.nativeElement, 'p-unselectable-text'); } findParentScrollableView(column) { if (column) { let parent = column.parentElement; while (parent && !DomHandler.hasClass(parent, 'p-treetable-scrollable-view')) { parent = parent.parentElement; } return parent; } else { return null; } } resizeColGroup(table, resizeColumnIndex, newColumnWidth, nextColumnWidth) { if (table) { let colGroup = table.children[0].nodeName === 'COLGROUP' ? table.children[0] : null; if (colGroup) { let col = colGroup.children[resizeColumnIndex]; let nextCol = col.nextElementSibling; col.style.width = newColumnWidth + 'px'; if (nextCol && nextColumnWidth) { nextCol.style.width = nextColumnWidth + 'px'; } } else { throw "Scrollable tables require a colgroup to support resizable columns"; } } } onColumnDragStart(event, columnElement) { this.reorderIconWidth = DomHandler.getHiddenElementOuterWidth(this.reorderIndicatorUpViewChild.nativeElement); this.reorderIconHeight = DomHandler.getHiddenElementOuterHeight(this.reorderIndicatorDownViewChild.nativeElement); this.draggedColumn = columnElement; event.dataTransfer.setData('text', 'b'); // For firefox } onColumnDragEnter(event, dropHeader) { if (this.reorderableColumns && this.draggedColumn && dropHeader) { event.preventDefault(); let containerOffset = DomHandler.getOffset(this.containerViewChild.nativeElement); let dropHeaderOffset = DomHandler.getOffset(dropHeader); if (this.draggedColumn != dropHeader) { let targetLeft = dropHeaderOffset.left - containerOffset.left; let targetTop = containerOffset.top - dropHeaderOffset.top; let columnCenter = dropHeaderOffset.left + dropHeader.offsetWidth / 2; this.reorderIndicatorUpViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top - (this.reorderIconHeight - 1) + 'px'; this.reorderIndicatorDownViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top + dropHeader.offsetHeight + 'px'; if (event.pageX > columnCenter) { this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px'; this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px'; this.dropPosition = 1; } else { this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px'; this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px'; this.dropPosition = -1; } this.reorderIndicatorUpViewChild.nativeElement.style.display = 'block'; this.reorderIndicatorDownViewChild.nativeElement.style.display = 'block'; } else { event.dataTransfer.dropEffect = 'none'; } } } onColumnDragLeave(event) { if (this.reorderableColumns && this.draggedColumn) { event.preventDefault(); this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none'; this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none'; } } onColumnDrop(event, dropColumn) { event.preventDefault(); if (this.draggedColumn) { let dragIndex = DomHandler.indexWithinGroup(this.draggedColumn, 'ttreorderablecolumn'); let dropIndex = DomHandler.indexWithinGroup(dropColumn, 'ttreorderablecolumn'); let allowDrop = (dragIndex != dropIndex); if (allowDrop && ((dropIndex - dragIndex == 1 && this.dropPosition === -1) || (dragIndex - dropIndex == 1 && this.dropPosition === 1))) { allowDrop = false; } if (allowDrop && ((dropIndex < dragIndex && this.dropPosition === 1))) { dropIndex = dropIndex + 1; } if (allowDrop && ((dropIndex > dragIndex && this.dropPosition === -1))) { dropIndex = dropIndex - 1; } if (allowDrop) { ObjectUtils.reorderArray(this.columns, dragIndex, dropIndex); this.onColReorder.emit({ dragIndex: dragIndex, dropIndex: dropIndex, columns: this.columns }); } this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none'; this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none'; this.draggedColumn.draggable = false; this.draggedColumn = null; this.dropPosition = null; } } handleRowClick(event) { let targetNode = event.originalEvent.target.nodeName; if (targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A' || (DomHandler.hasClass(event.originalEvent.target, 'p-clickable'))) { return; } if (this.selectionMode) { this.preventSelectionSetterPropagation = true; let rowNode = event.rowNode; let selected = this.isSelected(rowNode.node); let metaSelection = this.rowTouched ? false : this.metaKeySelection; let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(rowNode.node.data, this.dataKey)) : null; if (metaSelection) { let metaKey = event.originalEvent.metaKey || event.originalEvent.ctrlKey; if (selected && metaKey) { if (this.isSingleSelectionMode()) { this._selection = null; this.selectionKeys = {}; this.selectionChange.emit(null); } else { let selectionIndex = this.findIndexInSelection(rowNode.node); this._selection = this.selection.filter((val, i) => i != selectionIndex); this.selectionChange.emit(this.selection); if (dataKeyValue) { delete this.selectionKeys[dataKeyValue]; } } this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' }); } else { if (this.isSingleSelectionMode()) { this._selection = rowNode.node; this.selectionChange.emit(rowNode.node); if (dataKeyValue) { this.selectionKeys = {}; this.selectionKeys[dataKeyValue] = 1; } } else if (this.isMultipleSelectionMode()) { if (metaKey) { this._selection = this.selection || []; } else { this._selection = []; this.selectionKeys = {}; } this._selection = [...this.selection, rowNode.node]; this.selectionChange.emit(this.selection); if (dataKeyValue) { this.selectionKeys[dataKeyValue] = 1; } } this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex }); } } else { if (this.selectionMode === 'single') { if (selected) { this._selection = null; this.selectionKeys = {}; this.selectionChange.emit(this.selection); this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' }); } else { this._selection = rowNode.node; this.selectionChange.emit(this.selection); this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex }); if (dataKeyValue) { this.selectionKeys = {}; this.selectionKeys[dataKeyValue] = 1; } } } else if (this.selectionMode === 'multiple') { if (selected) { let selectionIndex = this.findIndexInSelection(rowNode.node); this._selection = this.selection.filter((val, i) => i != selectionIndex); this.selectionChange.emit(this.selection); this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' }); if (dataKeyValue) { delete this.selectionKeys[dataKeyValue]; } } else { this._selection = this.selection ? [...this.selection, rowNode.node] : [rowNode.node]; this.selectionChange.emit(this.selection); this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex }); if (dataKeyValue) { this.selectionKeys[dataKeyValue] = 1; } } } } this.tableService.onSelectionChange(); } this.rowTouched = false; } handleRowTouchEnd(event) { this.rowTouched = true; } handleRowRightClick(event) { if (this.contextMenu) { const node = event.rowNode.node; if (this.contextMenuSelectionMode === 'separate') { this.contextMenuSelection = node; this.contextMenuSelectionChange.emit(node); this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, node: node }); this.contextMenu.show(event.originalEvent); this.tableService.onContextMenu(node); } else if (this.contextMenuSelectionMode === 'joint') { this.preventSelectionSetterPropagation = true; let selected = this.isSelected(node); let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null; if (!selected) { if (this.isSingleSelectionMode()) { this.selection = node; this.selectionChange.emit(node); } else if (this.isMultipleSelectionMode()) { this.selection = [node]; this.selectionChange.emit(this.selection); } if (dataKeyValue) { this.selectionKeys[dataKeyValue] = 1; } } this.contextMenu.show(event.originalEvent); this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, node: node }); } } } toggleNodeWithCheckbox(event) { this.selection = this.selection || []; this.preventSelectionSetterPropagation = true; let node = event.rowNode.node; let selected = this.isSelected(node); if (selected) { this.propagateSelectionDown(node, false); if (event.rowNode.parent) { this.propagateSelectionUp(node.parent, false); } this.selectionChange.emit(this.selection); this.onNodeUnselect.emit({ originalEvent: event, node: node }); } else { this.propagateSelectionDown(node, true); if (event.rowNode.parent) { this.propagateSelectionUp(node.parent, true); } this.selectionChange.emit(this.selection); this.onNodeSelect.emit({ originalEvent: event, node: node }); } this.tableService.onSelectionChange(); } toggleNodesWithCheckbox(event, check) { let data = this.filteredNodes || this.value; this._selection = check && data ? data.slice() : []; if (check) { if (data && data.length) { for (let node of data) { this.propagateSelectionDown(node, true); } } } else { this._selection = []; this.selectionKeys = {}; } this.preventSelectionSetterPropagation = true; this.selectionChange.emit(this._selection); this.tableService.onSelectionChange(); this.onHeaderCheckboxToggle.emit({ originalEvent: event, checked: check }); } propagateSelectionUp(node, select) { if (node.children && node.children.length) { let selectedChildCount = 0; let childPartialSelected = false; let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null; for (let child of node.children) { if (this.isSelected(child)) selectedChildCount++; else if (child.partialSelected) childPartialSelected = true; } if (select && selectedChildCount == node.children.length) { this._selection = [...this.selection || [], node]; node.partialSelected = false; if (dataKeyValue) { this.selectionKeys[dataKeyValue] = 1; } } else { if (!select) { let index = this.findIndexInSelection(node); if (index >= 0) { this._selection = this.selection.filter((val, i) => i != index); if (dataKeyValue) { delete this.selectionKeys[dataKeyValue]; } } } if (childPartialSelected || selectedChildCount > 0 && selectedChildCount != node.children.length) node.partialSelected = true; else node.partialSelected = false; } } let parent = node.parent; if (parent) { this.propagateSelectionUp(parent, select); } } propagateSelectionDown(node, select) { let index = this.findIndexInSelection(node); let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null; if (select && index == -1) { this._selection = [...this.selection || [], node]; if (dataKeyValue) { this.selectionKeys[dataKeyValue] = 1; } } else if (!select && index > -1) { this._selection = this.selection.filter((val, i) => i != index); if (dataKeyValue) { delete this.selectionKeys[dataKeyValue]; } } node.partialSelected = false; if (node.children && node.children.length) { for (let child of node.children) { this.propagateSelectionDown(child, select); } } } isSelected(node) { if (node && this.selection) { if (this.dataKey) { return this.selectionKeys[ObjectUtils.resolveFieldData(node.data, this.dataKey)] !== undefined; } else { if (this.selection instanceof Array) return this.findIndexInSelection(node) > -1; else return this.equals(node, this.selection); } } return false; } findIndexInSelection(node) { let index = -1; if (this.selection && this.selection.length) { for (let i = 0; i < this.selection.length; i++) { if (this.equals(node, this.selection[i])) { index = i; break; } } } return index; } isSingleSelectionMode() { return this.selectionMode === 'single'; } isMultipleSelectionMode() { return this.selectionMode === 'multiple'; } equals(node1, node2) { return this.compareSelectionBy === 'equals' ? (node1 === node2) : ObjectUtils.equals(node1.data, node2.data, this.dataKey); } filter(value, field, matchMode) { if (this.filterTimeout) { clearTimeout(this.filterTimeout); } if (!this.isFilterBlank(value)) { this.filters[field] = { value: value, matchMode: matchMode }; } else if (this.filters[field]) { delete this.filters[field]; } this.filterTimeout = setTimeout(() => { this._filter(); this.filterTimeout = null; }, this.filterDelay); } filterGlobal(value, matchMode) { this.filter(value, 'global', matchMode); } isFilterBlank(filter) { if (filter !== null && filter !== undefined) { if ((typeof filter === 'string' && filter.trim().length == 0) || (filter instanceof Array && filter.length == 0)) return true; else return false; } return true; } _filter() { if (this.lazy) { this.onLazyLoad.emit(this.createLazyLoadMetadata()); } else { if (!this.value) { return; } if (!this.hasFilter()) { this.filteredNodes = null; if (this.paginator) { this.totalRecords = this.value ? this.value.length : 0; } } else { let globalFilterFieldsArray; if (this.filters['global']) { if (!this.columns && !this.globalFilterFields) throw new Error('Global filtering requires dynamic columns or globalFilterFields to be defined.'); else globalFilterFieldsArray = this.globalFilterFields || this.columns; } this.filteredNodes = []; const isStrictMode = this.filterMode === 'strict'; let isValueChanged = false; for (let node of this.value) { let copyNode = Object.assign({}, node); let localMatch = true; let globalMatch = false; let paramsWithoutNode; for (let prop in this.filters) { if (this.filters.hasOwnProperty(prop) && prop !== 'global') { let filterMeta = this.filters[prop]; let filterField = prop; let filterValue = filterMeta.value; let filterMatchMode = filterMeta.matchMode || 'startsWith'; let filterConstraint = this.filterService.filters[filterMatchMode]; paramsWithoutNode = { filterField, filterValue, filterConstraint, isStrictMode }; if ((isStrictMode && !(this.findFilteredNodes(copyNode, paramsWithoutNode) || this.isFilterMatched(copyNode, paramsWithoutNode))) || (!isStrictMode && !(this.isFilterMatched(copyNode, paramsWithoutNode) || this.findFilteredNodes(copyNode, paramsWithoutNode)))) { localMatch = false; } if (!localMatch) { break; } } } if (this.filters['global'] && !globalMatch && globalFilterFieldsArray) { for (let j = 0; j < globalFilterFieldsArray.length; j++) { let copyNodeForGlobal = Object.assign({}, copyNode); let filterField = globalFilterFieldsArray[j].field || globalFilterFieldsArray[j]; let filterValue = this.filters['global'].value; let filterConstraint = this.filterService.filters[this.filters['global'].matchMode]; paramsWithoutNode = { filterField, filterValue, filterConstraint, isStrictMode }; if ((isStrictMode && (this.findFilteredNodes(copyNodeForGlobal, paramsWithoutNode) || this.isFilterMatched(copyNodeForGlobal, paramsWithoutNode))) || (!isStrictMode && (this.isFilterMatched(copyNodeForGlobal, paramsWithoutNode) || this.findFilteredNodes(copyNodeForGlobal, paramsWithoutNode)))) { globalMatch = true; copyNode = copyNodeForGlobal; } } } let matches = localMatch; if (this.filters['global']) { matches = localMatch && globalMatch; } if (matches) { this.filteredNodes.push(copyNode); } isValueChanged = isValueChanged || !localMatch || globalMatch || (localMatch && this.filteredNodes.length > 0) || (!globalMatch && this.filteredNodes.length === 0); } if (!isValueChanged) { this.filteredNodes = null; } if (this.paginator) { this.totalRecords = this.filteredNodes ? this.filteredNodes.length : this.value ? this.value.length : 0; } } } this.first = 0; const filteredValue = this.filteredNodes || this.value; this.onFilter.emit({ filters: this.filters, filteredValue: filteredValue }); this.tableService.onUIUpdate(filteredValue); this.updateSerializedValue(); if (this.scrollable) { this.resetScrollTop(); } } findFilteredNodes(node, paramsWithoutNode) { if (node) { let matched = false; if (node.children) { let childNodes = [...node.children]; node.children = []; for (let childNode of childNodes) { let copyChildNode = Object.assign({}, childNode); if (this.isFilterMatched(copyChildNode, paramsWithoutNode)) { matched = true; node.children.push(copyChildNode); } } } if (matched) { return true; } } } isFilterMatched(node, { filterField, filterValue, filterConstraint, isStrictMode }) { let matched = false; let dataFieldValue = ObjectUtils.resolveFieldData(node.data, filterField); if (filterConstraint(dataFieldValue, filterValue, this.filterLocale)) { matched = true; } if (!matched || (isStrictMode && !this.isNodeLeaf(node))) { matched = this.findFilteredNodes(node, { filterField, filterValue, filterConstraint, isStrictMode }) || matched; } return matched; } isNodeLeaf(node) { return node.leaf === false ? false : !(node.children && node.children.length); } hasFilter() { let empty = true; for (let prop in this.filters) { if (this.filters.hasOwnProperty(prop)) { empty = false; break; } } return !empty; } reset() { this._sortField = null; this._sortOrder = 1; this._multiSortMeta = null; this.tableService.onSort(null); this.filteredNodes = null; this.filters = {}; this.first = 0; if (this.lazy) { this.onLazyLoad.emit(this.createLazyLoadMetadata()); } else { this.totalRecords = (this._value ? this._value.length : 0); } } updateEditingCell(cell, data, field) { this.editingCell = cell; this.editingCellData = data; this.editingCellField = field; this.bindDocumentEditListener(); } isEditingCellValid() { return (this.editingCell && DomHandler.find(this.editingCell, '.ng-invalid.ng-dirty').length === 0); } bindDocumentEditListener() { if (!this.documentEditListener) { this.documentEditListener = (event) => { if (this.editingCell && !this.editingCellClick && this.isEditingCellValid()) { DomHandler.removeClass(this.editingCell, 'p-cell-editing'); this.editingCell = null; this.onEditComplete.emit({ field: this.editingCellField, data: this.editingCellData }); this.editingCellField = null; this.editingCellData = null; this.unbindDocumentEditListener(); } this.editingCellClick = false; }; document.addEventListener('click', this.documentEditListener); } } unbindDocumentEditListener() { if (this.documentEditListener) { document.removeEventListener('click', this.documentEditListener); this.documentEditListener = null; } } ngOnDestroy() { this.unbindDocumentEditListener(); this.editingCell = null; this.editingCellField = null; this.editingCellData = null; this.initialized = null; } } TreeTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTable, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: TreeTableService }, { token: i1.FilterService }], target: i0.ɵɵFactoryTarget.Component }); TreeTable.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TreeTable, selector: "p-treeTable", inputs: { columns: "columns", style: "style", styleClass: "styleClass", tableStyle: "tableStyle", tableStyleClass: "tableStyleClass", autoLayout: "autoLayout", lazy: "lazy", lazyLoadOnInit: "lazyLoadOnInit", paginator: "paginator", rows: "rows", first: "first", pageLinks: "pageLinks", rowsPerPageOptions: "rowsPerPageOptions", alwaysShowPaginator: "alwaysShowPaginator", paginatorPosition: "paginatorPosition", paginatorDropdownAppendTo: "paginatorDropdownAppendTo", currentPageReportTemplate: "currentPageReportTemplate", showCurrentPageReport: "showCurrentPageReport", showJumpToPageDropdown: "showJumpToPageDropdown", showFirstLastIcon: "showFirstLastIcon", showPageLinks: "showPageLinks", defaultSortOrder: "defaultSortOrder", sortMode: "sortMode", resetPageOnSort: "resetPageOnSort", customSort: "customSort", selectionMode: "selectionMode", contextMenuSelection: "contextMenuSelection", contextMenuSelectionMode: "contextMenuSelectionMode", dataKey: "dataKey", metaKeySelection: "metaKeySelection", compareSelectionBy: "compareSelectionBy", rowHover: "rowHover", loading: "loading", loadingIcon: "loadingIcon", showLoader: "showLoader", scrollable: "scrollable", scrollHeight: "scrollHeight", virtualScroll: "virtualScroll", virtualScrollDelay: "virtualScrollDelay", virtualRowHeight: "virtualRowHeight", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx", frozenWidth: "frozenWidth", frozenColumns: "frozenColumns", resizableColumns: "resizableColumns", columnResizeMode: "columnResizeMode", reorderableColumns: "reorderableColumns", contextMenu: "contextMenu", rowTrackBy: "rowTrackBy", filters: "filters", globalFilterFields: "globalFilterFields", filterDelay: "filterDelay", filterMode: "filterMode", filterLocale: "filterLocale", value: "value", totalRecords: "totalRecords", sortField: "sortField", sortOrder: "sortOrder", multiSortMeta: "multiSortMeta", selection: "selection" }, outputs: { selectionChange: "selectionChange", contextMenuSelectionChange: "contextMenuSelectionChange", onFilter: "onFilter", onNodeExpand: "onNodeExpand", onNodeCollapse: "onNodeCollapse", onPage: "onPage", onSort: "onSort", onLazyLoad: "onLazyLoad", sortFunction: "sortFunction", onColResize: "onColResize", onColReorder: "onColReorder", onNodeSelect: "onNodeSelect", onNodeUnselect: "onNodeUnselect", onContextMenuSelect: "onContextMenuSelect", onHeaderCheckboxToggle: "onHeaderCheckboxToggle", onEditInit: "onEditInit", onEditComplete: "onEditComplete", onEditCancel: "onEditCancel" }, host: { classAttribute: "p-element" }, providers: [TreeTableService], queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "containerViewChild", first: true, predicate: ["container"], descendants: true }, { propertyName: "resizeHelperViewChild", first: true, predicate: ["resizeHelper"], descendants: true }, { propertyName: "reorderIndicatorUpViewChild", first: true, predicate: ["reorderIndicatorUp"], descendants: true }, { propertyName: "reorderIndicatorDownViewChild", first: true, predicate: ["reorderIndicatorDown"], descendants: true }, { propertyName: "tableViewChild", first: true, predicate: ["table"], descendants: true }, { propertyName: "scrollableViewChild", first: true, predicate: ["scrollableView"], descendants: true }, { propertyName: "scrollableFrozenViewChild", first: true, predicate: ["scrollableFrozenView"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
`, isInline: true, styles: [".p-treetable{position:relative}.p-treetable table{border-collapse:collapse;width:100%;table-layout:fixed}.p-treetable .p-sortable-column{cursor:pointer;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-treetable .p-sortable-column .p-column-title,.p-treetable .p-sortable-column .p-sortable-column-icon,.p-treetable .p-sortable-column .p-sortable-column-badge{vertical-align:middle}.p-treetable .p-sortable-column .p-sortable-column-badge{display:inline-flex;align-items:center;justify-content:center}.p-treetable-auto-layout>.p-treetable-wrapper{overflow-x:auto}.p-treetable-auto-layout>.p-treetable-wrapper>table{table-layout:auto}.p-treetable-hoverable-rows .p-treetable-tbody>tr{cursor:pointer}.p-treetable-toggler{cursor:pointer;-webkit-user-select:none;-ms-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;overflow:hidden;position:relative}p-treetabletoggler+p-treetablecheckbox .p-checkbox,p-treetabletoggler+p-treetablecheckbox+span{vertical-align:middle}.p-treetable-scrollable-wrapper{position:relative}.p-treetable-scrollable-header,.p-treetable-scrollable-footer{overflow:hidden}.p-treetable-scrollable-body{overflow:auto;position:relative}.p-treetable-scrollable-body>table>.p-treetable-tbody>tr:first-child>td{border-top:0 none}.p-treetable-virtual-table{position:absolute}.p-treetable-frozen-view .p-treetable-scrollable-body{overflow:hidden}.p-treetable-frozen-view>.p-treetable-scrollable-body>table>.p-treetable-tbody>tr>td:last-child{border-right:0 none}.p-treetable-unfrozen-view{position:absolute;top:0}.p-treetable-flex-scrollable,.p-treetable-flex-scrollable .p-treetable-scrollable-wrapper,.p-treetable-flex-scrollable .p-treetable-scrollable-view{display:flex;flex-direction:column;flex:1;height:100%}.p-treetable-flex-scrollable .p-treetable-scrollable-body{flex:1}.p-treetable-resizable>.p-treetable-wrapper{overflow-x:auto}.p-treetable-resizable .p-treetable-thead>tr>th,.p-treetable-resizable .p-treetable-tfoot>tr>td,.p-treetable-resizable .p-treetable-tbody>tr>td{overflow:hidden}.p-treetable-resizable .p-resizable-column{background-clip:padding-box;position:relative}.p-treetable-resizable-fit .p-resizable-column:last-child .p-column-resizer{display:none}.p-treetable .p-column-resizer{display:block;position:absolute!important;top:0;right:0;margin:0;width:.5rem;height:100%;padding:0;cursor:col-resize;border:1px solid transparent}.p-treetable .p-column-resizer-helper{width:1px;position:absolute;z-index:10;display:none}.p-treetable .p-row-editor-init,.p-treetable .p-row-editor-save,.p-treetable .p-row-editor-cancel,.p-treetable .p-row-toggler{display:inline-flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-treetable-reorder-indicator-up,.p-treetable-reorder-indicator-down{position:absolute;display:none}[ttReorderableColumn]{cursor:move}.p-treetable .p-treetable-loading-overlay{position:absolute;display:flex;align-items:center;justify-content:center;z-index:2}\n"], components: [{ type: i0.forwardRef(function () { return i2.Paginator; }), selector: "p-paginator", inputs: ["pageLinkSize", "style", "styleClass", "alwaysShow", "templateLeft", "templateRight", "dropdownAppendTo", "dropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showFirstLastIcon", "totalRecords", "rows", "rowsPerPageOptions", "showJumpToPageDropdown", "showJumpToPageInput", "showPageLinks", "dropdownItemTemplate", "first"], outputs: ["onPageChange"] }, { type: i0.forwardRef(function () { return TTBody; }), selector: "[pTreeTableBody]", inputs: ["pTreeTableBody", "pTreeTableBodyTemplate", "frozen"] }, { type: i0.forwardRef(function () { return TTScrollableView; }), selector: "[ttScrollableView]", inputs: ["ttScrollableView", "frozen", "scrollHeight"] }], directives: [{ type: i0.forwardRef(function () { return i3.NgStyle; }), selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i0.forwardRef(function () { return i3.NgClass; }), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i0.forwardRef(function () { return i3.NgIf; }), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i0.forwardRef(function () { return i3.NgTemplateOutlet; }), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTable, decorators: [{ type: Component, args: [{ selector: 'p-treeTable', template: `
`, providers: [TreeTableService], encapsulation: ViewEncapsulation.None, host: { 'class': 'p-element' }, styles: [".p-treetable{position:relative}.p-treetable table{border-collapse:collapse;width:100%;table-layout:fixed}.p-treetable .p-sortable-column{cursor:pointer;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-treetable .p-sortable-column .p-column-title,.p-treetable .p-sortable-column .p-sortable-column-icon,.p-treetable .p-sortable-column .p-sortable-column-badge{vertical-align:middle}.p-treetable .p-sortable-column .p-sortable-column-badge{display:inline-flex;align-items:center;justify-content:center}.p-treetable-auto-layout>.p-treetable-wrapper{overflow-x:auto}.p-treetable-auto-layout>.p-treetable-wrapper>table{table-layout:auto}.p-treetable-hoverable-rows .p-treetable-tbody>tr{cursor:pointer}.p-treetable-toggler{cursor:pointer;-webkit-user-select:none;-ms-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;overflow:hidden;position:relative}p-treetabletoggler+p-treetablecheckbox .p-checkbox,p-treetabletoggler+p-treetablecheckbox+span{vertical-align:middle}.p-treetable-scrollable-wrapper{position:relative}.p-treetable-scrollable-header,.p-treetable-scrollable-footer{overflow:hidden}.p-treetable-scrollable-body{overflow:auto;position:relative}.p-treetable-scrollable-body>table>.p-treetable-tbody>tr:first-child>td{border-top:0 none}.p-treetable-virtual-table{position:absolute}.p-treetable-frozen-view .p-treetable-scrollable-body{overflow:hidden}.p-treetable-frozen-view>.p-treetable-scrollable-body>table>.p-treetable-tbody>tr>td:last-child{border-right:0 none}.p-treetable-unfrozen-view{position:absolute;top:0}.p-treetable-flex-scrollable,.p-treetable-flex-scrollable .p-treetable-scrollable-wrapper,.p-treetable-flex-scrollable .p-treetable-scrollable-view{display:flex;flex-direction:column;flex:1;height:100%}.p-treetable-flex-scrollable .p-treetable-scrollable-body{flex:1}.p-treetable-resizable>.p-treetable-wrapper{overflow-x:auto}.p-treetable-resizable .p-treetable-thead>tr>th,.p-treetable-resizable .p-treetable-tfoot>tr>td,.p-treetable-resizable .p-treetable-tbody>tr>td{overflow:hidden}.p-treetable-resizable .p-resizable-column{background-clip:padding-box;position:relative}.p-treetable-resizable-fit .p-resizable-column:last-child .p-column-resizer{display:none}.p-treetable .p-column-resizer{display:block;position:absolute!important;top:0;right:0;margin:0;width:.5rem;height:100%;padding:0;cursor:col-resize;border:1px solid transparent}.p-treetable .p-column-resizer-helper{width:1px;position:absolute;z-index:10;display:none}.p-treetable .p-row-editor-init,.p-treetable .p-row-editor-save,.p-treetable .p-row-editor-cancel,.p-treetable .p-row-toggler{display:inline-flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-treetable-reorder-indicator-up,.p-treetable-reorder-indicator-down{position:absolute;display:none}[ttReorderableColumn]{cursor:move}.p-treetable .p-treetable-loading-overlay{position:absolute;display:flex;align-items:center;justify-content:center;z-index:2}\n"] }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: TreeTableService }, { type: i1.FilterService }]; }, propDecorators: { columns: [{ type: Input }], style: [{ type: Input }], styleClass: [{ type: Input }], tableStyle: [{ type: Input }], tableStyleClass: [{ type: Input }], autoLayout: [{ type: Input }], lazy: [{ type: Input }], lazyLoadOnInit: [{ type: Input }], paginator: [{ type: Input }], rows: [{ type: Input }], first: [{ type: Input }], pageLinks: [{ type: Input }], rowsPerPageOptions: [{ type: Input }], alwaysShowPaginator: [{ type: Input }], paginatorPosition: [{ type: Input }], paginatorDropdownAppendTo: [{ type: Input }], currentPageReportTemplate: [{ type: Input }], showCurrentPageReport: [{ type: Input }], showJumpToPageDropdown: [{ type: Input }], showFirstLastIcon: [{ type: Input }], showPageLinks: [{ type: Input }], defaultSortOrder: [{ type: Input }], sortMode: [{ type: Input }], resetPageOnSort: [{ type: Input }], customSort: [{ type: Input }], selectionMode: [{ type: Input }], selectionChange: [{ type: Output }], contextMenuSelection: [{ type: Input }], contextMenuSelectionChange: [{ type: Output }], contextMenuSelectionMode: [{ type: Input }], dataKey: [{ type: Input }], metaKeySelection: [{ type: Input }], compareSelectionBy: [{ type: Input }], rowHover: [{ type: Input }], loading: [{ type: Input }], loadingIcon: [{ type: Input }], showLoader: [{ type: Input }], scrollable: [{ type: Input }], scrollHeight: [{ type: Input }], virtualScroll: [{ type: Input }], virtualScrollDelay: [{ type: Input }], virtualRowHeight: [{ type: Input }], minBufferPx: [{ type: Input }], maxBufferPx: [{ type: Input }], frozenWidth: [{ type: Input }], frozenColumns: [{ type: Input }], resizableColumns: [{ type: Input }], columnResizeMode: [{ type: Input }], reorderableColumns: [{ type: Input }], contextMenu: [{ type: Input }], rowTrackBy: [{ type: Input }], filters: [{ type: Input }], globalFilterFields: [{ type: Input }], filterDelay: [{ type: Input }], filterMode: [{ type: Input }], filterLocale: [{ type: Input }], onFilter: [{ type: Output }], onNodeExpand: [{ type: Output }], onNodeCollapse: [{ type: Output }], onPage: [{ type: Output }], onSort: [{ type: Output }], onLazyLoad: [{ type: Output }], sortFunction: [{ type: Output }], onColResize: [{ type: Output }], onColReorder: [{ type: Output }], onNodeSelect: [{ type: Output }], onNodeUnselect: [{ type: Output }], onContextMenuSelect: [{ type: Output }], onHeaderCheckboxToggle: [{ type: Output }], onEditInit: [{ type: Output }], onEditComplete: [{ type: Output }], onEditCancel: [{ type: Output }], containerViewChild: [{ type: ViewChild, args: ['container'] }], resizeHelperViewChild: [{ type: ViewChild, args: ['resizeHelper'] }], reorderIndicatorUpViewChild: [{ type: ViewChild, args: ['reorderIndicatorUp'] }], reorderIndicatorDownViewChild: [{ type: ViewChild, args: ['reorderIndicatorDown'] }], tableViewChild: [{ type: ViewChild, args: ['table'] }], scrollableViewChild: [{ type: ViewChild, args: ['scrollableView'] }], scrollableFrozenViewChild: [{ type: ViewChild, args: ['scrollableFrozenView'] }], templates: [{ type: ContentChildren, args: [PrimeTemplate] }], value: [{ type: Input }], totalRecords: [{ type: Input }], sortField: [{ type: Input }], sortOrder: [{ type: Input }], multiSortMeta: [{ type: Input }], selection: [{ type: Input }] } }); class TTBody { constructor(tt, treeTableService, cd) { this.tt = tt; this.treeTableService = treeTableService; this.cd = cd; this.subscription = this.tt.tableService.uiUpdateSource$.subscribe(() => { if (this.tt.virtualScroll) { this.cd.detectChanges(); } }); } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } } TTBody.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTBody, deps: [{ token: TreeTable }, { token: TreeTableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); TTBody.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TTBody, selector: "[pTreeTableBody]", inputs: { columns: ["pTreeTableBody", "columns"], template: ["pTreeTableBodyTemplate", "template"], frozen: "frozen" }, host: { classAttribute: "p-element" }, ngImport: i0, template: ` `, isInline: true, directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i4.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }], encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTBody, decorators: [{ type: Component, args: [{ selector: '[pTreeTableBody]', template: ` `, encapsulation: ViewEncapsulation.None, host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { columns: [{ type: Input, args: ["pTreeTableBody"] }], template: [{ type: Input, args: ["pTreeTableBodyTemplate"] }], frozen: [{ type: Input }] } }); class TTScrollableView { constructor(tt, el, zone) { this.tt = tt; this.el = el; this.zone = zone; } get scrollHeight() { return this._scrollHeight; } set scrollHeight(val) { this._scrollHeight = val; if (val != null && (val.includes('%') || val.includes('calc'))) { console.log('Percentage scroll height calculation is removed in favor of the more performant CSS based flex mode, use scrollHeight="flex" instead.'); } if (this.tt.virtualScroll && this.virtualScrollBody) { this.virtualScrollBody.ngOnInit(); } } ngAfterViewInit() { if (!this.frozen) { if (this.tt.frozenColumns || this.tt.frozenBodyTemplate) { DomHandler.addClass(this.el.nativeElement, 'p-treetable-unfrozen-view'); } let frozenView = this.el.nativeElement.previousElementSibling; if (frozenView) { if (this.tt.virtualScroll) this.frozenSiblingBody = DomHandler.findSingle(frozenView, '.p-treetable-virtual-scrollable-body'); else this.frozenSiblingBody = DomHandler.findSingle(frozenView, '.p-treetable-scrollable-body'); } let scrollBarWidth = DomHandler.calculateScrollbarWidth(); this.scrollHeaderBoxViewChild.nativeElement.style.paddingRight = scrollBarWidth + 'px'; if (this.scrollFooterBoxViewChild && this.scrollFooterBoxViewChild.nativeElement) { this.scrollFooterBoxViewChild.nativeElement.style.paddingRight = scrollBarWidth + 'px'; } } else { if (this.scrollableAlignerViewChild && this.scrollableAlignerViewChild.nativeElement) { this.scrollableAlignerViewChild.nativeElement.style.height = DomHandler.calculateScrollbarHeight() + 'px'; } } this.bindEvents(); } bindEvents() { this.zone.runOutsideAngular(() => { if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) { this.headerScrollListener = this.onHeaderScroll.bind(this); this.scrollHeaderBoxViewChild.nativeElement.addEventListener('scroll', this.headerScrollListener); } if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) { this.footerScrollListener = this.onFooterScroll.bind(this); this.scrollFooterViewChild.nativeElement.addEventListener('scroll', this.footerScrollListener); } if (!this.frozen) { this.bodyScrollListener = this.onBodyScroll.bind(this); if (this.tt.virtualScroll) this.virtualScrollBody.getElementRef().nativeElement.addEventListener('scroll', this.bodyScrollListener); else this.scrollBodyViewChild.nativeElement.addEventListener('scroll', this.bodyScrollListener); } }); } unbindEvents() { if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) { this.scrollHeaderBoxViewChild.nativeElement.removeEventListener('scroll', this.headerScrollListener); } if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) { this.scrollFooterViewChild.nativeElement.removeEventListener('scroll', this.footerScrollListener); } if (this.scrollBodyViewChild && this.scrollBodyViewChild.nativeElement) { this.scrollBodyViewChild.nativeElement.removeEventListener('scroll', this.bodyScrollListener); } if (this.virtualScrollBody && this.virtualScrollBody.getElementRef()) { this.virtualScrollBody.getElementRef().nativeElement.removeEventListener('scroll', this.bodyScrollListener); } } onHeaderScroll() { const scrollLeft = this.scrollHeaderViewChild.nativeElement.scrollLeft; this.scrollBodyViewChild.nativeElement.scrollLeft = scrollLeft; if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) { this.scrollFooterViewChild.nativeElement.scrollLeft = scrollLeft; } this.preventBodyScrollPropagation = true; } onFooterScroll() { const scrollLeft = this.scrollFooterViewChild.nativeElement.scrollLeft; this.scrollBodyViewChild.nativeElement.scrollLeft = scrollLeft; if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) { this.scrollHeaderViewChild.nativeElement.scrollLeft = scrollLeft; } this.preventBodyScrollPropagation = true; } onBodyScroll(event) { if (this.preventBodyScrollPropagation) { this.preventBodyScrollPropagation = false; return; } if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) { this.scrollHeaderBoxViewChild.nativeElement.style.marginLeft = -1 * event.target.scrollLeft + 'px'; } if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) { this.scrollFooterBoxViewChild.nativeElement.style.marginLeft = -1 * event.target.scrollLeft + 'px'; } if (this.frozenSiblingBody) { this.frozenSiblingBody.scrollTop = event.target.scrollTop; } } scrollToVirtualIndex(index) { if (this.virtualScrollBody) { this.virtualScrollBody.scrollToIndex(index); } } scrollTo(options) { if (this.virtualScrollBody) { this.virtualScrollBody.scrollTo(options); } else { if (this.scrollBodyViewChild.nativeElement.scrollTo) { this.scrollBodyViewChild.nativeElement.scrollTo(options); } else { this.scrollBodyViewChild.nativeElement.scrollLeft = options.left; this.scrollBodyViewChild.nativeElement.scrollTop = options.top; } } } ngOnDestroy() { this.unbindEvents(); this.frozenSiblingBody = null; } } TTScrollableView.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTScrollableView, deps: [{ token: TreeTable }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); TTScrollableView.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TTScrollableView, selector: "[ttScrollableView]", inputs: { columns: ["ttScrollableView", "columns"], frozen: "frozen", scrollHeight: "scrollHeight" }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "scrollHeaderViewChild", first: true, predicate: ["scrollHeader"], descendants: true }, { propertyName: "scrollHeaderBoxViewChild", first: true, predicate: ["scrollHeaderBox"], descendants: true }, { propertyName: "scrollBodyViewChild", first: true, predicate: ["scrollBody"], descendants: true }, { propertyName: "scrollTableViewChild", first: true, predicate: ["scrollTable"], descendants: true }, { propertyName: "scrollLoadingTableViewChild", first: true, predicate: ["loadingTable"], descendants: true }, { propertyName: "scrollFooterViewChild", first: true, predicate: ["scrollFooter"], descendants: true }, { propertyName: "scrollFooterBoxViewChild", first: true, predicate: ["scrollFooterBox"], descendants: true }, { propertyName: "scrollableAlignerViewChild", first: true, predicate: ["scrollableAligner"], descendants: true }, { propertyName: "virtualScrollBody", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], ngImport: i0, template: `
`, isInline: true, components: [{ type: TTBody, selector: "[pTreeTableBody]", inputs: ["pTreeTableBody", "pTreeTableBodyTemplate", "frozen"] }, { type: i4.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }], encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTScrollableView, decorators: [{ type: Component, args: [{ selector: '[ttScrollableView]', template: `
`, encapsulation: ViewEncapsulation.None, host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { columns: [{ type: Input, args: ["ttScrollableView"] }], frozen: [{ type: Input }], scrollHeaderViewChild: [{ type: ViewChild, args: ['scrollHeader'] }], scrollHeaderBoxViewChild: [{ type: ViewChild, args: ['scrollHeaderBox'] }], scrollBodyViewChild: [{ type: ViewChild, args: ['scrollBody'] }], scrollTableViewChild: [{ type: ViewChild, args: ['scrollTable'] }], scrollLoadingTableViewChild: [{ type: ViewChild, args: ['loadingTable'] }], scrollFooterViewChild: [{ type: ViewChild, args: ['scrollFooter'] }], scrollFooterBoxViewChild: [{ type: ViewChild, args: ['scrollFooterBox'] }], scrollableAlignerViewChild: [{ type: ViewChild, args: ['scrollableAligner'] }], virtualScrollBody: [{ type: ViewChild, args: [CdkVirtualScrollViewport] }], scrollHeight: [{ type: Input }] } }); class TTSortableColumn { constructor(tt) { this.tt = tt; if (this.isEnabled()) { this.subscription = this.tt.tableService.sortSource$.subscribe(sortMeta => { this.updateSortState(); }); } } ngOnInit() { if (this.isEnabled()) { this.updateSortState(); } } updateSortState() { this.sorted = this.tt.isSorted(this.field); } onClick(event) { if (this.isEnabled()) { this.updateSortState(); this.tt.sort({ originalEvent: event, field: this.field }); DomHandler.clearSelection(); } } onEnterKey(event) { this.onClick(event); } isEnabled() { return this.ttSortableColumnDisabled !== true; } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } } TTSortableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSortableColumn, deps: [{ token: TreeTable }], target: i0.ɵɵFactoryTarget.Directive }); TTSortableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTSortableColumn, selector: "[ttSortableColumn]", inputs: { field: ["ttSortableColumn", "field"], ttSortableColumnDisabled: "ttSortableColumnDisabled" }, host: { listeners: { "click": "onClick($event)", "keydown.enter": "onEnterKey($event)" }, properties: { "class.p-sortable-column": "isEnabled()", "class.p-highlight": "sorted", "attr.tabindex": "isEnabled() ? \"0\" : null", "attr.role": "\"columnheader\"" }, classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSortableColumn, decorators: [{ type: Directive, args: [{ selector: '[ttSortableColumn]', host: { 'class': 'p-element', '[class.p-sortable-column]': 'isEnabled()', '[class.p-highlight]': 'sorted', '[attr.tabindex]': 'isEnabled() ? "0" : null', '[attr.role]': '"columnheader"' } }] }], ctorParameters: function () { return [{ type: TreeTable }]; }, propDecorators: { field: [{ type: Input, args: ["ttSortableColumn"] }], ttSortableColumnDisabled: [{ type: Input }], onClick: [{ type: HostListener, args: ['click', ['$event']] }], onEnterKey: [{ type: HostListener, args: ['keydown.enter', ['$event']] }] } }); class TTSortIcon { constructor(tt, cd) { this.tt = tt; this.cd = cd; this.subscription = this.tt.tableService.sortSource$.subscribe(sortMeta => { this.updateSortState(); this.cd.markForCheck(); }); } ngOnInit() { this.updateSortState(); } onClick(event) { event.preventDefault(); } updateSortState() { if (this.tt.sortMode === 'single') { this.sortOrder = this.tt.isSorted(this.field) ? this.tt.sortOrder : 0; } else if (this.tt.sortMode === 'multiple') { let sortMeta = this.tt.getSortMeta(this.field); this.sortOrder = sortMeta ? sortMeta.order : 0; } } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } } TTSortIcon.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSortIcon, deps: [{ token: TreeTable }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); TTSortIcon.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TTSortIcon, selector: "p-treeTableSortIcon", inputs: { field: "field", ariaLabelDesc: "ariaLabelDesc", ariaLabelAsc: "ariaLabelAsc" }, host: { classAttribute: "p-element" }, ngImport: i0, template: ` `, isInline: true, directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSortIcon, decorators: [{ type: Component, args: [{ selector: 'p-treeTableSortIcon', template: ` `, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { field: [{ type: Input }], ariaLabelDesc: [{ type: Input }], ariaLabelAsc: [{ type: Input }] } }); class TTResizableColumn { constructor(tt, el, zone) { this.tt = tt; this.el = el; this.zone = zone; } ngAfterViewInit() { if (this.isEnabled()) { DomHandler.addClass(this.el.nativeElement, 'p-resizable-column'); this.resizer = document.createElement('span'); this.resizer.className = 'p-column-resizer'; this.el.nativeElement.appendChild(this.resizer); this.zone.runOutsideAngular(() => { this.resizerMouseDownListener = this.onMouseDown.bind(this); this.resizer.addEventListener('mousedown', this.resizerMouseDownListener); }); } } bindDocumentEvents() { this.zone.runOutsideAngular(() => { this.documentMouseMoveListener = this.onDocumentMouseMove.bind(this); document.addEventListener('mousemove', this.documentMouseMoveListener); this.documentMouseUpListener = this.onDocumentMouseUp.bind(this); document.addEventListener('mouseup', this.documentMouseUpListener); }); } unbindDocumentEvents() { if (this.documentMouseMoveListener) { document.removeEventListener('mousemove', this.documentMouseMoveListener); this.documentMouseMoveListener = null; } if (this.documentMouseUpListener) { document.removeEventListener('mouseup', this.documentMouseUpListener); this.documentMouseUpListener = null; } } onMouseDown(event) { this.tt.onColumnResizeBegin(event); this.bindDocumentEvents(); } onDocumentMouseMove(event) { this.tt.onColumnResize(event); } onDocumentMouseUp(event) { this.tt.onColumnResizeEnd(event, this.el.nativeElement); this.unbindDocumentEvents(); } isEnabled() { return this.ttResizableColumnDisabled !== true; } ngOnDestroy() { if (this.resizerMouseDownListener) { this.resizer.removeEventListener('mousedown', this.resizerMouseDownListener); } this.unbindDocumentEvents(); } } TTResizableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTResizableColumn, deps: [{ token: TreeTable }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); TTResizableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTResizableColumn, selector: "[ttResizableColumn]", inputs: { ttResizableColumnDisabled: "ttResizableColumnDisabled" }, host: { classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTResizableColumn, decorators: [{ type: Directive, args: [{ selector: '[ttResizableColumn]', host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { ttResizableColumnDisabled: [{ type: Input }] } }); class TTReorderableColumn { constructor(tt, el, zone) { this.tt = tt; this.el = el; this.zone = zone; } ngAfterViewInit() { if (this.isEnabled()) { this.bindEvents(); } } bindEvents() { this.zone.runOutsideAngular(() => { this.mouseDownListener = this.onMouseDown.bind(this); this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener); this.dragStartListener = this.onDragStart.bind(this); this.el.nativeElement.addEventListener('dragstart', this.dragStartListener); this.dragOverListener = this.onDragEnter.bind(this); this.el.nativeElement.addEventListener('dragover', this.dragOverListener); this.dragEnterListener = this.onDragEnter.bind(this); this.el.nativeElement.addEventListener('dragenter', this.dragEnterListener); this.dragLeaveListener = this.onDragLeave.bind(this); this.el.nativeElement.addEventListener('dragleave', this.dragLeaveListener); }); } unbindEvents() { if (this.mouseDownListener) { document.removeEventListener('mousedown', this.mouseDownListener); this.mouseDownListener = null; } if (this.dragOverListener) { document.removeEventListener('dragover', this.dragOverListener); this.dragOverListener = null; } if (this.dragEnterListener) { document.removeEventListener('dragenter', this.dragEnterListener); this.dragEnterListener = null; } if (this.dragEnterListener) { document.removeEventListener('dragenter', this.dragEnterListener); this.dragEnterListener = null; } if (this.dragLeaveListener) { document.removeEventListener('dragleave', this.dragLeaveListener); this.dragLeaveListener = null; } } onMouseDown(event) { if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' || DomHandler.hasClass(event.target, 'p-column-resizer')) this.el.nativeElement.draggable = false; else this.el.nativeElement.draggable = true; } onDragStart(event) { this.tt.onColumnDragStart(event, this.el.nativeElement); } onDragOver(event) { event.preventDefault(); } onDragEnter(event) { this.tt.onColumnDragEnter(event, this.el.nativeElement); } onDragLeave(event) { this.tt.onColumnDragLeave(event); } onDrop(event) { if (this.isEnabled()) { this.tt.onColumnDrop(event, this.el.nativeElement); } } isEnabled() { return this.ttReorderableColumnDisabled !== true; } ngOnDestroy() { this.unbindEvents(); } } TTReorderableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTReorderableColumn, deps: [{ token: TreeTable }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); TTReorderableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTReorderableColumn, selector: "[ttReorderableColumn]", inputs: { ttReorderableColumnDisabled: "ttReorderableColumnDisabled" }, host: { listeners: { "drop": "onDrop($event)" }, classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTReorderableColumn, decorators: [{ type: Directive, args: [{ selector: '[ttReorderableColumn]', host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { ttReorderableColumnDisabled: [{ type: Input }], onDrop: [{ type: HostListener, args: ['drop', ['$event']] }] } }); class TTSelectableRow { constructor(tt, tableService) { this.tt = tt; this.tableService = tableService; if (this.isEnabled()) { this.subscription = this.tt.tableService.selectionSource$.subscribe(() => { this.selected = this.tt.isSelected(this.rowNode.node); }); } } ngOnInit() { if (this.isEnabled()) { this.selected = this.tt.isSelected(this.rowNode.node); } } onClick(event) { if (this.isEnabled()) { this.tt.handleRowClick({ originalEvent: event, rowNode: this.rowNode }); } } onEnterKey(event) { if (event.which === 13) { this.onClick(event); } } onTouchEnd(event) { if (this.isEnabled()) { this.tt.handleRowTouchEnd(event); } } isEnabled() { return this.ttSelectableRowDisabled !== true; } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } } TTSelectableRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSelectableRow, deps: [{ token: TreeTable }, { token: TreeTableService }], target: i0.ɵɵFactoryTarget.Directive }); TTSelectableRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTSelectableRow, selector: "[ttSelectableRow]", inputs: { rowNode: ["ttSelectableRow", "rowNode"], ttSelectableRowDisabled: "ttSelectableRowDisabled" }, host: { listeners: { "click": "onClick($event)", "keydown": "onEnterKey($event)", "touchend": "onTouchEnd($event)" }, properties: { "class.p-highlight": "selected" }, classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSelectableRow, decorators: [{ type: Directive, args: [{ selector: '[ttSelectableRow]', host: { 'class': 'p-element', '[class.p-highlight]': 'selected' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }]; }, propDecorators: { rowNode: [{ type: Input, args: ["ttSelectableRow"] }], ttSelectableRowDisabled: [{ type: Input }], onClick: [{ type: HostListener, args: ['click', ['$event']] }], onEnterKey: [{ type: HostListener, args: ['keydown', ['$event']] }], onTouchEnd: [{ type: HostListener, args: ['touchend', ['$event']] }] } }); class TTSelectableRowDblClick { constructor(tt, tableService) { this.tt = tt; this.tableService = tableService; if (this.isEnabled()) { this.subscription = this.tt.tableService.selectionSource$.subscribe(() => { this.selected = this.tt.isSelected(this.rowNode.node); }); } } ngOnInit() { if (this.isEnabled()) { this.selected = this.tt.isSelected(this.rowNode.node); } } onClick(event) { if (this.isEnabled()) { this.tt.handleRowClick({ originalEvent: event, rowNode: this.rowNode }); } } isEnabled() { return this.ttSelectableRowDisabled !== true; } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } } TTSelectableRowDblClick.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSelectableRowDblClick, deps: [{ token: TreeTable }, { token: TreeTableService }], target: i0.ɵɵFactoryTarget.Directive }); TTSelectableRowDblClick.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTSelectableRowDblClick, selector: "[ttSelectableRowDblClick]", inputs: { rowNode: ["ttSelectableRowDblClick", "rowNode"], ttSelectableRowDisabled: "ttSelectableRowDisabled" }, host: { listeners: { "dblclick": "onClick($event)" }, properties: { "class.p-highlight": "selected" }, classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSelectableRowDblClick, decorators: [{ type: Directive, args: [{ selector: '[ttSelectableRowDblClick]', host: { 'class': 'p-element', '[class.p-highlight]': 'selected' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }]; }, propDecorators: { rowNode: [{ type: Input, args: ["ttSelectableRowDblClick"] }], ttSelectableRowDisabled: [{ type: Input }], onClick: [{ type: HostListener, args: ['dblclick', ['$event']] }] } }); class TTContextMenuRow { constructor(tt, tableService, el) { this.tt = tt; this.tableService = tableService; this.el = el; if (this.isEnabled()) { this.subscription = this.tt.tableService.contextMenuSource$.subscribe((node) => { this.selected = this.tt.equals(this.rowNode.node, node); }); } } onContextMenu(event) { if (this.isEnabled()) { this.tt.handleRowRightClick({ originalEvent: event, rowNode: this.rowNode }); this.el.nativeElement.focus(); event.preventDefault(); } } isEnabled() { return this.ttContextMenuRowDisabled !== true; } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } } TTContextMenuRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTContextMenuRow, deps: [{ token: TreeTable }, { token: TreeTableService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); TTContextMenuRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTContextMenuRow, selector: "[ttContextMenuRow]", inputs: { rowNode: ["ttContextMenuRow", "rowNode"], ttContextMenuRowDisabled: "ttContextMenuRowDisabled" }, host: { listeners: { "contextmenu": "onContextMenu($event)" }, properties: { "class.p-highlight-contextmenu": "selected", "attr.tabindex": "isEnabled() ? 0 : undefined" }, classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTContextMenuRow, decorators: [{ type: Directive, args: [{ selector: '[ttContextMenuRow]', host: { 'class': 'p-element', '[class.p-highlight-contextmenu]': 'selected', '[attr.tabindex]': 'isEnabled() ? 0 : undefined' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ElementRef }]; }, propDecorators: { rowNode: [{ type: Input, args: ["ttContextMenuRow"] }], ttContextMenuRowDisabled: [{ type: Input }], onContextMenu: [{ type: HostListener, args: ['contextmenu', ['$event']] }] } }); class TTCheckbox { constructor(tt, tableService, cd) { this.tt = tt; this.tableService = tableService; this.cd = cd; this.subscription = this.tt.tableService.selectionSource$.subscribe(() => { this.checked = this.tt.isSelected(this.rowNode.node); this.cd.markForCheck(); }); } ngOnInit() { this.checked = this.tt.isSelected(this.rowNode.node); } onClick(event) { if (!this.disabled) { this.tt.toggleNodeWithCheckbox({ originalEvent: event, rowNode: this.rowNode }); } DomHandler.clearSelection(); } onFocus() { DomHandler.addClass(this.boxViewChild.nativeElement, 'p-focus'); } onBlur() { DomHandler.removeClass(this.boxViewChild.nativeElement, 'p-focus'); } ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } } TTCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTCheckbox, deps: [{ token: TreeTable }, { token: TreeTableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); TTCheckbox.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TTCheckbox, selector: "p-treeTableCheckbox", inputs: { disabled: "disabled", rowNode: ["value", "rowNode"] }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "boxViewChild", first: true, predicate: ["box"], descendants: true }], ngImport: i0, template: `
`, isInline: true, directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTCheckbox, decorators: [{ type: Component, args: [{ selector: 'p-treeTableCheckbox', template: `
`, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { disabled: [{ type: Input }], rowNode: [{ type: Input, args: ["value"] }], boxViewChild: [{ type: ViewChild, args: ['box'] }] } }); class TTHeaderCheckbox { constructor(tt, tableService, cd) { this.tt = tt; this.tableService = tableService; this.cd = cd; this.valueChangeSubscription = this.tt.tableService.uiUpdateSource$.subscribe(() => { this.checked = this.updateCheckedState(); }); this.selectionChangeSubscription = this.tt.tableService.selectionSource$.subscribe(() => { this.checked = this.updateCheckedState(); }); } ngOnInit() { this.checked = this.updateCheckedState(); } onClick(event, checked) { if (this.tt.value && this.tt.value.length > 0) { this.tt.toggleNodesWithCheckbox(event, !checked); } DomHandler.clearSelection(); } onFocus() { DomHandler.addClass(this.boxViewChild.nativeElement, 'p-focus'); } onBlur() { DomHandler.removeClass(this.boxViewChild.nativeElement, 'p-focus'); } ngOnDestroy() { if (this.selectionChangeSubscription) { this.selectionChangeSubscription.unsubscribe(); } if (this.valueChangeSubscription) { this.valueChangeSubscription.unsubscribe(); } } updateCheckedState() { this.cd.markForCheck(); let checked; const data = this.tt.filteredNodes || this.tt.value; if (data) { for (let node of data) { if (this.tt.isSelected(node)) { checked = true; } else { checked = false; break; } } } else { checked = false; } return checked; } } TTHeaderCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTHeaderCheckbox, deps: [{ token: TreeTable }, { token: TreeTableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); TTHeaderCheckbox.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TTHeaderCheckbox, selector: "p-treeTableHeaderCheckbox", host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "boxViewChild", first: true, predicate: ["box"], descendants: true }], ngImport: i0, template: `
`, isInline: true, directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTHeaderCheckbox, decorators: [{ type: Component, args: [{ selector: 'p-treeTableHeaderCheckbox', template: `
`, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { boxViewChild: [{ type: ViewChild, args: ['box'] }] } }); class TTEditableColumn { constructor(tt, el, zone) { this.tt = tt; this.el = el; this.zone = zone; } ngAfterViewInit() { if (this.isEnabled()) { DomHandler.addClass(this.el.nativeElement, 'p-editable-column'); } } onClick(event) { if (this.isEnabled()) { this.tt.editingCellClick = true; if (this.tt.editingCell) { if (this.tt.editingCell !== this.el.nativeElement) { if (!this.tt.isEditingCellValid()) { return; } DomHandler.removeClass(this.tt.editingCell, 'p-cell-editing'); this.openCell(); } } else { this.openCell(); } } } openCell() { this.tt.updateEditingCell(this.el.nativeElement, this.data, this.field); DomHandler.addClass(this.el.nativeElement, 'p-cell-editing'); this.tt.onEditInit.emit({ field: this.field, data: this.data }); this.tt.editingCellClick = true; this.zone.runOutsideAngular(() => { setTimeout(() => { let focusable = DomHandler.findSingle(this.el.nativeElement, 'input, textarea'); if (focusable) { focusable.focus(); } }, 50); }); } closeEditingCell() { DomHandler.removeClass(this.tt.editingCell, 'p-checkbox-icon'); this.tt.editingCell = null; this.tt.unbindDocumentEditListener(); } onKeyDown(event) { if (this.isEnabled()) { //enter if (event.keyCode == 13) { if (this.tt.isEditingCellValid()) { DomHandler.removeClass(this.tt.editingCell, 'p-cell-editing'); this.closeEditingCell(); this.tt.onEditComplete.emit({ field: this.field, data: this.data }); } event.preventDefault(); } //escape else if (event.keyCode == 27) { if (this.tt.isEditingCellValid()) { DomHandler.removeClass(this.tt.editingCell, 'p-cell-editing'); this.closeEditingCell(); this.tt.onEditCancel.emit({ field: this.field, data: this.data }); } event.preventDefault(); } //tab else if (event.keyCode == 9) { this.tt.onEditComplete.emit({ field: this.field, data: this.data }); if (event.shiftKey) this.moveToPreviousCell(event); else this.moveToNextCell(event); } } } findCell(element) { if (element) { let cell = element; while (cell && !DomHandler.hasClass(cell, 'p-cell-editing')) { cell = cell.parentElement; } return cell; } else { return null; } } moveToPreviousCell(event) { let currentCell = this.findCell(event.target); let row = currentCell.parentElement; let targetCell = this.findPreviousEditableColumn(currentCell); if (targetCell) { DomHandler.invokeElementMethod(targetCell, 'click'); event.preventDefault(); } } moveToNextCell(event) { let currentCell = this.findCell(event.target); let row = currentCell.parentElement; let targetCell = this.findNextEditableColumn(currentCell); if (targetCell) { DomHandler.invokeElementMethod(targetCell, 'click'); event.preventDefault(); } } findPreviousEditableColumn(cell) { let prevCell = cell.previousElementSibling; if (!prevCell) { let previousRow = cell.parentElement ? cell.parentElement.previousElementSibling : null; if (previousRow) { prevCell = previousRow.lastElementChild; } } if (prevCell) { if (DomHandler.hasClass(prevCell, 'p-editable-column')) return prevCell; else return this.findPreviousEditableColumn(prevCell); } else { return null; } } findNextEditableColumn(cell) { let nextCell = cell.nextElementSibling; if (!nextCell) { let nextRow = cell.parentElement ? cell.parentElement.nextElementSibling : null; if (nextRow) { nextCell = nextRow.firstElementChild; } } if (nextCell) { if (DomHandler.hasClass(nextCell, 'p-editable-column')) return nextCell; else return this.findNextEditableColumn(nextCell); } else { return null; } } isEnabled() { return this.ttEditableColumnDisabled !== true; } } TTEditableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTEditableColumn, deps: [{ token: TreeTable }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); TTEditableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTEditableColumn, selector: "[ttEditableColumn]", inputs: { data: ["ttEditableColumn", "data"], field: ["ttEditableColumnField", "field"], ttEditableColumnDisabled: "ttEditableColumnDisabled" }, host: { listeners: { "click": "onClick($event)", "keydown": "onKeyDown($event)" }, classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTEditableColumn, decorators: [{ type: Directive, args: [{ selector: '[ttEditableColumn]', host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { data: [{ type: Input, args: ["ttEditableColumn"] }], field: [{ type: Input, args: ["ttEditableColumnField"] }], ttEditableColumnDisabled: [{ type: Input }], onClick: [{ type: HostListener, args: ['click', ['$event']] }], onKeyDown: [{ type: HostListener, args: ['keydown', ['$event']] }] } }); class TreeTableCellEditor { constructor(tt, editableColumn) { this.tt = tt; this.editableColumn = editableColumn; } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'input': this.inputTemplate = item.template; break; case 'output': this.outputTemplate = item.template; break; } }); } } TreeTableCellEditor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableCellEditor, deps: [{ token: TreeTable }, { token: TTEditableColumn }], target: i0.ɵɵFactoryTarget.Component }); TreeTableCellEditor.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TreeTableCellEditor, selector: "p-treeTableCellEditor", host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: ` `, isInline: true, directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableCellEditor, decorators: [{ type: Component, args: [{ selector: 'p-treeTableCellEditor', template: ` `, encapsulation: ViewEncapsulation.None, host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: TTEditableColumn }]; }, propDecorators: { templates: [{ type: ContentChildren, args: [PrimeTemplate] }] } }); class TTRow { constructor(tt, el, zone) { this.tt = tt; this.el = el; this.zone = zone; } onKeyDown(event) { switch (event.which) { //down arrow case 40: let nextRow = this.el.nativeElement.nextElementSibling; if (nextRow) { nextRow.focus(); } event.preventDefault(); break; //down arrow case 38: let prevRow = this.el.nativeElement.previousElementSibling; if (prevRow) { prevRow.focus(); } event.preventDefault(); break; //left arrow case 37: if (this.rowNode.node.expanded) { this.tt.toggleRowIndex = DomHandler.index(this.el.nativeElement); this.rowNode.node.expanded = false; this.tt.onNodeCollapse.emit({ originalEvent: event, node: this.rowNode.node }); this.tt.updateSerializedValue(); this.tt.tableService.onUIUpdate(this.tt.value); this.restoreFocus(); } break; //right arrow case 39: if (!this.rowNode.node.expanded) { this.tt.toggleRowIndex = DomHandler.index(this.el.nativeElement); this.rowNode.node.expanded = true; this.tt.onNodeExpand.emit({ originalEvent: event, node: this.rowNode.node }); this.tt.updateSerializedValue(); this.tt.tableService.onUIUpdate(this.tt.value); this.restoreFocus(); } break; } } restoreFocus() { this.zone.runOutsideAngular(() => { setTimeout(() => { let row = DomHandler.findSingle(this.tt.containerViewChild.nativeElement, '.p-treetable-tbody').children[this.tt.toggleRowIndex]; if (row) { row.focus(); } }, 25); }); } } TTRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTRow, deps: [{ token: TreeTable }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); TTRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: TTRow, selector: "[ttRow]", inputs: { rowNode: ["ttRow", "rowNode"] }, host: { listeners: { "keydown": "onKeyDown($event)" }, properties: { "attr.tabindex": "\"0\"" }, classAttribute: "p-element" }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTRow, decorators: [{ type: Directive, args: [{ selector: '[ttRow]', host: { 'class': 'p-element', '[attr.tabindex]': '"0"' } }] }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { rowNode: [{ type: Input, args: ['ttRow'] }], onKeyDown: [{ type: HostListener, args: ['keydown', ['$event']] }] } }); class TreeTableToggler { constructor(tt) { this.tt = tt; } onClick(event) { this.rowNode.node.expanded = !this.rowNode.node.expanded; if (this.rowNode.node.expanded) { this.tt.onNodeExpand.emit({ originalEvent: event, node: this.rowNode.node }); } else { this.tt.onNodeCollapse.emit({ originalEvent: event, node: this.rowNode.node }); } this.tt.updateSerializedValue(); this.tt.tableService.onUIUpdate(this.tt.value); event.preventDefault(); } } TreeTableToggler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableToggler, deps: [{ token: TreeTable }], target: i0.ɵɵFactoryTarget.Component }); TreeTableToggler.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TreeTableToggler, selector: "p-treeTableToggler", inputs: { rowNode: "rowNode" }, host: { classAttribute: "p-element" }, ngImport: i0, template: ` `, isInline: true, directives: [{ type: i5.Ripple, selector: "[pRipple]" }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableToggler, decorators: [{ type: Component, args: [{ selector: 'p-treeTableToggler', template: ` `, encapsulation: ViewEncapsulation.None, host: { 'class': 'p-element' } }] }], ctorParameters: function () { return [{ type: TreeTable }]; }, propDecorators: { rowNode: [{ type: Input }] } }); class TreeTableModule { } TreeTableModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); TreeTableModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableModule, declarations: [TreeTable, TreeTableToggler, TTScrollableView, TTBody, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor], imports: [CommonModule, PaginatorModule, ScrollingModule, RippleModule], exports: [TreeTable, SharedModule, TreeTableToggler, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor, ScrollingModule] }); TreeTableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableModule, imports: [[CommonModule, PaginatorModule, ScrollingModule, RippleModule], SharedModule, ScrollingModule] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule, PaginatorModule, ScrollingModule, RippleModule], exports: [TreeTable, SharedModule, TreeTableToggler, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor, ScrollingModule], declarations: [TreeTable, TreeTableToggler, TTScrollableView, TTBody, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor] }] }] }); /** * Generated bundle index. Do not edit. */ export { TTBody, TTCheckbox, TTContextMenuRow, TTEditableColumn, TTHeaderCheckbox, TTReorderableColumn, TTResizableColumn, TTRow, TTScrollableView, TTSelectableRow, TTSelectableRowDblClick, TTSortIcon, TTSortableColumn, TreeTable, TreeTableCellEditor, TreeTableModule, TreeTableService, TreeTableToggler };