[59329aa] | 1 | import * as i0 from '@angular/core';
|
---|
| 2 | import { Injectable, EventEmitter, Component, ViewEncapsulation, Input, Output, ViewChild, ContentChildren, Directive, HostListener, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
---|
| 3 | import * as i3 from '@angular/common';
|
---|
| 4 | import { CommonModule } from '@angular/common';
|
---|
| 5 | import { Subject } from 'rxjs';
|
---|
| 6 | import { DomHandler } from 'primeng/dom';
|
---|
| 7 | import * as i2 from 'primeng/paginator';
|
---|
| 8 | import { PaginatorModule } from 'primeng/paginator';
|
---|
| 9 | import * as i1 from 'primeng/api';
|
---|
| 10 | import { PrimeTemplate, SharedModule } from 'primeng/api';
|
---|
| 11 | import { ObjectUtils } from 'primeng/utils';
|
---|
| 12 | import * as i5 from 'primeng/ripple';
|
---|
| 13 | import { RippleModule } from 'primeng/ripple';
|
---|
| 14 | import * as i4 from '@angular/cdk/scrolling';
|
---|
| 15 | import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
|
---|
| 16 |
|
---|
| 17 | class TreeTableService {
|
---|
| 18 | constructor() {
|
---|
| 19 | this.sortSource = new Subject();
|
---|
| 20 | this.selectionSource = new Subject();
|
---|
| 21 | this.contextMenuSource = new Subject();
|
---|
| 22 | this.uiUpdateSource = new Subject();
|
---|
| 23 | this.totalRecordsSource = new Subject();
|
---|
| 24 | this.sortSource$ = this.sortSource.asObservable();
|
---|
| 25 | this.selectionSource$ = this.selectionSource.asObservable();
|
---|
| 26 | this.contextMenuSource$ = this.contextMenuSource.asObservable();
|
---|
| 27 | this.uiUpdateSource$ = this.uiUpdateSource.asObservable();
|
---|
| 28 | this.totalRecordsSource$ = this.totalRecordsSource.asObservable();
|
---|
| 29 | }
|
---|
| 30 | onSort(sortMeta) {
|
---|
| 31 | this.sortSource.next(sortMeta);
|
---|
| 32 | }
|
---|
| 33 | onSelectionChange() {
|
---|
| 34 | this.selectionSource.next(null);
|
---|
| 35 | }
|
---|
| 36 | onContextMenu(node) {
|
---|
| 37 | this.contextMenuSource.next(node);
|
---|
| 38 | }
|
---|
| 39 | onUIUpdate(value) {
|
---|
| 40 | this.uiUpdateSource.next(value);
|
---|
| 41 | }
|
---|
| 42 | onTotalRecordsChange(value) {
|
---|
| 43 | this.totalRecordsSource.next(value);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | TreeTableService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
---|
| 47 | TreeTableService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableService });
|
---|
| 48 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableService, decorators: [{
|
---|
| 49 | type: Injectable
|
---|
| 50 | }] });
|
---|
| 51 | class TreeTable {
|
---|
| 52 | constructor(el, zone, tableService, filterService) {
|
---|
| 53 | this.el = el;
|
---|
| 54 | this.zone = zone;
|
---|
| 55 | this.tableService = tableService;
|
---|
| 56 | this.filterService = filterService;
|
---|
| 57 | this.lazy = false;
|
---|
| 58 | this.lazyLoadOnInit = true;
|
---|
| 59 | this.first = 0;
|
---|
| 60 | this.pageLinks = 5;
|
---|
| 61 | this.alwaysShowPaginator = true;
|
---|
| 62 | this.paginatorPosition = 'bottom';
|
---|
| 63 | this.currentPageReportTemplate = '{currentPage} of {totalPages}';
|
---|
| 64 | this.showFirstLastIcon = true;
|
---|
| 65 | this.showPageLinks = true;
|
---|
| 66 | this.defaultSortOrder = 1;
|
---|
| 67 | this.sortMode = 'single';
|
---|
| 68 | this.resetPageOnSort = true;
|
---|
| 69 | this.selectionChange = new EventEmitter();
|
---|
| 70 | this.contextMenuSelectionChange = new EventEmitter();
|
---|
| 71 | this.contextMenuSelectionMode = "separate";
|
---|
| 72 | this.compareSelectionBy = 'deepEquals';
|
---|
| 73 | this.loadingIcon = 'pi pi-spinner';
|
---|
| 74 | this.showLoader = true;
|
---|
| 75 | this.virtualScrollDelay = 150;
|
---|
| 76 | this.virtualRowHeight = 28;
|
---|
| 77 | this.columnResizeMode = 'fit';
|
---|
| 78 | this.rowTrackBy = (index, item) => item;
|
---|
| 79 | this.filters = {};
|
---|
| 80 | this.filterDelay = 300;
|
---|
| 81 | this.filterMode = 'lenient';
|
---|
| 82 | this.onFilter = new EventEmitter();
|
---|
| 83 | this.onNodeExpand = new EventEmitter();
|
---|
| 84 | this.onNodeCollapse = new EventEmitter();
|
---|
| 85 | this.onPage = new EventEmitter();
|
---|
| 86 | this.onSort = new EventEmitter();
|
---|
| 87 | this.onLazyLoad = new EventEmitter();
|
---|
| 88 | this.sortFunction = new EventEmitter();
|
---|
| 89 | this.onColResize = new EventEmitter();
|
---|
| 90 | this.onColReorder = new EventEmitter();
|
---|
| 91 | this.onNodeSelect = new EventEmitter();
|
---|
| 92 | this.onNodeUnselect = new EventEmitter();
|
---|
| 93 | this.onContextMenuSelect = new EventEmitter();
|
---|
| 94 | this.onHeaderCheckboxToggle = new EventEmitter();
|
---|
| 95 | this.onEditInit = new EventEmitter();
|
---|
| 96 | this.onEditComplete = new EventEmitter();
|
---|
| 97 | this.onEditCancel = new EventEmitter();
|
---|
| 98 | this._value = [];
|
---|
| 99 | this._totalRecords = 0;
|
---|
| 100 | this._sortOrder = 1;
|
---|
| 101 | this.selectionKeys = {};
|
---|
| 102 | }
|
---|
| 103 | ngOnInit() {
|
---|
| 104 | if (this.lazy && this.lazyLoadOnInit) {
|
---|
| 105 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 106 | }
|
---|
| 107 | this.initialized = true;
|
---|
| 108 | }
|
---|
| 109 | ngAfterContentInit() {
|
---|
| 110 | this.templates.forEach((item) => {
|
---|
| 111 | switch (item.getType()) {
|
---|
| 112 | case 'caption':
|
---|
| 113 | this.captionTemplate = item.template;
|
---|
| 114 | break;
|
---|
| 115 | case 'header':
|
---|
| 116 | this.headerTemplate = item.template;
|
---|
| 117 | break;
|
---|
| 118 | case 'body':
|
---|
| 119 | this.bodyTemplate = item.template;
|
---|
| 120 | break;
|
---|
| 121 | case 'loadingbody':
|
---|
| 122 | this.loadingBodyTemplate = item.template;
|
---|
| 123 | break;
|
---|
| 124 | case 'footer':
|
---|
| 125 | this.footerTemplate = item.template;
|
---|
| 126 | break;
|
---|
| 127 | case 'summary':
|
---|
| 128 | this.summaryTemplate = item.template;
|
---|
| 129 | break;
|
---|
| 130 | case 'colgroup':
|
---|
| 131 | this.colGroupTemplate = item.template;
|
---|
| 132 | break;
|
---|
| 133 | case 'emptymessage':
|
---|
| 134 | this.emptyMessageTemplate = item.template;
|
---|
| 135 | break;
|
---|
| 136 | case 'paginatorleft':
|
---|
| 137 | this.paginatorLeftTemplate = item.template;
|
---|
| 138 | break;
|
---|
| 139 | case 'paginatorright':
|
---|
| 140 | this.paginatorRightTemplate = item.template;
|
---|
| 141 | break;
|
---|
| 142 | case 'paginatordropdownitem':
|
---|
| 143 | this.paginatorDropdownItemTemplate = item.template;
|
---|
| 144 | break;
|
---|
| 145 | case 'frozenheader':
|
---|
| 146 | this.frozenHeaderTemplate = item.template;
|
---|
| 147 | break;
|
---|
| 148 | case 'frozenbody':
|
---|
| 149 | this.frozenBodyTemplate = item.template;
|
---|
| 150 | break;
|
---|
| 151 | case 'frozenfooter':
|
---|
| 152 | this.frozenFooterTemplate = item.template;
|
---|
| 153 | break;
|
---|
| 154 | case 'frozencolgroup':
|
---|
| 155 | this.frozenColGroupTemplate = item.template;
|
---|
| 156 | break;
|
---|
| 157 | }
|
---|
| 158 | });
|
---|
| 159 | }
|
---|
| 160 | ngOnChanges(simpleChange) {
|
---|
| 161 | if (simpleChange.value) {
|
---|
| 162 | this._value = simpleChange.value.currentValue;
|
---|
| 163 | if (!this.lazy) {
|
---|
| 164 | this.totalRecords = (this._value ? this._value.length : 0);
|
---|
| 165 | if (this.sortMode == 'single' && this.sortField)
|
---|
| 166 | this.sortSingle();
|
---|
| 167 | else if (this.sortMode == 'multiple' && this.multiSortMeta)
|
---|
| 168 | this.sortMultiple();
|
---|
| 169 | else if (this.hasFilter()) //sort already filters
|
---|
| 170 | this._filter();
|
---|
| 171 | }
|
---|
| 172 | this.updateSerializedValue();
|
---|
| 173 | this.tableService.onUIUpdate(this.value);
|
---|
| 174 | }
|
---|
| 175 | if (simpleChange.sortField) {
|
---|
| 176 | this._sortField = simpleChange.sortField.currentValue;
|
---|
| 177 | //avoid triggering lazy load prior to lazy initialization at onInit
|
---|
| 178 | if (!this.lazy || this.initialized) {
|
---|
| 179 | if (this.sortMode === 'single') {
|
---|
| 180 | this.sortSingle();
|
---|
| 181 | }
|
---|
| 182 | }
|
---|
| 183 | }
|
---|
| 184 | if (simpleChange.sortOrder) {
|
---|
| 185 | this._sortOrder = simpleChange.sortOrder.currentValue;
|
---|
| 186 | //avoid triggering lazy load prior to lazy initialization at onInit
|
---|
| 187 | if (!this.lazy || this.initialized) {
|
---|
| 188 | if (this.sortMode === 'single') {
|
---|
| 189 | this.sortSingle();
|
---|
| 190 | }
|
---|
| 191 | }
|
---|
| 192 | }
|
---|
| 193 | if (simpleChange.multiSortMeta) {
|
---|
| 194 | this._multiSortMeta = simpleChange.multiSortMeta.currentValue;
|
---|
| 195 | if (this.sortMode === 'multiple') {
|
---|
| 196 | this.sortMultiple();
|
---|
| 197 | }
|
---|
| 198 | }
|
---|
| 199 | if (simpleChange.selection) {
|
---|
| 200 | this._selection = simpleChange.selection.currentValue;
|
---|
| 201 | if (!this.preventSelectionSetterPropagation) {
|
---|
| 202 | this.updateSelectionKeys();
|
---|
| 203 | this.tableService.onSelectionChange();
|
---|
| 204 | }
|
---|
| 205 | this.preventSelectionSetterPropagation = false;
|
---|
| 206 | }
|
---|
| 207 | }
|
---|
| 208 | get value() {
|
---|
| 209 | return this._value;
|
---|
| 210 | }
|
---|
| 211 | set value(val) {
|
---|
| 212 | this._value = val;
|
---|
| 213 | }
|
---|
| 214 | updateSerializedValue() {
|
---|
| 215 | this.serializedValue = [];
|
---|
| 216 | if (this.paginator)
|
---|
| 217 | this.serializePageNodes();
|
---|
| 218 | else
|
---|
| 219 | this.serializeNodes(null, this.filteredNodes || this.value, 0, true);
|
---|
| 220 | }
|
---|
| 221 | serializeNodes(parent, nodes, level, visible) {
|
---|
| 222 | if (nodes && nodes.length) {
|
---|
| 223 | for (let node of nodes) {
|
---|
| 224 | node.parent = parent;
|
---|
| 225 | const rowNode = {
|
---|
| 226 | node: node,
|
---|
| 227 | parent: parent,
|
---|
| 228 | level: level,
|
---|
| 229 | visible: visible && (parent ? parent.expanded : true)
|
---|
| 230 | };
|
---|
| 231 | this.serializedValue.push(rowNode);
|
---|
| 232 | if (rowNode.visible && node.expanded) {
|
---|
| 233 | this.serializeNodes(node, node.children, level + 1, rowNode.visible);
|
---|
| 234 | }
|
---|
| 235 | }
|
---|
| 236 | }
|
---|
| 237 | }
|
---|
| 238 | serializePageNodes() {
|
---|
| 239 | let data = this.filteredNodes || this.value;
|
---|
| 240 | this.serializedValue = [];
|
---|
| 241 | if (data && data.length) {
|
---|
| 242 | const first = this.lazy ? 0 : this.first;
|
---|
| 243 | for (let i = first; i < (first + this.rows); i++) {
|
---|
| 244 | let node = data[i];
|
---|
| 245 | if (node) {
|
---|
| 246 | this.serializedValue.push({
|
---|
| 247 | node: node,
|
---|
| 248 | parent: null,
|
---|
| 249 | level: 0,
|
---|
| 250 | visible: true
|
---|
| 251 | });
|
---|
| 252 | this.serializeNodes(node, node.children, 1, true);
|
---|
| 253 | }
|
---|
| 254 | }
|
---|
| 255 | }
|
---|
| 256 | }
|
---|
| 257 | get totalRecords() {
|
---|
| 258 | return this._totalRecords;
|
---|
| 259 | }
|
---|
| 260 | set totalRecords(val) {
|
---|
| 261 | this._totalRecords = val;
|
---|
| 262 | this.tableService.onTotalRecordsChange(this._totalRecords);
|
---|
| 263 | }
|
---|
| 264 | get sortField() {
|
---|
| 265 | return this._sortField;
|
---|
| 266 | }
|
---|
| 267 | set sortField(val) {
|
---|
| 268 | this._sortField = val;
|
---|
| 269 | }
|
---|
| 270 | get sortOrder() {
|
---|
| 271 | return this._sortOrder;
|
---|
| 272 | }
|
---|
| 273 | set sortOrder(val) {
|
---|
| 274 | this._sortOrder = val;
|
---|
| 275 | }
|
---|
| 276 | get multiSortMeta() {
|
---|
| 277 | return this._multiSortMeta;
|
---|
| 278 | }
|
---|
| 279 | set multiSortMeta(val) {
|
---|
| 280 | this._multiSortMeta = val;
|
---|
| 281 | }
|
---|
| 282 | get selection() {
|
---|
| 283 | return this._selection;
|
---|
| 284 | }
|
---|
| 285 | set selection(val) {
|
---|
| 286 | this._selection = val;
|
---|
| 287 | }
|
---|
| 288 | updateSelectionKeys() {
|
---|
| 289 | if (this.dataKey && this._selection) {
|
---|
| 290 | this.selectionKeys = {};
|
---|
| 291 | if (Array.isArray(this._selection)) {
|
---|
| 292 | for (let node of this._selection) {
|
---|
| 293 | this.selectionKeys[String(ObjectUtils.resolveFieldData(node.data, this.dataKey))] = 1;
|
---|
| 294 | }
|
---|
| 295 | }
|
---|
| 296 | else {
|
---|
| 297 | this.selectionKeys[String(ObjectUtils.resolveFieldData(this._selection.data, this.dataKey))] = 1;
|
---|
| 298 | }
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
| 301 | onPageChange(event) {
|
---|
| 302 | this.first = event.first;
|
---|
| 303 | this.rows = event.rows;
|
---|
| 304 | if (this.lazy)
|
---|
| 305 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 306 | else
|
---|
| 307 | this.serializePageNodes();
|
---|
| 308 | this.onPage.emit({
|
---|
| 309 | first: this.first,
|
---|
| 310 | rows: this.rows
|
---|
| 311 | });
|
---|
| 312 | this.tableService.onUIUpdate(this.value);
|
---|
| 313 | if (this.scrollable) {
|
---|
| 314 | this.resetScrollTop();
|
---|
| 315 | }
|
---|
| 316 | }
|
---|
| 317 | sort(event) {
|
---|
| 318 | let originalEvent = event.originalEvent;
|
---|
| 319 | if (this.sortMode === 'single') {
|
---|
| 320 | this._sortOrder = (this.sortField === event.field) ? this.sortOrder * -1 : this.defaultSortOrder;
|
---|
| 321 | this._sortField = event.field;
|
---|
| 322 | this.sortSingle();
|
---|
| 323 | if (this.resetPageOnSort && this.scrollable) {
|
---|
| 324 | this.resetScrollTop();
|
---|
| 325 | }
|
---|
| 326 | }
|
---|
| 327 | if (this.sortMode === 'multiple') {
|
---|
| 328 | let metaKey = originalEvent.metaKey || originalEvent.ctrlKey;
|
---|
| 329 | let sortMeta = this.getSortMeta(event.field);
|
---|
| 330 | if (sortMeta) {
|
---|
| 331 | if (!metaKey) {
|
---|
| 332 | this._multiSortMeta = [{ field: event.field, order: sortMeta.order * -1 }];
|
---|
| 333 | if (this.resetPageOnSort && this.scrollable) {
|
---|
| 334 | this.resetScrollTop();
|
---|
| 335 | }
|
---|
| 336 | }
|
---|
| 337 | else {
|
---|
| 338 | sortMeta.order = sortMeta.order * -1;
|
---|
| 339 | }
|
---|
| 340 | }
|
---|
| 341 | else {
|
---|
| 342 | if (!metaKey || !this.multiSortMeta) {
|
---|
| 343 | this._multiSortMeta = [];
|
---|
| 344 | if (this.resetPageOnSort && this.scrollable) {
|
---|
| 345 | this.resetScrollTop();
|
---|
| 346 | }
|
---|
| 347 | }
|
---|
| 348 | this.multiSortMeta.push({ field: event.field, order: this.defaultSortOrder });
|
---|
| 349 | }
|
---|
| 350 | this.sortMultiple();
|
---|
| 351 | }
|
---|
| 352 | }
|
---|
| 353 | sortSingle() {
|
---|
| 354 | if (this.sortField && this.sortOrder) {
|
---|
| 355 | if (this.lazy) {
|
---|
| 356 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 357 | }
|
---|
| 358 | else if (this.value) {
|
---|
| 359 | this.sortNodes(this.value);
|
---|
| 360 | if (this.hasFilter()) {
|
---|
| 361 | this._filter();
|
---|
| 362 | }
|
---|
| 363 | }
|
---|
| 364 | let sortMeta = {
|
---|
| 365 | field: this.sortField,
|
---|
| 366 | order: this.sortOrder
|
---|
| 367 | };
|
---|
| 368 | this.onSort.emit(sortMeta);
|
---|
| 369 | this.tableService.onSort(sortMeta);
|
---|
| 370 | this.updateSerializedValue();
|
---|
| 371 | }
|
---|
| 372 | }
|
---|
| 373 | sortNodes(nodes) {
|
---|
| 374 | if (!nodes || nodes.length === 0) {
|
---|
| 375 | return;
|
---|
| 376 | }
|
---|
| 377 | if (this.customSort) {
|
---|
| 378 | this.sortFunction.emit({
|
---|
| 379 | data: nodes,
|
---|
| 380 | mode: this.sortMode,
|
---|
| 381 | field: this.sortField,
|
---|
| 382 | order: this.sortOrder
|
---|
| 383 | });
|
---|
| 384 | }
|
---|
| 385 | else {
|
---|
| 386 | nodes.sort((node1, node2) => {
|
---|
| 387 | let value1 = ObjectUtils.resolveFieldData(node1.data, this.sortField);
|
---|
| 388 | let value2 = ObjectUtils.resolveFieldData(node2.data, this.sortField);
|
---|
| 389 | let result = null;
|
---|
| 390 | if (value1 == null && value2 != null)
|
---|
| 391 | result = -1;
|
---|
| 392 | else if (value1 != null && value2 == null)
|
---|
| 393 | result = 1;
|
---|
| 394 | else if (value1 == null && value2 == null)
|
---|
| 395 | result = 0;
|
---|
| 396 | else if (typeof value1 === 'string' && typeof value2 === 'string')
|
---|
| 397 | result = value1.localeCompare(value2, undefined, { numeric: true });
|
---|
| 398 | else
|
---|
| 399 | result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;
|
---|
| 400 | return (this.sortOrder * result);
|
---|
| 401 | });
|
---|
| 402 | }
|
---|
| 403 | for (let node of nodes) {
|
---|
| 404 | this.sortNodes(node.children);
|
---|
| 405 | }
|
---|
| 406 | }
|
---|
| 407 | sortMultiple() {
|
---|
| 408 | if (this.multiSortMeta) {
|
---|
| 409 | if (this.lazy) {
|
---|
| 410 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 411 | }
|
---|
| 412 | else if (this.value) {
|
---|
| 413 | this.sortMultipleNodes(this.value);
|
---|
| 414 | if (this.hasFilter()) {
|
---|
| 415 | this._filter();
|
---|
| 416 | }
|
---|
| 417 | }
|
---|
| 418 | this.onSort.emit({
|
---|
| 419 | multisortmeta: this.multiSortMeta
|
---|
| 420 | });
|
---|
| 421 | this.updateSerializedValue();
|
---|
| 422 | this.tableService.onSort(this.multiSortMeta);
|
---|
| 423 | }
|
---|
| 424 | }
|
---|
| 425 | sortMultipleNodes(nodes) {
|
---|
| 426 | if (!nodes || nodes.length === 0) {
|
---|
| 427 | return;
|
---|
| 428 | }
|
---|
| 429 | if (this.customSort) {
|
---|
| 430 | this.sortFunction.emit({
|
---|
| 431 | data: this.value,
|
---|
| 432 | mode: this.sortMode,
|
---|
| 433 | multiSortMeta: this.multiSortMeta
|
---|
| 434 | });
|
---|
| 435 | }
|
---|
| 436 | else {
|
---|
| 437 | nodes.sort((node1, node2) => {
|
---|
| 438 | return this.multisortField(node1, node2, this.multiSortMeta, 0);
|
---|
| 439 | });
|
---|
| 440 | }
|
---|
| 441 | for (let node of nodes) {
|
---|
| 442 | this.sortMultipleNodes(node.children);
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | multisortField(node1, node2, multiSortMeta, index) {
|
---|
| 446 | let value1 = ObjectUtils.resolveFieldData(node1.data, multiSortMeta[index].field);
|
---|
| 447 | let value2 = ObjectUtils.resolveFieldData(node2.data, multiSortMeta[index].field);
|
---|
| 448 | let result = null;
|
---|
| 449 | if (value1 == null && value2 != null)
|
---|
| 450 | result = -1;
|
---|
| 451 | else if (value1 != null && value2 == null)
|
---|
| 452 | result = 1;
|
---|
| 453 | else if (value1 == null && value2 == null)
|
---|
| 454 | result = 0;
|
---|
| 455 | if (typeof value1 == 'string' || value1 instanceof String) {
|
---|
| 456 | if (value1.localeCompare && (value1 != value2)) {
|
---|
| 457 | return (multiSortMeta[index].order * value1.localeCompare(value2, undefined, { numeric: true }));
|
---|
| 458 | }
|
---|
| 459 | }
|
---|
| 460 | else {
|
---|
| 461 | result = (value1 < value2) ? -1 : 1;
|
---|
| 462 | }
|
---|
| 463 | if (value1 == value2) {
|
---|
| 464 | return (multiSortMeta.length - 1) > (index) ? (this.multisortField(node1, node2, multiSortMeta, index + 1)) : 0;
|
---|
| 465 | }
|
---|
| 466 | return (multiSortMeta[index].order * result);
|
---|
| 467 | }
|
---|
| 468 | getSortMeta(field) {
|
---|
| 469 | if (this.multiSortMeta && this.multiSortMeta.length) {
|
---|
| 470 | for (let i = 0; i < this.multiSortMeta.length; i++) {
|
---|
| 471 | if (this.multiSortMeta[i].field === field) {
|
---|
| 472 | return this.multiSortMeta[i];
|
---|
| 473 | }
|
---|
| 474 | }
|
---|
| 475 | }
|
---|
| 476 | return null;
|
---|
| 477 | }
|
---|
| 478 | isSorted(field) {
|
---|
| 479 | if (this.sortMode === 'single') {
|
---|
| 480 | return (this.sortField && this.sortField === field);
|
---|
| 481 | }
|
---|
| 482 | else if (this.sortMode === 'multiple') {
|
---|
| 483 | let sorted = false;
|
---|
| 484 | if (this.multiSortMeta) {
|
---|
| 485 | for (let i = 0; i < this.multiSortMeta.length; i++) {
|
---|
| 486 | if (this.multiSortMeta[i].field == field) {
|
---|
| 487 | sorted = true;
|
---|
| 488 | break;
|
---|
| 489 | }
|
---|
| 490 | }
|
---|
| 491 | }
|
---|
| 492 | return sorted;
|
---|
| 493 | }
|
---|
| 494 | }
|
---|
| 495 | createLazyLoadMetadata() {
|
---|
| 496 | return {
|
---|
| 497 | first: this.first,
|
---|
| 498 | rows: this.rows,
|
---|
| 499 | sortField: this.sortField,
|
---|
| 500 | sortOrder: this.sortOrder,
|
---|
| 501 | filters: this.filters,
|
---|
| 502 | globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null,
|
---|
| 503 | multiSortMeta: this.multiSortMeta
|
---|
| 504 | };
|
---|
| 505 | }
|
---|
| 506 | resetScrollTop() {
|
---|
| 507 | if (this.virtualScroll)
|
---|
| 508 | this.scrollToVirtualIndex(0);
|
---|
| 509 | else
|
---|
| 510 | this.scrollTo({ top: 0 });
|
---|
| 511 | }
|
---|
| 512 | scrollToVirtualIndex(index) {
|
---|
| 513 | if (this.scrollableViewChild) {
|
---|
| 514 | this.scrollableViewChild.scrollToVirtualIndex(index);
|
---|
| 515 | }
|
---|
| 516 | if (this.scrollableFrozenViewChild) {
|
---|
| 517 | this.scrollableFrozenViewChild.scrollToVirtualIndex(index);
|
---|
| 518 | }
|
---|
| 519 | }
|
---|
| 520 | scrollTo(options) {
|
---|
| 521 | if (this.scrollableViewChild) {
|
---|
| 522 | this.scrollableViewChild.scrollTo(options);
|
---|
| 523 | }
|
---|
| 524 | if (this.scrollableFrozenViewChild) {
|
---|
| 525 | this.scrollableFrozenViewChild.scrollTo(options);
|
---|
| 526 | }
|
---|
| 527 | }
|
---|
| 528 | isEmpty() {
|
---|
| 529 | let data = this.filteredNodes || this.value;
|
---|
| 530 | return data == null || data.length == 0;
|
---|
| 531 | }
|
---|
| 532 | getBlockableElement() {
|
---|
| 533 | return this.el.nativeElement.children[0];
|
---|
| 534 | }
|
---|
| 535 | onColumnResizeBegin(event) {
|
---|
| 536 | let containerLeft = DomHandler.getOffset(this.containerViewChild.nativeElement).left;
|
---|
| 537 | this.lastResizerHelperX = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft);
|
---|
| 538 | event.preventDefault();
|
---|
| 539 | }
|
---|
| 540 | onColumnResize(event) {
|
---|
| 541 | let containerLeft = DomHandler.getOffset(this.containerViewChild.nativeElement).left;
|
---|
| 542 | DomHandler.addClass(this.containerViewChild.nativeElement, 'p-unselectable-text');
|
---|
| 543 | this.resizeHelperViewChild.nativeElement.style.height = this.containerViewChild.nativeElement.offsetHeight + 'px';
|
---|
| 544 | this.resizeHelperViewChild.nativeElement.style.top = 0 + 'px';
|
---|
| 545 | this.resizeHelperViewChild.nativeElement.style.left = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft) + 'px';
|
---|
| 546 | this.resizeHelperViewChild.nativeElement.style.display = 'block';
|
---|
| 547 | }
|
---|
| 548 | onColumnResizeEnd(event, column) {
|
---|
| 549 | let delta = this.resizeHelperViewChild.nativeElement.offsetLeft - this.lastResizerHelperX;
|
---|
| 550 | let columnWidth = column.offsetWidth;
|
---|
| 551 | let newColumnWidth = columnWidth + delta;
|
---|
| 552 | let minWidth = column.style.minWidth || 15;
|
---|
| 553 | if (columnWidth + delta > parseInt(minWidth)) {
|
---|
| 554 | if (this.columnResizeMode === 'fit') {
|
---|
| 555 | let nextColumn = column.nextElementSibling;
|
---|
| 556 | while (!nextColumn.offsetParent) {
|
---|
| 557 | nextColumn = nextColumn.nextElementSibling;
|
---|
| 558 | }
|
---|
| 559 | if (nextColumn) {
|
---|
| 560 | let nextColumnWidth = nextColumn.offsetWidth - delta;
|
---|
| 561 | let nextColumnMinWidth = nextColumn.style.minWidth || 15;
|
---|
| 562 | if (newColumnWidth > 15 && nextColumnWidth > parseInt(nextColumnMinWidth)) {
|
---|
| 563 | if (this.scrollable) {
|
---|
| 564 | let scrollableView = this.findParentScrollableView(column);
|
---|
| 565 | let scrollableBodyTable = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-body table') || DomHandler.findSingle(scrollableView, '.p-treetable-virtual-scrollable-body table');
|
---|
| 566 | let scrollableHeaderTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-header-table');
|
---|
| 567 | let scrollableFooterTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-footer-table');
|
---|
| 568 | let resizeColumnIndex = DomHandler.index(column);
|
---|
| 569 | this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
|
---|
| 570 | this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
|
---|
| 571 | this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
|
---|
| 572 | }
|
---|
| 573 | else {
|
---|
| 574 | column.style.width = newColumnWidth + 'px';
|
---|
| 575 | if (nextColumn) {
|
---|
| 576 | nextColumn.style.width = nextColumnWidth + 'px';
|
---|
| 577 | }
|
---|
| 578 | }
|
---|
| 579 | }
|
---|
| 580 | }
|
---|
| 581 | }
|
---|
| 582 | else if (this.columnResizeMode === 'expand') {
|
---|
| 583 | if (this.scrollable) {
|
---|
| 584 | let scrollableView = this.findParentScrollableView(column);
|
---|
| 585 | let scrollableBody = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-body') || DomHandler.findSingle(scrollableView, 'cdk-virtual-scroll-viewport');
|
---|
| 586 | let scrollableHeader = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-header');
|
---|
| 587 | let scrollableFooter = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-footer');
|
---|
| 588 | let scrollableBodyTable = DomHandler.findSingle(scrollableView, '.p-treetable-scrollable-body table') || DomHandler.findSingle(scrollableView, 'cdk-virtual-scroll-viewport table');
|
---|
| 589 | let scrollableHeaderTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-header-table');
|
---|
| 590 | let scrollableFooterTable = DomHandler.findSingle(scrollableView, 'table.p-treetable-scrollable-footer-table');
|
---|
| 591 | scrollableBodyTable.style.width = scrollableBodyTable.offsetWidth + delta + 'px';
|
---|
| 592 | scrollableHeaderTable.style.width = scrollableHeaderTable.offsetWidth + delta + 'px';
|
---|
| 593 | if (scrollableFooterTable) {
|
---|
| 594 | scrollableFooterTable.style.width = scrollableFooterTable.offsetWidth + delta + 'px';
|
---|
| 595 | }
|
---|
| 596 | let resizeColumnIndex = DomHandler.index(column);
|
---|
| 597 | const scrollableBodyTableWidth = column ? scrollableBodyTable.offsetWidth + delta : newColumnWidth;
|
---|
| 598 | const scrollableHeaderTableWidth = column ? scrollableHeaderTable.offsetWidth + delta : newColumnWidth;
|
---|
| 599 | const isContainerInViewport = this.containerViewChild.nativeElement.offsetWidth >= scrollableBodyTableWidth;
|
---|
| 600 | let setWidth = (container, table, width, isContainerInViewport) => {
|
---|
| 601 | if (container && table) {
|
---|
| 602 | container.style.width = isContainerInViewport ? width + DomHandler.calculateScrollbarWidth(scrollableBody) + 'px' : 'auto';
|
---|
| 603 | table.style.width = width + 'px';
|
---|
| 604 | }
|
---|
| 605 | };
|
---|
| 606 | setWidth(scrollableBody, scrollableBodyTable, scrollableBodyTableWidth, isContainerInViewport);
|
---|
| 607 | setWidth(scrollableHeader, scrollableHeaderTable, scrollableHeaderTableWidth, isContainerInViewport);
|
---|
| 608 | setWidth(scrollableFooter, scrollableFooterTable, scrollableHeaderTableWidth, isContainerInViewport);
|
---|
| 609 | this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, null);
|
---|
| 610 | this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, null);
|
---|
| 611 | this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, null);
|
---|
| 612 | }
|
---|
| 613 | else {
|
---|
| 614 | this.tableViewChild.nativeElement.style.width = this.tableViewChild.nativeElement.offsetWidth + delta + 'px';
|
---|
| 615 | column.style.width = newColumnWidth + 'px';
|
---|
| 616 | let containerWidth = this.tableViewChild.nativeElement.style.width;
|
---|
| 617 | this.containerViewChild.nativeElement.style.width = containerWidth + 'px';
|
---|
| 618 | }
|
---|
| 619 | }
|
---|
| 620 | this.onColResize.emit({
|
---|
| 621 | element: column,
|
---|
| 622 | delta: delta
|
---|
| 623 | });
|
---|
| 624 | }
|
---|
| 625 | this.resizeHelperViewChild.nativeElement.style.display = 'none';
|
---|
| 626 | DomHandler.removeClass(this.containerViewChild.nativeElement, 'p-unselectable-text');
|
---|
| 627 | }
|
---|
| 628 | findParentScrollableView(column) {
|
---|
| 629 | if (column) {
|
---|
| 630 | let parent = column.parentElement;
|
---|
| 631 | while (parent && !DomHandler.hasClass(parent, 'p-treetable-scrollable-view')) {
|
---|
| 632 | parent = parent.parentElement;
|
---|
| 633 | }
|
---|
| 634 | return parent;
|
---|
| 635 | }
|
---|
| 636 | else {
|
---|
| 637 | return null;
|
---|
| 638 | }
|
---|
| 639 | }
|
---|
| 640 | resizeColGroup(table, resizeColumnIndex, newColumnWidth, nextColumnWidth) {
|
---|
| 641 | if (table) {
|
---|
| 642 | let colGroup = table.children[0].nodeName === 'COLGROUP' ? table.children[0] : null;
|
---|
| 643 | if (colGroup) {
|
---|
| 644 | let col = colGroup.children[resizeColumnIndex];
|
---|
| 645 | let nextCol = col.nextElementSibling;
|
---|
| 646 | col.style.width = newColumnWidth + 'px';
|
---|
| 647 | if (nextCol && nextColumnWidth) {
|
---|
| 648 | nextCol.style.width = nextColumnWidth + 'px';
|
---|
| 649 | }
|
---|
| 650 | }
|
---|
| 651 | else {
|
---|
| 652 | throw "Scrollable tables require a colgroup to support resizable columns";
|
---|
| 653 | }
|
---|
| 654 | }
|
---|
| 655 | }
|
---|
| 656 | onColumnDragStart(event, columnElement) {
|
---|
| 657 | this.reorderIconWidth = DomHandler.getHiddenElementOuterWidth(this.reorderIndicatorUpViewChild.nativeElement);
|
---|
| 658 | this.reorderIconHeight = DomHandler.getHiddenElementOuterHeight(this.reorderIndicatorDownViewChild.nativeElement);
|
---|
| 659 | this.draggedColumn = columnElement;
|
---|
| 660 | event.dataTransfer.setData('text', 'b'); // For firefox
|
---|
| 661 | }
|
---|
| 662 | onColumnDragEnter(event, dropHeader) {
|
---|
| 663 | if (this.reorderableColumns && this.draggedColumn && dropHeader) {
|
---|
| 664 | event.preventDefault();
|
---|
| 665 | let containerOffset = DomHandler.getOffset(this.containerViewChild.nativeElement);
|
---|
| 666 | let dropHeaderOffset = DomHandler.getOffset(dropHeader);
|
---|
| 667 | if (this.draggedColumn != dropHeader) {
|
---|
| 668 | let targetLeft = dropHeaderOffset.left - containerOffset.left;
|
---|
| 669 | let targetTop = containerOffset.top - dropHeaderOffset.top;
|
---|
| 670 | let columnCenter = dropHeaderOffset.left + dropHeader.offsetWidth / 2;
|
---|
| 671 | this.reorderIndicatorUpViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top - (this.reorderIconHeight - 1) + 'px';
|
---|
| 672 | this.reorderIndicatorDownViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top + dropHeader.offsetHeight + 'px';
|
---|
| 673 | if (event.pageX > columnCenter) {
|
---|
| 674 | this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 675 | this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 676 | this.dropPosition = 1;
|
---|
| 677 | }
|
---|
| 678 | else {
|
---|
| 679 | this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 680 | this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 681 | this.dropPosition = -1;
|
---|
| 682 | }
|
---|
| 683 | this.reorderIndicatorUpViewChild.nativeElement.style.display = 'block';
|
---|
| 684 | this.reorderIndicatorDownViewChild.nativeElement.style.display = 'block';
|
---|
| 685 | }
|
---|
| 686 | else {
|
---|
| 687 | event.dataTransfer.dropEffect = 'none';
|
---|
| 688 | }
|
---|
| 689 | }
|
---|
| 690 | }
|
---|
| 691 | onColumnDragLeave(event) {
|
---|
| 692 | if (this.reorderableColumns && this.draggedColumn) {
|
---|
| 693 | event.preventDefault();
|
---|
| 694 | this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
|
---|
| 695 | this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
|
---|
| 696 | }
|
---|
| 697 | }
|
---|
| 698 | onColumnDrop(event, dropColumn) {
|
---|
| 699 | event.preventDefault();
|
---|
| 700 | if (this.draggedColumn) {
|
---|
| 701 | let dragIndex = DomHandler.indexWithinGroup(this.draggedColumn, 'ttreorderablecolumn');
|
---|
| 702 | let dropIndex = DomHandler.indexWithinGroup(dropColumn, 'ttreorderablecolumn');
|
---|
| 703 | let allowDrop = (dragIndex != dropIndex);
|
---|
| 704 | if (allowDrop && ((dropIndex - dragIndex == 1 && this.dropPosition === -1) || (dragIndex - dropIndex == 1 && this.dropPosition === 1))) {
|
---|
| 705 | allowDrop = false;
|
---|
| 706 | }
|
---|
| 707 | if (allowDrop && ((dropIndex < dragIndex && this.dropPosition === 1))) {
|
---|
| 708 | dropIndex = dropIndex + 1;
|
---|
| 709 | }
|
---|
| 710 | if (allowDrop && ((dropIndex > dragIndex && this.dropPosition === -1))) {
|
---|
| 711 | dropIndex = dropIndex - 1;
|
---|
| 712 | }
|
---|
| 713 | if (allowDrop) {
|
---|
| 714 | ObjectUtils.reorderArray(this.columns, dragIndex, dropIndex);
|
---|
| 715 | this.onColReorder.emit({
|
---|
| 716 | dragIndex: dragIndex,
|
---|
| 717 | dropIndex: dropIndex,
|
---|
| 718 | columns: this.columns
|
---|
| 719 | });
|
---|
| 720 | }
|
---|
| 721 | this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
|
---|
| 722 | this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
|
---|
| 723 | this.draggedColumn.draggable = false;
|
---|
| 724 | this.draggedColumn = null;
|
---|
| 725 | this.dropPosition = null;
|
---|
| 726 | }
|
---|
| 727 | }
|
---|
| 728 | handleRowClick(event) {
|
---|
| 729 | let targetNode = event.originalEvent.target.nodeName;
|
---|
| 730 | if (targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A' || (DomHandler.hasClass(event.originalEvent.target, 'p-clickable'))) {
|
---|
| 731 | return;
|
---|
| 732 | }
|
---|
| 733 | if (this.selectionMode) {
|
---|
| 734 | this.preventSelectionSetterPropagation = true;
|
---|
| 735 | let rowNode = event.rowNode;
|
---|
| 736 | let selected = this.isSelected(rowNode.node);
|
---|
| 737 | let metaSelection = this.rowTouched ? false : this.metaKeySelection;
|
---|
| 738 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(rowNode.node.data, this.dataKey)) : null;
|
---|
| 739 | if (metaSelection) {
|
---|
| 740 | let metaKey = event.originalEvent.metaKey || event.originalEvent.ctrlKey;
|
---|
| 741 | if (selected && metaKey) {
|
---|
| 742 | if (this.isSingleSelectionMode()) {
|
---|
| 743 | this._selection = null;
|
---|
| 744 | this.selectionKeys = {};
|
---|
| 745 | this.selectionChange.emit(null);
|
---|
| 746 | }
|
---|
| 747 | else {
|
---|
| 748 | let selectionIndex = this.findIndexInSelection(rowNode.node);
|
---|
| 749 | this._selection = this.selection.filter((val, i) => i != selectionIndex);
|
---|
| 750 | this.selectionChange.emit(this.selection);
|
---|
| 751 | if (dataKeyValue) {
|
---|
| 752 | delete this.selectionKeys[dataKeyValue];
|
---|
| 753 | }
|
---|
| 754 | }
|
---|
| 755 | this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' });
|
---|
| 756 | }
|
---|
| 757 | else {
|
---|
| 758 | if (this.isSingleSelectionMode()) {
|
---|
| 759 | this._selection = rowNode.node;
|
---|
| 760 | this.selectionChange.emit(rowNode.node);
|
---|
| 761 | if (dataKeyValue) {
|
---|
| 762 | this.selectionKeys = {};
|
---|
| 763 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 764 | }
|
---|
| 765 | }
|
---|
| 766 | else if (this.isMultipleSelectionMode()) {
|
---|
| 767 | if (metaKey) {
|
---|
| 768 | this._selection = this.selection || [];
|
---|
| 769 | }
|
---|
| 770 | else {
|
---|
| 771 | this._selection = [];
|
---|
| 772 | this.selectionKeys = {};
|
---|
| 773 | }
|
---|
| 774 | this._selection = [...this.selection, rowNode.node];
|
---|
| 775 | this.selectionChange.emit(this.selection);
|
---|
| 776 | if (dataKeyValue) {
|
---|
| 777 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 778 | }
|
---|
| 779 | }
|
---|
| 780 | this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex });
|
---|
| 781 | }
|
---|
| 782 | }
|
---|
| 783 | else {
|
---|
| 784 | if (this.selectionMode === 'single') {
|
---|
| 785 | if (selected) {
|
---|
| 786 | this._selection = null;
|
---|
| 787 | this.selectionKeys = {};
|
---|
| 788 | this.selectionChange.emit(this.selection);
|
---|
| 789 | this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' });
|
---|
| 790 | }
|
---|
| 791 | else {
|
---|
| 792 | this._selection = rowNode.node;
|
---|
| 793 | this.selectionChange.emit(this.selection);
|
---|
| 794 | this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex });
|
---|
| 795 | if (dataKeyValue) {
|
---|
| 796 | this.selectionKeys = {};
|
---|
| 797 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 798 | }
|
---|
| 799 | }
|
---|
| 800 | }
|
---|
| 801 | else if (this.selectionMode === 'multiple') {
|
---|
| 802 | if (selected) {
|
---|
| 803 | let selectionIndex = this.findIndexInSelection(rowNode.node);
|
---|
| 804 | this._selection = this.selection.filter((val, i) => i != selectionIndex);
|
---|
| 805 | this.selectionChange.emit(this.selection);
|
---|
| 806 | this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' });
|
---|
| 807 | if (dataKeyValue) {
|
---|
| 808 | delete this.selectionKeys[dataKeyValue];
|
---|
| 809 | }
|
---|
| 810 | }
|
---|
| 811 | else {
|
---|
| 812 | this._selection = this.selection ? [...this.selection, rowNode.node] : [rowNode.node];
|
---|
| 813 | this.selectionChange.emit(this.selection);
|
---|
| 814 | this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex });
|
---|
| 815 | if (dataKeyValue) {
|
---|
| 816 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 817 | }
|
---|
| 818 | }
|
---|
| 819 | }
|
---|
| 820 | }
|
---|
| 821 | this.tableService.onSelectionChange();
|
---|
| 822 | }
|
---|
| 823 | this.rowTouched = false;
|
---|
| 824 | }
|
---|
| 825 | handleRowTouchEnd(event) {
|
---|
| 826 | this.rowTouched = true;
|
---|
| 827 | }
|
---|
| 828 | handleRowRightClick(event) {
|
---|
| 829 | if (this.contextMenu) {
|
---|
| 830 | const node = event.rowNode.node;
|
---|
| 831 | if (this.contextMenuSelectionMode === 'separate') {
|
---|
| 832 | this.contextMenuSelection = node;
|
---|
| 833 | this.contextMenuSelectionChange.emit(node);
|
---|
| 834 | this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, node: node });
|
---|
| 835 | this.contextMenu.show(event.originalEvent);
|
---|
| 836 | this.tableService.onContextMenu(node);
|
---|
| 837 | }
|
---|
| 838 | else if (this.contextMenuSelectionMode === 'joint') {
|
---|
| 839 | this.preventSelectionSetterPropagation = true;
|
---|
| 840 | let selected = this.isSelected(node);
|
---|
| 841 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null;
|
---|
| 842 | if (!selected) {
|
---|
| 843 | if (this.isSingleSelectionMode()) {
|
---|
| 844 | this.selection = node;
|
---|
| 845 | this.selectionChange.emit(node);
|
---|
| 846 | }
|
---|
| 847 | else if (this.isMultipleSelectionMode()) {
|
---|
| 848 | this.selection = [node];
|
---|
| 849 | this.selectionChange.emit(this.selection);
|
---|
| 850 | }
|
---|
| 851 | if (dataKeyValue) {
|
---|
| 852 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 853 | }
|
---|
| 854 | }
|
---|
| 855 | this.contextMenu.show(event.originalEvent);
|
---|
| 856 | this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, node: node });
|
---|
| 857 | }
|
---|
| 858 | }
|
---|
| 859 | }
|
---|
| 860 | toggleNodeWithCheckbox(event) {
|
---|
| 861 | this.selection = this.selection || [];
|
---|
| 862 | this.preventSelectionSetterPropagation = true;
|
---|
| 863 | let node = event.rowNode.node;
|
---|
| 864 | let selected = this.isSelected(node);
|
---|
| 865 | if (selected) {
|
---|
| 866 | this.propagateSelectionDown(node, false);
|
---|
| 867 | if (event.rowNode.parent) {
|
---|
| 868 | this.propagateSelectionUp(node.parent, false);
|
---|
| 869 | }
|
---|
| 870 | this.selectionChange.emit(this.selection);
|
---|
| 871 | this.onNodeUnselect.emit({ originalEvent: event, node: node });
|
---|
| 872 | }
|
---|
| 873 | else {
|
---|
| 874 | this.propagateSelectionDown(node, true);
|
---|
| 875 | if (event.rowNode.parent) {
|
---|
| 876 | this.propagateSelectionUp(node.parent, true);
|
---|
| 877 | }
|
---|
| 878 | this.selectionChange.emit(this.selection);
|
---|
| 879 | this.onNodeSelect.emit({ originalEvent: event, node: node });
|
---|
| 880 | }
|
---|
| 881 | this.tableService.onSelectionChange();
|
---|
| 882 | }
|
---|
| 883 | toggleNodesWithCheckbox(event, check) {
|
---|
| 884 | let data = this.filteredNodes || this.value;
|
---|
| 885 | this._selection = check && data ? data.slice() : [];
|
---|
| 886 | if (check) {
|
---|
| 887 | if (data && data.length) {
|
---|
| 888 | for (let node of data) {
|
---|
| 889 | this.propagateSelectionDown(node, true);
|
---|
| 890 | }
|
---|
| 891 | }
|
---|
| 892 | }
|
---|
| 893 | else {
|
---|
| 894 | this._selection = [];
|
---|
| 895 | this.selectionKeys = {};
|
---|
| 896 | }
|
---|
| 897 | this.preventSelectionSetterPropagation = true;
|
---|
| 898 | this.selectionChange.emit(this._selection);
|
---|
| 899 | this.tableService.onSelectionChange();
|
---|
| 900 | this.onHeaderCheckboxToggle.emit({ originalEvent: event, checked: check });
|
---|
| 901 | }
|
---|
| 902 | propagateSelectionUp(node, select) {
|
---|
| 903 | if (node.children && node.children.length) {
|
---|
| 904 | let selectedChildCount = 0;
|
---|
| 905 | let childPartialSelected = false;
|
---|
| 906 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null;
|
---|
| 907 | for (let child of node.children) {
|
---|
| 908 | if (this.isSelected(child))
|
---|
| 909 | selectedChildCount++;
|
---|
| 910 | else if (child.partialSelected)
|
---|
| 911 | childPartialSelected = true;
|
---|
| 912 | }
|
---|
| 913 | if (select && selectedChildCount == node.children.length) {
|
---|
| 914 | this._selection = [...this.selection || [], node];
|
---|
| 915 | node.partialSelected = false;
|
---|
| 916 | if (dataKeyValue) {
|
---|
| 917 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 918 | }
|
---|
| 919 | }
|
---|
| 920 | else {
|
---|
| 921 | if (!select) {
|
---|
| 922 | let index = this.findIndexInSelection(node);
|
---|
| 923 | if (index >= 0) {
|
---|
| 924 | this._selection = this.selection.filter((val, i) => i != index);
|
---|
| 925 | if (dataKeyValue) {
|
---|
| 926 | delete this.selectionKeys[dataKeyValue];
|
---|
| 927 | }
|
---|
| 928 | }
|
---|
| 929 | }
|
---|
| 930 | if (childPartialSelected || selectedChildCount > 0 && selectedChildCount != node.children.length)
|
---|
| 931 | node.partialSelected = true;
|
---|
| 932 | else
|
---|
| 933 | node.partialSelected = false;
|
---|
| 934 | }
|
---|
| 935 | }
|
---|
| 936 | let parent = node.parent;
|
---|
| 937 | if (parent) {
|
---|
| 938 | this.propagateSelectionUp(parent, select);
|
---|
| 939 | }
|
---|
| 940 | }
|
---|
| 941 | propagateSelectionDown(node, select) {
|
---|
| 942 | let index = this.findIndexInSelection(node);
|
---|
| 943 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null;
|
---|
| 944 | if (select && index == -1) {
|
---|
| 945 | this._selection = [...this.selection || [], node];
|
---|
| 946 | if (dataKeyValue) {
|
---|
| 947 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 948 | }
|
---|
| 949 | }
|
---|
| 950 | else if (!select && index > -1) {
|
---|
| 951 | this._selection = this.selection.filter((val, i) => i != index);
|
---|
| 952 | if (dataKeyValue) {
|
---|
| 953 | delete this.selectionKeys[dataKeyValue];
|
---|
| 954 | }
|
---|
| 955 | }
|
---|
| 956 | node.partialSelected = false;
|
---|
| 957 | if (node.children && node.children.length) {
|
---|
| 958 | for (let child of node.children) {
|
---|
| 959 | this.propagateSelectionDown(child, select);
|
---|
| 960 | }
|
---|
| 961 | }
|
---|
| 962 | }
|
---|
| 963 | isSelected(node) {
|
---|
| 964 | if (node && this.selection) {
|
---|
| 965 | if (this.dataKey) {
|
---|
| 966 | return this.selectionKeys[ObjectUtils.resolveFieldData(node.data, this.dataKey)] !== undefined;
|
---|
| 967 | }
|
---|
| 968 | else {
|
---|
| 969 | if (this.selection instanceof Array)
|
---|
| 970 | return this.findIndexInSelection(node) > -1;
|
---|
| 971 | else
|
---|
| 972 | return this.equals(node, this.selection);
|
---|
| 973 | }
|
---|
| 974 | }
|
---|
| 975 | return false;
|
---|
| 976 | }
|
---|
| 977 | findIndexInSelection(node) {
|
---|
| 978 | let index = -1;
|
---|
| 979 | if (this.selection && this.selection.length) {
|
---|
| 980 | for (let i = 0; i < this.selection.length; i++) {
|
---|
| 981 | if (this.equals(node, this.selection[i])) {
|
---|
| 982 | index = i;
|
---|
| 983 | break;
|
---|
| 984 | }
|
---|
| 985 | }
|
---|
| 986 | }
|
---|
| 987 | return index;
|
---|
| 988 | }
|
---|
| 989 | isSingleSelectionMode() {
|
---|
| 990 | return this.selectionMode === 'single';
|
---|
| 991 | }
|
---|
| 992 | isMultipleSelectionMode() {
|
---|
| 993 | return this.selectionMode === 'multiple';
|
---|
| 994 | }
|
---|
| 995 | equals(node1, node2) {
|
---|
| 996 | return this.compareSelectionBy === 'equals' ? (node1 === node2) : ObjectUtils.equals(node1.data, node2.data, this.dataKey);
|
---|
| 997 | }
|
---|
| 998 | filter(value, field, matchMode) {
|
---|
| 999 | if (this.filterTimeout) {
|
---|
| 1000 | clearTimeout(this.filterTimeout);
|
---|
| 1001 | }
|
---|
| 1002 | if (!this.isFilterBlank(value)) {
|
---|
| 1003 | this.filters[field] = { value: value, matchMode: matchMode };
|
---|
| 1004 | }
|
---|
| 1005 | else if (this.filters[field]) {
|
---|
| 1006 | delete this.filters[field];
|
---|
| 1007 | }
|
---|
| 1008 | this.filterTimeout = setTimeout(() => {
|
---|
| 1009 | this._filter();
|
---|
| 1010 | this.filterTimeout = null;
|
---|
| 1011 | }, this.filterDelay);
|
---|
| 1012 | }
|
---|
| 1013 | filterGlobal(value, matchMode) {
|
---|
| 1014 | this.filter(value, 'global', matchMode);
|
---|
| 1015 | }
|
---|
| 1016 | isFilterBlank(filter) {
|
---|
| 1017 | if (filter !== null && filter !== undefined) {
|
---|
| 1018 | if ((typeof filter === 'string' && filter.trim().length == 0) || (filter instanceof Array && filter.length == 0))
|
---|
| 1019 | return true;
|
---|
| 1020 | else
|
---|
| 1021 | return false;
|
---|
| 1022 | }
|
---|
| 1023 | return true;
|
---|
| 1024 | }
|
---|
| 1025 | _filter() {
|
---|
| 1026 | if (this.lazy) {
|
---|
| 1027 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 1028 | }
|
---|
| 1029 | else {
|
---|
| 1030 | if (!this.value) {
|
---|
| 1031 | return;
|
---|
| 1032 | }
|
---|
| 1033 | if (!this.hasFilter()) {
|
---|
| 1034 | this.filteredNodes = null;
|
---|
| 1035 | if (this.paginator) {
|
---|
| 1036 | this.totalRecords = this.value ? this.value.length : 0;
|
---|
| 1037 | }
|
---|
| 1038 | }
|
---|
| 1039 | else {
|
---|
| 1040 | let globalFilterFieldsArray;
|
---|
| 1041 | if (this.filters['global']) {
|
---|
| 1042 | if (!this.columns && !this.globalFilterFields)
|
---|
| 1043 | throw new Error('Global filtering requires dynamic columns or globalFilterFields to be defined.');
|
---|
| 1044 | else
|
---|
| 1045 | globalFilterFieldsArray = this.globalFilterFields || this.columns;
|
---|
| 1046 | }
|
---|
| 1047 | this.filteredNodes = [];
|
---|
| 1048 | const isStrictMode = this.filterMode === 'strict';
|
---|
| 1049 | let isValueChanged = false;
|
---|
| 1050 | for (let node of this.value) {
|
---|
| 1051 | let copyNode = { ...node };
|
---|
| 1052 | let localMatch = true;
|
---|
| 1053 | let globalMatch = false;
|
---|
| 1054 | let paramsWithoutNode;
|
---|
| 1055 | for (let prop in this.filters) {
|
---|
| 1056 | if (this.filters.hasOwnProperty(prop) && prop !== 'global') {
|
---|
| 1057 | let filterMeta = this.filters[prop];
|
---|
| 1058 | let filterField = prop;
|
---|
| 1059 | let filterValue = filterMeta.value;
|
---|
| 1060 | let filterMatchMode = filterMeta.matchMode || 'startsWith';
|
---|
| 1061 | let filterConstraint = this.filterService.filters[filterMatchMode];
|
---|
| 1062 | paramsWithoutNode = { filterField, filterValue, filterConstraint, isStrictMode };
|
---|
| 1063 | if ((isStrictMode && !(this.findFilteredNodes(copyNode, paramsWithoutNode) || this.isFilterMatched(copyNode, paramsWithoutNode))) ||
|
---|
| 1064 | (!isStrictMode && !(this.isFilterMatched(copyNode, paramsWithoutNode) || this.findFilteredNodes(copyNode, paramsWithoutNode)))) {
|
---|
| 1065 | localMatch = false;
|
---|
| 1066 | }
|
---|
| 1067 | if (!localMatch) {
|
---|
| 1068 | break;
|
---|
| 1069 | }
|
---|
| 1070 | }
|
---|
| 1071 | }
|
---|
| 1072 | if (this.filters['global'] && !globalMatch && globalFilterFieldsArray) {
|
---|
| 1073 | for (let j = 0; j < globalFilterFieldsArray.length; j++) {
|
---|
| 1074 | let copyNodeForGlobal = { ...copyNode };
|
---|
| 1075 | let filterField = globalFilterFieldsArray[j].field || globalFilterFieldsArray[j];
|
---|
| 1076 | let filterValue = this.filters['global'].value;
|
---|
| 1077 | let filterConstraint = this.filterService.filters[this.filters['global'].matchMode];
|
---|
| 1078 | paramsWithoutNode = { filterField, filterValue, filterConstraint, isStrictMode };
|
---|
| 1079 | if ((isStrictMode && (this.findFilteredNodes(copyNodeForGlobal, paramsWithoutNode) || this.isFilterMatched(copyNodeForGlobal, paramsWithoutNode))) ||
|
---|
| 1080 | (!isStrictMode && (this.isFilterMatched(copyNodeForGlobal, paramsWithoutNode) || this.findFilteredNodes(copyNodeForGlobal, paramsWithoutNode)))) {
|
---|
| 1081 | globalMatch = true;
|
---|
| 1082 | copyNode = copyNodeForGlobal;
|
---|
| 1083 | }
|
---|
| 1084 | }
|
---|
| 1085 | }
|
---|
| 1086 | let matches = localMatch;
|
---|
| 1087 | if (this.filters['global']) {
|
---|
| 1088 | matches = localMatch && globalMatch;
|
---|
| 1089 | }
|
---|
| 1090 | if (matches) {
|
---|
| 1091 | this.filteredNodes.push(copyNode);
|
---|
| 1092 | }
|
---|
| 1093 | isValueChanged = isValueChanged || !localMatch || globalMatch || (localMatch && this.filteredNodes.length > 0) || (!globalMatch && this.filteredNodes.length === 0);
|
---|
| 1094 | }
|
---|
| 1095 | if (!isValueChanged) {
|
---|
| 1096 | this.filteredNodes = null;
|
---|
| 1097 | }
|
---|
| 1098 | if (this.paginator) {
|
---|
| 1099 | this.totalRecords = this.filteredNodes ? this.filteredNodes.length : this.value ? this.value.length : 0;
|
---|
| 1100 | }
|
---|
| 1101 | }
|
---|
| 1102 | }
|
---|
| 1103 | this.first = 0;
|
---|
| 1104 | const filteredValue = this.filteredNodes || this.value;
|
---|
| 1105 | this.onFilter.emit({
|
---|
| 1106 | filters: this.filters,
|
---|
| 1107 | filteredValue: filteredValue
|
---|
| 1108 | });
|
---|
| 1109 | this.tableService.onUIUpdate(filteredValue);
|
---|
| 1110 | this.updateSerializedValue();
|
---|
| 1111 | if (this.scrollable) {
|
---|
| 1112 | this.resetScrollTop();
|
---|
| 1113 | }
|
---|
| 1114 | }
|
---|
| 1115 | findFilteredNodes(node, paramsWithoutNode) {
|
---|
| 1116 | if (node) {
|
---|
| 1117 | let matched = false;
|
---|
| 1118 | if (node.children) {
|
---|
| 1119 | let childNodes = [...node.children];
|
---|
| 1120 | node.children = [];
|
---|
| 1121 | for (let childNode of childNodes) {
|
---|
| 1122 | let copyChildNode = { ...childNode };
|
---|
| 1123 | if (this.isFilterMatched(copyChildNode, paramsWithoutNode)) {
|
---|
| 1124 | matched = true;
|
---|
| 1125 | node.children.push(copyChildNode);
|
---|
| 1126 | }
|
---|
| 1127 | }
|
---|
| 1128 | }
|
---|
| 1129 | if (matched) {
|
---|
| 1130 | return true;
|
---|
| 1131 | }
|
---|
| 1132 | }
|
---|
| 1133 | }
|
---|
| 1134 | isFilterMatched(node, { filterField, filterValue, filterConstraint, isStrictMode }) {
|
---|
| 1135 | let matched = false;
|
---|
| 1136 | let dataFieldValue = ObjectUtils.resolveFieldData(node.data, filterField);
|
---|
| 1137 | if (filterConstraint(dataFieldValue, filterValue, this.filterLocale)) {
|
---|
| 1138 | matched = true;
|
---|
| 1139 | }
|
---|
| 1140 | if (!matched || (isStrictMode && !this.isNodeLeaf(node))) {
|
---|
| 1141 | matched = this.findFilteredNodes(node, { filterField, filterValue, filterConstraint, isStrictMode }) || matched;
|
---|
| 1142 | }
|
---|
| 1143 | return matched;
|
---|
| 1144 | }
|
---|
| 1145 | isNodeLeaf(node) {
|
---|
| 1146 | return node.leaf === false ? false : !(node.children && node.children.length);
|
---|
| 1147 | }
|
---|
| 1148 | hasFilter() {
|
---|
| 1149 | let empty = true;
|
---|
| 1150 | for (let prop in this.filters) {
|
---|
| 1151 | if (this.filters.hasOwnProperty(prop)) {
|
---|
| 1152 | empty = false;
|
---|
| 1153 | break;
|
---|
| 1154 | }
|
---|
| 1155 | }
|
---|
| 1156 | return !empty;
|
---|
| 1157 | }
|
---|
| 1158 | reset() {
|
---|
| 1159 | this._sortField = null;
|
---|
| 1160 | this._sortOrder = 1;
|
---|
| 1161 | this._multiSortMeta = null;
|
---|
| 1162 | this.tableService.onSort(null);
|
---|
| 1163 | this.filteredNodes = null;
|
---|
| 1164 | this.filters = {};
|
---|
| 1165 | this.first = 0;
|
---|
| 1166 | if (this.lazy) {
|
---|
| 1167 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 1168 | }
|
---|
| 1169 | else {
|
---|
| 1170 | this.totalRecords = (this._value ? this._value.length : 0);
|
---|
| 1171 | }
|
---|
| 1172 | }
|
---|
| 1173 | updateEditingCell(cell, data, field) {
|
---|
| 1174 | this.editingCell = cell;
|
---|
| 1175 | this.editingCellData = data;
|
---|
| 1176 | this.editingCellField = field;
|
---|
| 1177 | this.bindDocumentEditListener();
|
---|
| 1178 | }
|
---|
| 1179 | isEditingCellValid() {
|
---|
| 1180 | return (this.editingCell && DomHandler.find(this.editingCell, '.ng-invalid.ng-dirty').length === 0);
|
---|
| 1181 | }
|
---|
| 1182 | bindDocumentEditListener() {
|
---|
| 1183 | if (!this.documentEditListener) {
|
---|
| 1184 | this.documentEditListener = (event) => {
|
---|
| 1185 | if (this.editingCell && !this.editingCellClick && this.isEditingCellValid()) {
|
---|
| 1186 | DomHandler.removeClass(this.editingCell, 'p-cell-editing');
|
---|
| 1187 | this.editingCell = null;
|
---|
| 1188 | this.onEditComplete.emit({ field: this.editingCellField, data: this.editingCellData });
|
---|
| 1189 | this.editingCellField = null;
|
---|
| 1190 | this.editingCellData = null;
|
---|
| 1191 | this.unbindDocumentEditListener();
|
---|
| 1192 | }
|
---|
| 1193 | this.editingCellClick = false;
|
---|
| 1194 | };
|
---|
| 1195 | document.addEventListener('click', this.documentEditListener);
|
---|
| 1196 | }
|
---|
| 1197 | }
|
---|
| 1198 | unbindDocumentEditListener() {
|
---|
| 1199 | if (this.documentEditListener) {
|
---|
| 1200 | document.removeEventListener('click', this.documentEditListener);
|
---|
| 1201 | this.documentEditListener = null;
|
---|
| 1202 | }
|
---|
| 1203 | }
|
---|
| 1204 | ngOnDestroy() {
|
---|
| 1205 | this.unbindDocumentEditListener();
|
---|
| 1206 | this.editingCell = null;
|
---|
| 1207 | this.editingCellField = null;
|
---|
| 1208 | this.editingCellData = null;
|
---|
| 1209 | this.initialized = null;
|
---|
| 1210 | }
|
---|
| 1211 | }
|
---|
| 1212 | 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 });
|
---|
| 1213 | 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: `
|
---|
| 1214 | <div #container [ngStyle]="style" [class]="styleClass" data-scrollselectors=".p-treetable-scrollable-body"
|
---|
| 1215 | [ngClass]="{'p-treetable p-component': true,
|
---|
| 1216 | 'p-treetable-hoverable-rows': (rowHover||(selectionMode === 'single' || selectionMode === 'multiple')),
|
---|
| 1217 | 'p-treetable-auto-layout': autoLayout,
|
---|
| 1218 | 'p-treetable-resizable': resizableColumns,
|
---|
| 1219 | 'p-treetable-resizable-fit': (resizableColumns && columnResizeMode === 'fit'),
|
---|
| 1220 | 'p-treetable-flex-scrollable': (scrollable && scrollHeight === 'flex')}">
|
---|
| 1221 | <div class="p-treetable-loading" *ngIf="loading && showLoader">
|
---|
| 1222 | <div class="p-treetable-loading-overlay p-component-overlay">
|
---|
| 1223 | <i [class]="'p-treetable-loading-icon pi-spin ' + loadingIcon"></i>
|
---|
| 1224 | </div>
|
---|
| 1225 | </div>
|
---|
| 1226 | <div *ngIf="captionTemplate" class="p-treetable-header">
|
---|
| 1227 | <ng-container *ngTemplateOutlet="captionTemplate"></ng-container>
|
---|
| 1228 | </div>
|
---|
| 1229 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-top" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1230 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'top' || paginatorPosition =='both')"
|
---|
| 1231 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo"
|
---|
| 1232 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1233 |
|
---|
| 1234 | <div class="p-treetable-wrapper" *ngIf="!scrollable">
|
---|
| 1235 | <table #table [ngClass]="tableStyleClass" [ngStyle]="tableStyle">
|
---|
| 1236 | <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1237 | <thead class="p-treetable-thead">
|
---|
| 1238 | <ng-container *ngTemplateOutlet="headerTemplate; context: {$implicit: columns}"></ng-container>
|
---|
| 1239 | </thead>
|
---|
| 1240 | <tbody class="p-treetable-tbody" [pTreeTableBody]="columns" [pTreeTableBodyTemplate]="bodyTemplate"></tbody>
|
---|
| 1241 | <tfoot class="p-treetable-tfoot">
|
---|
| 1242 | <ng-container *ngTemplateOutlet="footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1243 | </tfoot>
|
---|
| 1244 | </table>
|
---|
| 1245 | </div>
|
---|
| 1246 |
|
---|
| 1247 | <div class="p-treetable-scrollable-wrapper" *ngIf="scrollable">
|
---|
| 1248 | <div class="p-treetable-scrollable-view p-treetable-frozen-view" *ngIf="frozenColumns||frozenBodyTemplate" #scrollableFrozenView [ttScrollableView]="frozenColumns" [frozen]="true" [ngStyle]="{width: frozenWidth}" [scrollHeight]="scrollHeight"></div>
|
---|
| 1249 | <div class="p-treetable-scrollable-view" #scrollableView [ttScrollableView]="columns" [frozen]="false" [scrollHeight]="scrollHeight" [ngStyle]="{left: frozenWidth, width: 'calc(100% - '+frozenWidth+')'}"></div>
|
---|
| 1250 | </div>
|
---|
| 1251 |
|
---|
| 1252 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-bottom" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1253 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'bottom' || paginatorPosition =='both')"
|
---|
| 1254 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo"
|
---|
| 1255 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1256 | <div *ngIf="summaryTemplate" class="p-treetable-footer">
|
---|
| 1257 | <ng-container *ngTemplateOutlet="summaryTemplate"></ng-container>
|
---|
| 1258 | </div>
|
---|
| 1259 |
|
---|
| 1260 | <div #resizeHelper class="p-column-resizer-helper" style="display:none" *ngIf="resizableColumns"></div>
|
---|
| 1261 |
|
---|
| 1262 | <span #reorderIndicatorUp class="pi pi-arrow-down p-treetable-reorder-indicator-up" *ngIf="reorderableColumns"></span>
|
---|
| 1263 | <span #reorderIndicatorDown class="pi pi-arrow-up p-treetable-reorder-indicator-down" *ngIf="reorderableColumns"></span>
|
---|
| 1264 | </div>
|
---|
| 1265 | `, 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 });
|
---|
| 1266 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTable, decorators: [{
|
---|
| 1267 | type: Component,
|
---|
| 1268 | args: [{ selector: 'p-treeTable', template: `
|
---|
| 1269 | <div #container [ngStyle]="style" [class]="styleClass" data-scrollselectors=".p-treetable-scrollable-body"
|
---|
| 1270 | [ngClass]="{'p-treetable p-component': true,
|
---|
| 1271 | 'p-treetable-hoverable-rows': (rowHover||(selectionMode === 'single' || selectionMode === 'multiple')),
|
---|
| 1272 | 'p-treetable-auto-layout': autoLayout,
|
---|
| 1273 | 'p-treetable-resizable': resizableColumns,
|
---|
| 1274 | 'p-treetable-resizable-fit': (resizableColumns && columnResizeMode === 'fit'),
|
---|
| 1275 | 'p-treetable-flex-scrollable': (scrollable && scrollHeight === 'flex')}">
|
---|
| 1276 | <div class="p-treetable-loading" *ngIf="loading && showLoader">
|
---|
| 1277 | <div class="p-treetable-loading-overlay p-component-overlay">
|
---|
| 1278 | <i [class]="'p-treetable-loading-icon pi-spin ' + loadingIcon"></i>
|
---|
| 1279 | </div>
|
---|
| 1280 | </div>
|
---|
| 1281 | <div *ngIf="captionTemplate" class="p-treetable-header">
|
---|
| 1282 | <ng-container *ngTemplateOutlet="captionTemplate"></ng-container>
|
---|
| 1283 | </div>
|
---|
| 1284 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-top" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1285 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'top' || paginatorPosition =='both')"
|
---|
| 1286 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo"
|
---|
| 1287 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1288 |
|
---|
| 1289 | <div class="p-treetable-wrapper" *ngIf="!scrollable">
|
---|
| 1290 | <table #table [ngClass]="tableStyleClass" [ngStyle]="tableStyle">
|
---|
| 1291 | <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1292 | <thead class="p-treetable-thead">
|
---|
| 1293 | <ng-container *ngTemplateOutlet="headerTemplate; context: {$implicit: columns}"></ng-container>
|
---|
| 1294 | </thead>
|
---|
| 1295 | <tbody class="p-treetable-tbody" [pTreeTableBody]="columns" [pTreeTableBodyTemplate]="bodyTemplate"></tbody>
|
---|
| 1296 | <tfoot class="p-treetable-tfoot">
|
---|
| 1297 | <ng-container *ngTemplateOutlet="footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1298 | </tfoot>
|
---|
| 1299 | </table>
|
---|
| 1300 | </div>
|
---|
| 1301 |
|
---|
| 1302 | <div class="p-treetable-scrollable-wrapper" *ngIf="scrollable">
|
---|
| 1303 | <div class="p-treetable-scrollable-view p-treetable-frozen-view" *ngIf="frozenColumns||frozenBodyTemplate" #scrollableFrozenView [ttScrollableView]="frozenColumns" [frozen]="true" [ngStyle]="{width: frozenWidth}" [scrollHeight]="scrollHeight"></div>
|
---|
| 1304 | <div class="p-treetable-scrollable-view" #scrollableView [ttScrollableView]="columns" [frozen]="false" [scrollHeight]="scrollHeight" [ngStyle]="{left: frozenWidth, width: 'calc(100% - '+frozenWidth+')'}"></div>
|
---|
| 1305 | </div>
|
---|
| 1306 |
|
---|
| 1307 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-bottom" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1308 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'bottom' || paginatorPosition =='both')"
|
---|
| 1309 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo"
|
---|
| 1310 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1311 | <div *ngIf="summaryTemplate" class="p-treetable-footer">
|
---|
| 1312 | <ng-container *ngTemplateOutlet="summaryTemplate"></ng-container>
|
---|
| 1313 | </div>
|
---|
| 1314 |
|
---|
| 1315 | <div #resizeHelper class="p-column-resizer-helper" style="display:none" *ngIf="resizableColumns"></div>
|
---|
| 1316 |
|
---|
| 1317 | <span #reorderIndicatorUp class="pi pi-arrow-down p-treetable-reorder-indicator-up" *ngIf="reorderableColumns"></span>
|
---|
| 1318 | <span #reorderIndicatorDown class="pi pi-arrow-up p-treetable-reorder-indicator-down" *ngIf="reorderableColumns"></span>
|
---|
| 1319 | </div>
|
---|
| 1320 | `, providers: [TreeTableService], encapsulation: ViewEncapsulation.None, host: {
|
---|
| 1321 | 'class': 'p-element'
|
---|
| 1322 | }, 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"] }]
|
---|
| 1323 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: TreeTableService }, { type: i1.FilterService }]; }, propDecorators: { columns: [{
|
---|
| 1324 | type: Input
|
---|
| 1325 | }], style: [{
|
---|
| 1326 | type: Input
|
---|
| 1327 | }], styleClass: [{
|
---|
| 1328 | type: Input
|
---|
| 1329 | }], tableStyle: [{
|
---|
| 1330 | type: Input
|
---|
| 1331 | }], tableStyleClass: [{
|
---|
| 1332 | type: Input
|
---|
| 1333 | }], autoLayout: [{
|
---|
| 1334 | type: Input
|
---|
| 1335 | }], lazy: [{
|
---|
| 1336 | type: Input
|
---|
| 1337 | }], lazyLoadOnInit: [{
|
---|
| 1338 | type: Input
|
---|
| 1339 | }], paginator: [{
|
---|
| 1340 | type: Input
|
---|
| 1341 | }], rows: [{
|
---|
| 1342 | type: Input
|
---|
| 1343 | }], first: [{
|
---|
| 1344 | type: Input
|
---|
| 1345 | }], pageLinks: [{
|
---|
| 1346 | type: Input
|
---|
| 1347 | }], rowsPerPageOptions: [{
|
---|
| 1348 | type: Input
|
---|
| 1349 | }], alwaysShowPaginator: [{
|
---|
| 1350 | type: Input
|
---|
| 1351 | }], paginatorPosition: [{
|
---|
| 1352 | type: Input
|
---|
| 1353 | }], paginatorDropdownAppendTo: [{
|
---|
| 1354 | type: Input
|
---|
| 1355 | }], currentPageReportTemplate: [{
|
---|
| 1356 | type: Input
|
---|
| 1357 | }], showCurrentPageReport: [{
|
---|
| 1358 | type: Input
|
---|
| 1359 | }], showJumpToPageDropdown: [{
|
---|
| 1360 | type: Input
|
---|
| 1361 | }], showFirstLastIcon: [{
|
---|
| 1362 | type: Input
|
---|
| 1363 | }], showPageLinks: [{
|
---|
| 1364 | type: Input
|
---|
| 1365 | }], defaultSortOrder: [{
|
---|
| 1366 | type: Input
|
---|
| 1367 | }], sortMode: [{
|
---|
| 1368 | type: Input
|
---|
| 1369 | }], resetPageOnSort: [{
|
---|
| 1370 | type: Input
|
---|
| 1371 | }], customSort: [{
|
---|
| 1372 | type: Input
|
---|
| 1373 | }], selectionMode: [{
|
---|
| 1374 | type: Input
|
---|
| 1375 | }], selectionChange: [{
|
---|
| 1376 | type: Output
|
---|
| 1377 | }], contextMenuSelection: [{
|
---|
| 1378 | type: Input
|
---|
| 1379 | }], contextMenuSelectionChange: [{
|
---|
| 1380 | type: Output
|
---|
| 1381 | }], contextMenuSelectionMode: [{
|
---|
| 1382 | type: Input
|
---|
| 1383 | }], dataKey: [{
|
---|
| 1384 | type: Input
|
---|
| 1385 | }], metaKeySelection: [{
|
---|
| 1386 | type: Input
|
---|
| 1387 | }], compareSelectionBy: [{
|
---|
| 1388 | type: Input
|
---|
| 1389 | }], rowHover: [{
|
---|
| 1390 | type: Input
|
---|
| 1391 | }], loading: [{
|
---|
| 1392 | type: Input
|
---|
| 1393 | }], loadingIcon: [{
|
---|
| 1394 | type: Input
|
---|
| 1395 | }], showLoader: [{
|
---|
| 1396 | type: Input
|
---|
| 1397 | }], scrollable: [{
|
---|
| 1398 | type: Input
|
---|
| 1399 | }], scrollHeight: [{
|
---|
| 1400 | type: Input
|
---|
| 1401 | }], virtualScroll: [{
|
---|
| 1402 | type: Input
|
---|
| 1403 | }], virtualScrollDelay: [{
|
---|
| 1404 | type: Input
|
---|
| 1405 | }], virtualRowHeight: [{
|
---|
| 1406 | type: Input
|
---|
| 1407 | }], minBufferPx: [{
|
---|
| 1408 | type: Input
|
---|
| 1409 | }], maxBufferPx: [{
|
---|
| 1410 | type: Input
|
---|
| 1411 | }], frozenWidth: [{
|
---|
| 1412 | type: Input
|
---|
| 1413 | }], frozenColumns: [{
|
---|
| 1414 | type: Input
|
---|
| 1415 | }], resizableColumns: [{
|
---|
| 1416 | type: Input
|
---|
| 1417 | }], columnResizeMode: [{
|
---|
| 1418 | type: Input
|
---|
| 1419 | }], reorderableColumns: [{
|
---|
| 1420 | type: Input
|
---|
| 1421 | }], contextMenu: [{
|
---|
| 1422 | type: Input
|
---|
| 1423 | }], rowTrackBy: [{
|
---|
| 1424 | type: Input
|
---|
| 1425 | }], filters: [{
|
---|
| 1426 | type: Input
|
---|
| 1427 | }], globalFilterFields: [{
|
---|
| 1428 | type: Input
|
---|
| 1429 | }], filterDelay: [{
|
---|
| 1430 | type: Input
|
---|
| 1431 | }], filterMode: [{
|
---|
| 1432 | type: Input
|
---|
| 1433 | }], filterLocale: [{
|
---|
| 1434 | type: Input
|
---|
| 1435 | }], onFilter: [{
|
---|
| 1436 | type: Output
|
---|
| 1437 | }], onNodeExpand: [{
|
---|
| 1438 | type: Output
|
---|
| 1439 | }], onNodeCollapse: [{
|
---|
| 1440 | type: Output
|
---|
| 1441 | }], onPage: [{
|
---|
| 1442 | type: Output
|
---|
| 1443 | }], onSort: [{
|
---|
| 1444 | type: Output
|
---|
| 1445 | }], onLazyLoad: [{
|
---|
| 1446 | type: Output
|
---|
| 1447 | }], sortFunction: [{
|
---|
| 1448 | type: Output
|
---|
| 1449 | }], onColResize: [{
|
---|
| 1450 | type: Output
|
---|
| 1451 | }], onColReorder: [{
|
---|
| 1452 | type: Output
|
---|
| 1453 | }], onNodeSelect: [{
|
---|
| 1454 | type: Output
|
---|
| 1455 | }], onNodeUnselect: [{
|
---|
| 1456 | type: Output
|
---|
| 1457 | }], onContextMenuSelect: [{
|
---|
| 1458 | type: Output
|
---|
| 1459 | }], onHeaderCheckboxToggle: [{
|
---|
| 1460 | type: Output
|
---|
| 1461 | }], onEditInit: [{
|
---|
| 1462 | type: Output
|
---|
| 1463 | }], onEditComplete: [{
|
---|
| 1464 | type: Output
|
---|
| 1465 | }], onEditCancel: [{
|
---|
| 1466 | type: Output
|
---|
| 1467 | }], containerViewChild: [{
|
---|
| 1468 | type: ViewChild,
|
---|
| 1469 | args: ['container']
|
---|
| 1470 | }], resizeHelperViewChild: [{
|
---|
| 1471 | type: ViewChild,
|
---|
| 1472 | args: ['resizeHelper']
|
---|
| 1473 | }], reorderIndicatorUpViewChild: [{
|
---|
| 1474 | type: ViewChild,
|
---|
| 1475 | args: ['reorderIndicatorUp']
|
---|
| 1476 | }], reorderIndicatorDownViewChild: [{
|
---|
| 1477 | type: ViewChild,
|
---|
| 1478 | args: ['reorderIndicatorDown']
|
---|
| 1479 | }], tableViewChild: [{
|
---|
| 1480 | type: ViewChild,
|
---|
| 1481 | args: ['table']
|
---|
| 1482 | }], scrollableViewChild: [{
|
---|
| 1483 | type: ViewChild,
|
---|
| 1484 | args: ['scrollableView']
|
---|
| 1485 | }], scrollableFrozenViewChild: [{
|
---|
| 1486 | type: ViewChild,
|
---|
| 1487 | args: ['scrollableFrozenView']
|
---|
| 1488 | }], templates: [{
|
---|
| 1489 | type: ContentChildren,
|
---|
| 1490 | args: [PrimeTemplate]
|
---|
| 1491 | }], value: [{
|
---|
| 1492 | type: Input
|
---|
| 1493 | }], totalRecords: [{
|
---|
| 1494 | type: Input
|
---|
| 1495 | }], sortField: [{
|
---|
| 1496 | type: Input
|
---|
| 1497 | }], sortOrder: [{
|
---|
| 1498 | type: Input
|
---|
| 1499 | }], multiSortMeta: [{
|
---|
| 1500 | type: Input
|
---|
| 1501 | }], selection: [{
|
---|
| 1502 | type: Input
|
---|
| 1503 | }] } });
|
---|
| 1504 | class TTBody {
|
---|
| 1505 | constructor(tt, treeTableService, cd) {
|
---|
| 1506 | this.tt = tt;
|
---|
| 1507 | this.treeTableService = treeTableService;
|
---|
| 1508 | this.cd = cd;
|
---|
| 1509 | this.subscription = this.tt.tableService.uiUpdateSource$.subscribe(() => {
|
---|
| 1510 | if (this.tt.virtualScroll) {
|
---|
| 1511 | this.cd.detectChanges();
|
---|
| 1512 | }
|
---|
| 1513 | });
|
---|
| 1514 | }
|
---|
| 1515 | ngOnDestroy() {
|
---|
| 1516 | if (this.subscription) {
|
---|
| 1517 | this.subscription.unsubscribe();
|
---|
| 1518 | }
|
---|
| 1519 | }
|
---|
| 1520 | }
|
---|
| 1521 | 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 });
|
---|
| 1522 | 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: `
|
---|
| 1523 | <ng-container *ngIf="!tt.virtualScroll">
|
---|
| 1524 | <ng-template ngFor let-serializedNode let-rowIndex="index" [ngForOf]="tt.serializedValue" [ngForTrackBy]="tt.rowTrackBy">
|
---|
| 1525 | <ng-container *ngIf="serializedNode.visible">
|
---|
| 1526 | <ng-container *ngTemplateOutlet="template; context: {$implicit: serializedNode, node: serializedNode.node, rowData: serializedNode.node.data, columns: columns}"></ng-container>
|
---|
| 1527 | </ng-container>
|
---|
| 1528 | </ng-template>
|
---|
| 1529 | </ng-container>
|
---|
| 1530 | <ng-container *ngIf="tt.virtualScroll">
|
---|
| 1531 | <ng-template cdkVirtualFor let-serializedNode let-rowIndex="index" [cdkVirtualForOf]="tt.serializedValue" [cdkVirtualForTrackBy]="tt.rowTrackBy" [cdkVirtualForTemplateCacheSize]="0">
|
---|
| 1532 | <ng-container *ngIf="serializedNode.visible">
|
---|
| 1533 | <ng-container *ngTemplateOutlet="template; context: {$implicit: serializedNode, node: serializedNode.node, rowData: serializedNode.node.data, columns: columns}"></ng-container>
|
---|
| 1534 | </ng-container>
|
---|
| 1535 | </ng-template>
|
---|
| 1536 | </ng-container>
|
---|
| 1537 | <ng-container *ngIf="tt.isEmpty()">
|
---|
| 1538 | <ng-container *ngTemplateOutlet="tt.emptyMessageTemplate; context: {$implicit: columns, frozen: frozen}"></ng-container>
|
---|
| 1539 | </ng-container>
|
---|
| 1540 | `, 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 });
|
---|
| 1541 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTBody, decorators: [{
|
---|
| 1542 | type: Component,
|
---|
| 1543 | args: [{
|
---|
| 1544 | selector: '[pTreeTableBody]',
|
---|
| 1545 | template: `
|
---|
| 1546 | <ng-container *ngIf="!tt.virtualScroll">
|
---|
| 1547 | <ng-template ngFor let-serializedNode let-rowIndex="index" [ngForOf]="tt.serializedValue" [ngForTrackBy]="tt.rowTrackBy">
|
---|
| 1548 | <ng-container *ngIf="serializedNode.visible">
|
---|
| 1549 | <ng-container *ngTemplateOutlet="template; context: {$implicit: serializedNode, node: serializedNode.node, rowData: serializedNode.node.data, columns: columns}"></ng-container>
|
---|
| 1550 | </ng-container>
|
---|
| 1551 | </ng-template>
|
---|
| 1552 | </ng-container>
|
---|
| 1553 | <ng-container *ngIf="tt.virtualScroll">
|
---|
| 1554 | <ng-template cdkVirtualFor let-serializedNode let-rowIndex="index" [cdkVirtualForOf]="tt.serializedValue" [cdkVirtualForTrackBy]="tt.rowTrackBy" [cdkVirtualForTemplateCacheSize]="0">
|
---|
| 1555 | <ng-container *ngIf="serializedNode.visible">
|
---|
| 1556 | <ng-container *ngTemplateOutlet="template; context: {$implicit: serializedNode, node: serializedNode.node, rowData: serializedNode.node.data, columns: columns}"></ng-container>
|
---|
| 1557 | </ng-container>
|
---|
| 1558 | </ng-template>
|
---|
| 1559 | </ng-container>
|
---|
| 1560 | <ng-container *ngIf="tt.isEmpty()">
|
---|
| 1561 | <ng-container *ngTemplateOutlet="tt.emptyMessageTemplate; context: {$implicit: columns, frozen: frozen}"></ng-container>
|
---|
| 1562 | </ng-container>
|
---|
| 1563 | `,
|
---|
| 1564 | encapsulation: ViewEncapsulation.None,
|
---|
| 1565 | host: {
|
---|
| 1566 | 'class': 'p-element'
|
---|
| 1567 | }
|
---|
| 1568 | }]
|
---|
| 1569 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { columns: [{
|
---|
| 1570 | type: Input,
|
---|
| 1571 | args: ["pTreeTableBody"]
|
---|
| 1572 | }], template: [{
|
---|
| 1573 | type: Input,
|
---|
| 1574 | args: ["pTreeTableBodyTemplate"]
|
---|
| 1575 | }], frozen: [{
|
---|
| 1576 | type: Input
|
---|
| 1577 | }] } });
|
---|
| 1578 | class TTScrollableView {
|
---|
| 1579 | constructor(tt, el, zone) {
|
---|
| 1580 | this.tt = tt;
|
---|
| 1581 | this.el = el;
|
---|
| 1582 | this.zone = zone;
|
---|
| 1583 | }
|
---|
| 1584 | get scrollHeight() {
|
---|
| 1585 | return this._scrollHeight;
|
---|
| 1586 | }
|
---|
| 1587 | set scrollHeight(val) {
|
---|
| 1588 | this._scrollHeight = val;
|
---|
| 1589 | if (val != null && (val.includes('%') || val.includes('calc'))) {
|
---|
| 1590 | console.log('Percentage scroll height calculation is removed in favor of the more performant CSS based flex mode, use scrollHeight="flex" instead.');
|
---|
| 1591 | }
|
---|
| 1592 | if (this.tt.virtualScroll && this.virtualScrollBody) {
|
---|
| 1593 | this.virtualScrollBody.ngOnInit();
|
---|
| 1594 | }
|
---|
| 1595 | }
|
---|
| 1596 | ngAfterViewInit() {
|
---|
| 1597 | if (!this.frozen) {
|
---|
| 1598 | if (this.tt.frozenColumns || this.tt.frozenBodyTemplate) {
|
---|
| 1599 | DomHandler.addClass(this.el.nativeElement, 'p-treetable-unfrozen-view');
|
---|
| 1600 | }
|
---|
| 1601 | let frozenView = this.el.nativeElement.previousElementSibling;
|
---|
| 1602 | if (frozenView) {
|
---|
| 1603 | if (this.tt.virtualScroll)
|
---|
| 1604 | this.frozenSiblingBody = DomHandler.findSingle(frozenView, '.p-treetable-virtual-scrollable-body');
|
---|
| 1605 | else
|
---|
| 1606 | this.frozenSiblingBody = DomHandler.findSingle(frozenView, '.p-treetable-scrollable-body');
|
---|
| 1607 | }
|
---|
| 1608 | let scrollBarWidth = DomHandler.calculateScrollbarWidth();
|
---|
| 1609 | this.scrollHeaderBoxViewChild.nativeElement.style.paddingRight = scrollBarWidth + 'px';
|
---|
| 1610 | if (this.scrollFooterBoxViewChild && this.scrollFooterBoxViewChild.nativeElement) {
|
---|
| 1611 | this.scrollFooterBoxViewChild.nativeElement.style.paddingRight = scrollBarWidth + 'px';
|
---|
| 1612 | }
|
---|
| 1613 | }
|
---|
| 1614 | else {
|
---|
| 1615 | if (this.scrollableAlignerViewChild && this.scrollableAlignerViewChild.nativeElement) {
|
---|
| 1616 | this.scrollableAlignerViewChild.nativeElement.style.height = DomHandler.calculateScrollbarHeight() + 'px';
|
---|
| 1617 | }
|
---|
| 1618 | }
|
---|
| 1619 | this.bindEvents();
|
---|
| 1620 | }
|
---|
| 1621 | bindEvents() {
|
---|
| 1622 | this.zone.runOutsideAngular(() => {
|
---|
| 1623 | if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
|
---|
| 1624 | this.headerScrollListener = this.onHeaderScroll.bind(this);
|
---|
| 1625 | this.scrollHeaderBoxViewChild.nativeElement.addEventListener('scroll', this.headerScrollListener);
|
---|
| 1626 | }
|
---|
| 1627 | if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
|
---|
| 1628 | this.footerScrollListener = this.onFooterScroll.bind(this);
|
---|
| 1629 | this.scrollFooterViewChild.nativeElement.addEventListener('scroll', this.footerScrollListener);
|
---|
| 1630 | }
|
---|
| 1631 | if (!this.frozen) {
|
---|
| 1632 | this.bodyScrollListener = this.onBodyScroll.bind(this);
|
---|
| 1633 | if (this.tt.virtualScroll)
|
---|
| 1634 | this.virtualScrollBody.getElementRef().nativeElement.addEventListener('scroll', this.bodyScrollListener);
|
---|
| 1635 | else
|
---|
| 1636 | this.scrollBodyViewChild.nativeElement.addEventListener('scroll', this.bodyScrollListener);
|
---|
| 1637 | }
|
---|
| 1638 | });
|
---|
| 1639 | }
|
---|
| 1640 | unbindEvents() {
|
---|
| 1641 | if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
|
---|
| 1642 | this.scrollHeaderBoxViewChild.nativeElement.removeEventListener('scroll', this.headerScrollListener);
|
---|
| 1643 | }
|
---|
| 1644 | if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
|
---|
| 1645 | this.scrollFooterViewChild.nativeElement.removeEventListener('scroll', this.footerScrollListener);
|
---|
| 1646 | }
|
---|
| 1647 | if (this.scrollBodyViewChild && this.scrollBodyViewChild.nativeElement) {
|
---|
| 1648 | this.scrollBodyViewChild.nativeElement.removeEventListener('scroll', this.bodyScrollListener);
|
---|
| 1649 | }
|
---|
| 1650 | if (this.virtualScrollBody && this.virtualScrollBody.getElementRef()) {
|
---|
| 1651 | this.virtualScrollBody.getElementRef().nativeElement.removeEventListener('scroll', this.bodyScrollListener);
|
---|
| 1652 | }
|
---|
| 1653 | }
|
---|
| 1654 | onHeaderScroll() {
|
---|
| 1655 | const scrollLeft = this.scrollHeaderViewChild.nativeElement.scrollLeft;
|
---|
| 1656 | this.scrollBodyViewChild.nativeElement.scrollLeft = scrollLeft;
|
---|
| 1657 | if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
|
---|
| 1658 | this.scrollFooterViewChild.nativeElement.scrollLeft = scrollLeft;
|
---|
| 1659 | }
|
---|
| 1660 | this.preventBodyScrollPropagation = true;
|
---|
| 1661 | }
|
---|
| 1662 | onFooterScroll() {
|
---|
| 1663 | const scrollLeft = this.scrollFooterViewChild.nativeElement.scrollLeft;
|
---|
| 1664 | this.scrollBodyViewChild.nativeElement.scrollLeft = scrollLeft;
|
---|
| 1665 | if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
|
---|
| 1666 | this.scrollHeaderViewChild.nativeElement.scrollLeft = scrollLeft;
|
---|
| 1667 | }
|
---|
| 1668 | this.preventBodyScrollPropagation = true;
|
---|
| 1669 | }
|
---|
| 1670 | onBodyScroll(event) {
|
---|
| 1671 | if (this.preventBodyScrollPropagation) {
|
---|
| 1672 | this.preventBodyScrollPropagation = false;
|
---|
| 1673 | return;
|
---|
| 1674 | }
|
---|
| 1675 | if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
|
---|
| 1676 | this.scrollHeaderBoxViewChild.nativeElement.style.marginLeft = -1 * event.target.scrollLeft + 'px';
|
---|
| 1677 | }
|
---|
| 1678 | if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
|
---|
| 1679 | this.scrollFooterBoxViewChild.nativeElement.style.marginLeft = -1 * event.target.scrollLeft + 'px';
|
---|
| 1680 | }
|
---|
| 1681 | if (this.frozenSiblingBody) {
|
---|
| 1682 | this.frozenSiblingBody.scrollTop = event.target.scrollTop;
|
---|
| 1683 | }
|
---|
| 1684 | }
|
---|
| 1685 | scrollToVirtualIndex(index) {
|
---|
| 1686 | if (this.virtualScrollBody) {
|
---|
| 1687 | this.virtualScrollBody.scrollToIndex(index);
|
---|
| 1688 | }
|
---|
| 1689 | }
|
---|
| 1690 | scrollTo(options) {
|
---|
| 1691 | if (this.virtualScrollBody) {
|
---|
| 1692 | this.virtualScrollBody.scrollTo(options);
|
---|
| 1693 | }
|
---|
| 1694 | else {
|
---|
| 1695 | if (this.scrollBodyViewChild.nativeElement.scrollTo) {
|
---|
| 1696 | this.scrollBodyViewChild.nativeElement.scrollTo(options);
|
---|
| 1697 | }
|
---|
| 1698 | else {
|
---|
| 1699 | this.scrollBodyViewChild.nativeElement.scrollLeft = options.left;
|
---|
| 1700 | this.scrollBodyViewChild.nativeElement.scrollTop = options.top;
|
---|
| 1701 | }
|
---|
| 1702 | }
|
---|
| 1703 | }
|
---|
| 1704 | ngOnDestroy() {
|
---|
| 1705 | this.unbindEvents();
|
---|
| 1706 | this.frozenSiblingBody = null;
|
---|
| 1707 | }
|
---|
| 1708 | }
|
---|
| 1709 | 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 });
|
---|
| 1710 | 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: `
|
---|
| 1711 | <div #scrollHeader class="p-treetable-scrollable-header">
|
---|
| 1712 | <div #scrollHeaderBox class="p-treetable-scrollable-header-box">
|
---|
| 1713 | <table class="p-treetable-scrollable-header-table" [ngClass]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1714 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1715 | <thead class="p-treetable-thead">
|
---|
| 1716 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenHeaderTemplate||tt.headerTemplate : tt.headerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1717 | </thead>
|
---|
| 1718 | </table>
|
---|
| 1719 | </div>
|
---|
| 1720 | </div>
|
---|
| 1721 | <ng-container *ngIf="!tt.virtualScroll; else virtualScrollTemplate">
|
---|
| 1722 | <div #scrollBody class="p-treetable-scrollable-body" [ngStyle]="{'max-height': tt.scrollHeight !== 'flex' ? scrollHeight : undefined, 'overflow-y': !frozen && tt.scrollHeight ? 'scroll' : undefined}">
|
---|
| 1723 | <table #scrollTable [class]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1724 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1725 | <tbody class="p-treetable-tbody" [pTreeTableBody]="columns" [pTreeTableBodyTemplate]="frozen ? tt.frozenBodyTemplate||tt.bodyTemplate : tt.bodyTemplate" [frozen]="frozen"></tbody>
|
---|
| 1726 | </table>
|
---|
| 1727 | <div #scrollableAligner style="background-color:transparent" *ngIf="frozen"></div>
|
---|
| 1728 | </div>
|
---|
| 1729 | </ng-container>
|
---|
| 1730 | <ng-template #virtualScrollTemplate>
|
---|
| 1731 | <cdk-virtual-scroll-viewport [itemSize]="tt.virtualRowHeight" [style.height]="tt.scrollHeight !== 'flex' ? scrollHeight : undefined"
|
---|
| 1732 | [minBufferPx]="tt.minBufferPx" [maxBufferPx]="tt.maxBufferPx" class="p-treetable-virtual-scrollable-body">
|
---|
| 1733 | <table #scrollTable [class]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1734 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1735 | <tbody class="p-treetable-tbody" [pTreeTableBody]="columns" [pTreeTableBodyTemplate]="frozen ? tt.frozenBodyTemplate||tt.bodyTemplate : tt.bodyTemplate" [frozen]="frozen"></tbody>
|
---|
| 1736 | </table>
|
---|
| 1737 | <div #scrollableAligner style="background-color:transparent" *ngIf="frozen"></div>
|
---|
| 1738 | </cdk-virtual-scroll-viewport>
|
---|
| 1739 | </ng-template>
|
---|
| 1740 | <div #scrollFooter *ngIf="tt.footerTemplate" class="p-treetable-scrollable-footer">
|
---|
| 1741 | <div #scrollFooterBox class="p-treetable-scrollable-footer-box">
|
---|
| 1742 | <table class="p-treetable-scrollable-footer-table" [ngClass]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1743 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1744 | <tfoot class="p-treetable-tfoot">
|
---|
| 1745 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenFooterTemplate||tt.footerTemplate : tt.footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1746 | </tfoot>
|
---|
| 1747 | </table>
|
---|
| 1748 | </div>
|
---|
| 1749 | </div>
|
---|
| 1750 | `, 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 });
|
---|
| 1751 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTScrollableView, decorators: [{
|
---|
| 1752 | type: Component,
|
---|
| 1753 | args: [{
|
---|
| 1754 | selector: '[ttScrollableView]',
|
---|
| 1755 | template: `
|
---|
| 1756 | <div #scrollHeader class="p-treetable-scrollable-header">
|
---|
| 1757 | <div #scrollHeaderBox class="p-treetable-scrollable-header-box">
|
---|
| 1758 | <table class="p-treetable-scrollable-header-table" [ngClass]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1759 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1760 | <thead class="p-treetable-thead">
|
---|
| 1761 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenHeaderTemplate||tt.headerTemplate : tt.headerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1762 | </thead>
|
---|
| 1763 | </table>
|
---|
| 1764 | </div>
|
---|
| 1765 | </div>
|
---|
| 1766 | <ng-container *ngIf="!tt.virtualScroll; else virtualScrollTemplate">
|
---|
| 1767 | <div #scrollBody class="p-treetable-scrollable-body" [ngStyle]="{'max-height': tt.scrollHeight !== 'flex' ? scrollHeight : undefined, 'overflow-y': !frozen && tt.scrollHeight ? 'scroll' : undefined}">
|
---|
| 1768 | <table #scrollTable [class]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1769 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1770 | <tbody class="p-treetable-tbody" [pTreeTableBody]="columns" [pTreeTableBodyTemplate]="frozen ? tt.frozenBodyTemplate||tt.bodyTemplate : tt.bodyTemplate" [frozen]="frozen"></tbody>
|
---|
| 1771 | </table>
|
---|
| 1772 | <div #scrollableAligner style="background-color:transparent" *ngIf="frozen"></div>
|
---|
| 1773 | </div>
|
---|
| 1774 | </ng-container>
|
---|
| 1775 | <ng-template #virtualScrollTemplate>
|
---|
| 1776 | <cdk-virtual-scroll-viewport [itemSize]="tt.virtualRowHeight" [style.height]="tt.scrollHeight !== 'flex' ? scrollHeight : undefined"
|
---|
| 1777 | [minBufferPx]="tt.minBufferPx" [maxBufferPx]="tt.maxBufferPx" class="p-treetable-virtual-scrollable-body">
|
---|
| 1778 | <table #scrollTable [class]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1779 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1780 | <tbody class="p-treetable-tbody" [pTreeTableBody]="columns" [pTreeTableBodyTemplate]="frozen ? tt.frozenBodyTemplate||tt.bodyTemplate : tt.bodyTemplate" [frozen]="frozen"></tbody>
|
---|
| 1781 | </table>
|
---|
| 1782 | <div #scrollableAligner style="background-color:transparent" *ngIf="frozen"></div>
|
---|
| 1783 | </cdk-virtual-scroll-viewport>
|
---|
| 1784 | </ng-template>
|
---|
| 1785 | <div #scrollFooter *ngIf="tt.footerTemplate" class="p-treetable-scrollable-footer">
|
---|
| 1786 | <div #scrollFooterBox class="p-treetable-scrollable-footer-box">
|
---|
| 1787 | <table class="p-treetable-scrollable-footer-table" [ngClass]="tt.tableStyleClass" [ngStyle]="tt.tableStyle">
|
---|
| 1788 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1789 | <tfoot class="p-treetable-tfoot">
|
---|
| 1790 | <ng-container *ngTemplateOutlet="frozen ? tt.frozenFooterTemplate||tt.footerTemplate : tt.footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1791 | </tfoot>
|
---|
| 1792 | </table>
|
---|
| 1793 | </div>
|
---|
| 1794 | </div>
|
---|
| 1795 | `,
|
---|
| 1796 | encapsulation: ViewEncapsulation.None,
|
---|
| 1797 | host: {
|
---|
| 1798 | 'class': 'p-element'
|
---|
| 1799 | }
|
---|
| 1800 | }]
|
---|
| 1801 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { columns: [{
|
---|
| 1802 | type: Input,
|
---|
| 1803 | args: ["ttScrollableView"]
|
---|
| 1804 | }], frozen: [{
|
---|
| 1805 | type: Input
|
---|
| 1806 | }], scrollHeaderViewChild: [{
|
---|
| 1807 | type: ViewChild,
|
---|
| 1808 | args: ['scrollHeader']
|
---|
| 1809 | }], scrollHeaderBoxViewChild: [{
|
---|
| 1810 | type: ViewChild,
|
---|
| 1811 | args: ['scrollHeaderBox']
|
---|
| 1812 | }], scrollBodyViewChild: [{
|
---|
| 1813 | type: ViewChild,
|
---|
| 1814 | args: ['scrollBody']
|
---|
| 1815 | }], scrollTableViewChild: [{
|
---|
| 1816 | type: ViewChild,
|
---|
| 1817 | args: ['scrollTable']
|
---|
| 1818 | }], scrollLoadingTableViewChild: [{
|
---|
| 1819 | type: ViewChild,
|
---|
| 1820 | args: ['loadingTable']
|
---|
| 1821 | }], scrollFooterViewChild: [{
|
---|
| 1822 | type: ViewChild,
|
---|
| 1823 | args: ['scrollFooter']
|
---|
| 1824 | }], scrollFooterBoxViewChild: [{
|
---|
| 1825 | type: ViewChild,
|
---|
| 1826 | args: ['scrollFooterBox']
|
---|
| 1827 | }], scrollableAlignerViewChild: [{
|
---|
| 1828 | type: ViewChild,
|
---|
| 1829 | args: ['scrollableAligner']
|
---|
| 1830 | }], virtualScrollBody: [{
|
---|
| 1831 | type: ViewChild,
|
---|
| 1832 | args: [CdkVirtualScrollViewport]
|
---|
| 1833 | }], scrollHeight: [{
|
---|
| 1834 | type: Input
|
---|
| 1835 | }] } });
|
---|
| 1836 | class TTSortableColumn {
|
---|
| 1837 | constructor(tt) {
|
---|
| 1838 | this.tt = tt;
|
---|
| 1839 | if (this.isEnabled()) {
|
---|
| 1840 | this.subscription = this.tt.tableService.sortSource$.subscribe(sortMeta => {
|
---|
| 1841 | this.updateSortState();
|
---|
| 1842 | });
|
---|
| 1843 | }
|
---|
| 1844 | }
|
---|
| 1845 | ngOnInit() {
|
---|
| 1846 | if (this.isEnabled()) {
|
---|
| 1847 | this.updateSortState();
|
---|
| 1848 | }
|
---|
| 1849 | }
|
---|
| 1850 | updateSortState() {
|
---|
| 1851 | this.sorted = this.tt.isSorted(this.field);
|
---|
| 1852 | }
|
---|
| 1853 | onClick(event) {
|
---|
| 1854 | if (this.isEnabled()) {
|
---|
| 1855 | this.updateSortState();
|
---|
| 1856 | this.tt.sort({
|
---|
| 1857 | originalEvent: event,
|
---|
| 1858 | field: this.field
|
---|
| 1859 | });
|
---|
| 1860 | DomHandler.clearSelection();
|
---|
| 1861 | }
|
---|
| 1862 | }
|
---|
| 1863 | onEnterKey(event) {
|
---|
| 1864 | this.onClick(event);
|
---|
| 1865 | }
|
---|
| 1866 | isEnabled() {
|
---|
| 1867 | return this.ttSortableColumnDisabled !== true;
|
---|
| 1868 | }
|
---|
| 1869 | ngOnDestroy() {
|
---|
| 1870 | if (this.subscription) {
|
---|
| 1871 | this.subscription.unsubscribe();
|
---|
| 1872 | }
|
---|
| 1873 | }
|
---|
| 1874 | }
|
---|
| 1875 | TTSortableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSortableColumn, deps: [{ token: TreeTable }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 1876 | 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 });
|
---|
| 1877 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSortableColumn, decorators: [{
|
---|
| 1878 | type: Directive,
|
---|
| 1879 | args: [{
|
---|
| 1880 | selector: '[ttSortableColumn]',
|
---|
| 1881 | host: {
|
---|
| 1882 | 'class': 'p-element',
|
---|
| 1883 | '[class.p-sortable-column]': 'isEnabled()',
|
---|
| 1884 | '[class.p-highlight]': 'sorted',
|
---|
| 1885 | '[attr.tabindex]': 'isEnabled() ? "0" : null',
|
---|
| 1886 | '[attr.role]': '"columnheader"'
|
---|
| 1887 | }
|
---|
| 1888 | }]
|
---|
| 1889 | }], ctorParameters: function () { return [{ type: TreeTable }]; }, propDecorators: { field: [{
|
---|
| 1890 | type: Input,
|
---|
| 1891 | args: ["ttSortableColumn"]
|
---|
| 1892 | }], ttSortableColumnDisabled: [{
|
---|
| 1893 | type: Input
|
---|
| 1894 | }], onClick: [{
|
---|
| 1895 | type: HostListener,
|
---|
| 1896 | args: ['click', ['$event']]
|
---|
| 1897 | }], onEnterKey: [{
|
---|
| 1898 | type: HostListener,
|
---|
| 1899 | args: ['keydown.enter', ['$event']]
|
---|
| 1900 | }] } });
|
---|
| 1901 | class TTSortIcon {
|
---|
| 1902 | constructor(tt, cd) {
|
---|
| 1903 | this.tt = tt;
|
---|
| 1904 | this.cd = cd;
|
---|
| 1905 | this.subscription = this.tt.tableService.sortSource$.subscribe(sortMeta => {
|
---|
| 1906 | this.updateSortState();
|
---|
| 1907 | this.cd.markForCheck();
|
---|
| 1908 | });
|
---|
| 1909 | }
|
---|
| 1910 | ngOnInit() {
|
---|
| 1911 | this.updateSortState();
|
---|
| 1912 | }
|
---|
| 1913 | onClick(event) {
|
---|
| 1914 | event.preventDefault();
|
---|
| 1915 | }
|
---|
| 1916 | updateSortState() {
|
---|
| 1917 | if (this.tt.sortMode === 'single') {
|
---|
| 1918 | this.sortOrder = this.tt.isSorted(this.field) ? this.tt.sortOrder : 0;
|
---|
| 1919 | }
|
---|
| 1920 | else if (this.tt.sortMode === 'multiple') {
|
---|
| 1921 | let sortMeta = this.tt.getSortMeta(this.field);
|
---|
| 1922 | this.sortOrder = sortMeta ? sortMeta.order : 0;
|
---|
| 1923 | }
|
---|
| 1924 | }
|
---|
| 1925 | ngOnDestroy() {
|
---|
| 1926 | if (this.subscription) {
|
---|
| 1927 | this.subscription.unsubscribe();
|
---|
| 1928 | }
|
---|
| 1929 | }
|
---|
| 1930 | }
|
---|
| 1931 | 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 });
|
---|
| 1932 | 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: `
|
---|
| 1933 | <i class="p-sortable-column-icon pi pi-fw" [ngClass]="{'pi-sort-amount-up-alt': sortOrder === 1, 'pi-sort-amount-down': sortOrder === -1, 'pi-sort-alt': sortOrder === 0}"></i>
|
---|
| 1934 | `, isInline: true, directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 1935 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSortIcon, decorators: [{
|
---|
| 1936 | type: Component,
|
---|
| 1937 | args: [{
|
---|
| 1938 | selector: 'p-treeTableSortIcon',
|
---|
| 1939 | template: `
|
---|
| 1940 | <i class="p-sortable-column-icon pi pi-fw" [ngClass]="{'pi-sort-amount-up-alt': sortOrder === 1, 'pi-sort-amount-down': sortOrder === -1, 'pi-sort-alt': sortOrder === 0}"></i>
|
---|
| 1941 | `,
|
---|
| 1942 | encapsulation: ViewEncapsulation.None,
|
---|
| 1943 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 1944 | host: {
|
---|
| 1945 | 'class': 'p-element'
|
---|
| 1946 | }
|
---|
| 1947 | }]
|
---|
| 1948 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { field: [{
|
---|
| 1949 | type: Input
|
---|
| 1950 | }], ariaLabelDesc: [{
|
---|
| 1951 | type: Input
|
---|
| 1952 | }], ariaLabelAsc: [{
|
---|
| 1953 | type: Input
|
---|
| 1954 | }] } });
|
---|
| 1955 | class TTResizableColumn {
|
---|
| 1956 | constructor(tt, el, zone) {
|
---|
| 1957 | this.tt = tt;
|
---|
| 1958 | this.el = el;
|
---|
| 1959 | this.zone = zone;
|
---|
| 1960 | }
|
---|
| 1961 | ngAfterViewInit() {
|
---|
| 1962 | if (this.isEnabled()) {
|
---|
| 1963 | DomHandler.addClass(this.el.nativeElement, 'p-resizable-column');
|
---|
| 1964 | this.resizer = document.createElement('span');
|
---|
| 1965 | this.resizer.className = 'p-column-resizer';
|
---|
| 1966 | this.el.nativeElement.appendChild(this.resizer);
|
---|
| 1967 | this.zone.runOutsideAngular(() => {
|
---|
| 1968 | this.resizerMouseDownListener = this.onMouseDown.bind(this);
|
---|
| 1969 | this.resizer.addEventListener('mousedown', this.resizerMouseDownListener);
|
---|
| 1970 | });
|
---|
| 1971 | }
|
---|
| 1972 | }
|
---|
| 1973 | bindDocumentEvents() {
|
---|
| 1974 | this.zone.runOutsideAngular(() => {
|
---|
| 1975 | this.documentMouseMoveListener = this.onDocumentMouseMove.bind(this);
|
---|
| 1976 | document.addEventListener('mousemove', this.documentMouseMoveListener);
|
---|
| 1977 | this.documentMouseUpListener = this.onDocumentMouseUp.bind(this);
|
---|
| 1978 | document.addEventListener('mouseup', this.documentMouseUpListener);
|
---|
| 1979 | });
|
---|
| 1980 | }
|
---|
| 1981 | unbindDocumentEvents() {
|
---|
| 1982 | if (this.documentMouseMoveListener) {
|
---|
| 1983 | document.removeEventListener('mousemove', this.documentMouseMoveListener);
|
---|
| 1984 | this.documentMouseMoveListener = null;
|
---|
| 1985 | }
|
---|
| 1986 | if (this.documentMouseUpListener) {
|
---|
| 1987 | document.removeEventListener('mouseup', this.documentMouseUpListener);
|
---|
| 1988 | this.documentMouseUpListener = null;
|
---|
| 1989 | }
|
---|
| 1990 | }
|
---|
| 1991 | onMouseDown(event) {
|
---|
| 1992 | this.tt.onColumnResizeBegin(event);
|
---|
| 1993 | this.bindDocumentEvents();
|
---|
| 1994 | }
|
---|
| 1995 | onDocumentMouseMove(event) {
|
---|
| 1996 | this.tt.onColumnResize(event);
|
---|
| 1997 | }
|
---|
| 1998 | onDocumentMouseUp(event) {
|
---|
| 1999 | this.tt.onColumnResizeEnd(event, this.el.nativeElement);
|
---|
| 2000 | this.unbindDocumentEvents();
|
---|
| 2001 | }
|
---|
| 2002 | isEnabled() {
|
---|
| 2003 | return this.ttResizableColumnDisabled !== true;
|
---|
| 2004 | }
|
---|
| 2005 | ngOnDestroy() {
|
---|
| 2006 | if (this.resizerMouseDownListener) {
|
---|
| 2007 | this.resizer.removeEventListener('mousedown', this.resizerMouseDownListener);
|
---|
| 2008 | }
|
---|
| 2009 | this.unbindDocumentEvents();
|
---|
| 2010 | }
|
---|
| 2011 | }
|
---|
| 2012 | 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 });
|
---|
| 2013 | 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 });
|
---|
| 2014 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTResizableColumn, decorators: [{
|
---|
| 2015 | type: Directive,
|
---|
| 2016 | args: [{
|
---|
| 2017 | selector: '[ttResizableColumn]',
|
---|
| 2018 | host: {
|
---|
| 2019 | 'class': 'p-element'
|
---|
| 2020 | }
|
---|
| 2021 | }]
|
---|
| 2022 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { ttResizableColumnDisabled: [{
|
---|
| 2023 | type: Input
|
---|
| 2024 | }] } });
|
---|
| 2025 | class TTReorderableColumn {
|
---|
| 2026 | constructor(tt, el, zone) {
|
---|
| 2027 | this.tt = tt;
|
---|
| 2028 | this.el = el;
|
---|
| 2029 | this.zone = zone;
|
---|
| 2030 | }
|
---|
| 2031 | ngAfterViewInit() {
|
---|
| 2032 | if (this.isEnabled()) {
|
---|
| 2033 | this.bindEvents();
|
---|
| 2034 | }
|
---|
| 2035 | }
|
---|
| 2036 | bindEvents() {
|
---|
| 2037 | this.zone.runOutsideAngular(() => {
|
---|
| 2038 | this.mouseDownListener = this.onMouseDown.bind(this);
|
---|
| 2039 | this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);
|
---|
| 2040 | this.dragStartListener = this.onDragStart.bind(this);
|
---|
| 2041 | this.el.nativeElement.addEventListener('dragstart', this.dragStartListener);
|
---|
| 2042 | this.dragOverListener = this.onDragEnter.bind(this);
|
---|
| 2043 | this.el.nativeElement.addEventListener('dragover', this.dragOverListener);
|
---|
| 2044 | this.dragEnterListener = this.onDragEnter.bind(this);
|
---|
| 2045 | this.el.nativeElement.addEventListener('dragenter', this.dragEnterListener);
|
---|
| 2046 | this.dragLeaveListener = this.onDragLeave.bind(this);
|
---|
| 2047 | this.el.nativeElement.addEventListener('dragleave', this.dragLeaveListener);
|
---|
| 2048 | });
|
---|
| 2049 | }
|
---|
| 2050 | unbindEvents() {
|
---|
| 2051 | if (this.mouseDownListener) {
|
---|
| 2052 | document.removeEventListener('mousedown', this.mouseDownListener);
|
---|
| 2053 | this.mouseDownListener = null;
|
---|
| 2054 | }
|
---|
| 2055 | if (this.dragOverListener) {
|
---|
| 2056 | document.removeEventListener('dragover', this.dragOverListener);
|
---|
| 2057 | this.dragOverListener = null;
|
---|
| 2058 | }
|
---|
| 2059 | if (this.dragEnterListener) {
|
---|
| 2060 | document.removeEventListener('dragenter', this.dragEnterListener);
|
---|
| 2061 | this.dragEnterListener = null;
|
---|
| 2062 | }
|
---|
| 2063 | if (this.dragEnterListener) {
|
---|
| 2064 | document.removeEventListener('dragenter', this.dragEnterListener);
|
---|
| 2065 | this.dragEnterListener = null;
|
---|
| 2066 | }
|
---|
| 2067 | if (this.dragLeaveListener) {
|
---|
| 2068 | document.removeEventListener('dragleave', this.dragLeaveListener);
|
---|
| 2069 | this.dragLeaveListener = null;
|
---|
| 2070 | }
|
---|
| 2071 | }
|
---|
| 2072 | onMouseDown(event) {
|
---|
| 2073 | if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' || DomHandler.hasClass(event.target, 'p-column-resizer'))
|
---|
| 2074 | this.el.nativeElement.draggable = false;
|
---|
| 2075 | else
|
---|
| 2076 | this.el.nativeElement.draggable = true;
|
---|
| 2077 | }
|
---|
| 2078 | onDragStart(event) {
|
---|
| 2079 | this.tt.onColumnDragStart(event, this.el.nativeElement);
|
---|
| 2080 | }
|
---|
| 2081 | onDragOver(event) {
|
---|
| 2082 | event.preventDefault();
|
---|
| 2083 | }
|
---|
| 2084 | onDragEnter(event) {
|
---|
| 2085 | this.tt.onColumnDragEnter(event, this.el.nativeElement);
|
---|
| 2086 | }
|
---|
| 2087 | onDragLeave(event) {
|
---|
| 2088 | this.tt.onColumnDragLeave(event);
|
---|
| 2089 | }
|
---|
| 2090 | onDrop(event) {
|
---|
| 2091 | if (this.isEnabled()) {
|
---|
| 2092 | this.tt.onColumnDrop(event, this.el.nativeElement);
|
---|
| 2093 | }
|
---|
| 2094 | }
|
---|
| 2095 | isEnabled() {
|
---|
| 2096 | return this.ttReorderableColumnDisabled !== true;
|
---|
| 2097 | }
|
---|
| 2098 | ngOnDestroy() {
|
---|
| 2099 | this.unbindEvents();
|
---|
| 2100 | }
|
---|
| 2101 | }
|
---|
| 2102 | 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 });
|
---|
| 2103 | 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 });
|
---|
| 2104 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTReorderableColumn, decorators: [{
|
---|
| 2105 | type: Directive,
|
---|
| 2106 | args: [{
|
---|
| 2107 | selector: '[ttReorderableColumn]',
|
---|
| 2108 | host: {
|
---|
| 2109 | 'class': 'p-element'
|
---|
| 2110 | }
|
---|
| 2111 | }]
|
---|
| 2112 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { ttReorderableColumnDisabled: [{
|
---|
| 2113 | type: Input
|
---|
| 2114 | }], onDrop: [{
|
---|
| 2115 | type: HostListener,
|
---|
| 2116 | args: ['drop', ['$event']]
|
---|
| 2117 | }] } });
|
---|
| 2118 | class TTSelectableRow {
|
---|
| 2119 | constructor(tt, tableService) {
|
---|
| 2120 | this.tt = tt;
|
---|
| 2121 | this.tableService = tableService;
|
---|
| 2122 | if (this.isEnabled()) {
|
---|
| 2123 | this.subscription = this.tt.tableService.selectionSource$.subscribe(() => {
|
---|
| 2124 | this.selected = this.tt.isSelected(this.rowNode.node);
|
---|
| 2125 | });
|
---|
| 2126 | }
|
---|
| 2127 | }
|
---|
| 2128 | ngOnInit() {
|
---|
| 2129 | if (this.isEnabled()) {
|
---|
| 2130 | this.selected = this.tt.isSelected(this.rowNode.node);
|
---|
| 2131 | }
|
---|
| 2132 | }
|
---|
| 2133 | onClick(event) {
|
---|
| 2134 | if (this.isEnabled()) {
|
---|
| 2135 | this.tt.handleRowClick({
|
---|
| 2136 | originalEvent: event,
|
---|
| 2137 | rowNode: this.rowNode
|
---|
| 2138 | });
|
---|
| 2139 | }
|
---|
| 2140 | }
|
---|
| 2141 | onEnterKey(event) {
|
---|
| 2142 | if (event.which === 13) {
|
---|
| 2143 | this.onClick(event);
|
---|
| 2144 | }
|
---|
| 2145 | }
|
---|
| 2146 | onTouchEnd(event) {
|
---|
| 2147 | if (this.isEnabled()) {
|
---|
| 2148 | this.tt.handleRowTouchEnd(event);
|
---|
| 2149 | }
|
---|
| 2150 | }
|
---|
| 2151 | isEnabled() {
|
---|
| 2152 | return this.ttSelectableRowDisabled !== true;
|
---|
| 2153 | }
|
---|
| 2154 | ngOnDestroy() {
|
---|
| 2155 | if (this.subscription) {
|
---|
| 2156 | this.subscription.unsubscribe();
|
---|
| 2157 | }
|
---|
| 2158 | }
|
---|
| 2159 | }
|
---|
| 2160 | 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 });
|
---|
| 2161 | 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 });
|
---|
| 2162 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSelectableRow, decorators: [{
|
---|
| 2163 | type: Directive,
|
---|
| 2164 | args: [{
|
---|
| 2165 | selector: '[ttSelectableRow]',
|
---|
| 2166 | host: {
|
---|
| 2167 | 'class': 'p-element',
|
---|
| 2168 | '[class.p-highlight]': 'selected'
|
---|
| 2169 | }
|
---|
| 2170 | }]
|
---|
| 2171 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }]; }, propDecorators: { rowNode: [{
|
---|
| 2172 | type: Input,
|
---|
| 2173 | args: ["ttSelectableRow"]
|
---|
| 2174 | }], ttSelectableRowDisabled: [{
|
---|
| 2175 | type: Input
|
---|
| 2176 | }], onClick: [{
|
---|
| 2177 | type: HostListener,
|
---|
| 2178 | args: ['click', ['$event']]
|
---|
| 2179 | }], onEnterKey: [{
|
---|
| 2180 | type: HostListener,
|
---|
| 2181 | args: ['keydown', ['$event']]
|
---|
| 2182 | }], onTouchEnd: [{
|
---|
| 2183 | type: HostListener,
|
---|
| 2184 | args: ['touchend', ['$event']]
|
---|
| 2185 | }] } });
|
---|
| 2186 | class TTSelectableRowDblClick {
|
---|
| 2187 | constructor(tt, tableService) {
|
---|
| 2188 | this.tt = tt;
|
---|
| 2189 | this.tableService = tableService;
|
---|
| 2190 | if (this.isEnabled()) {
|
---|
| 2191 | this.subscription = this.tt.tableService.selectionSource$.subscribe(() => {
|
---|
| 2192 | this.selected = this.tt.isSelected(this.rowNode.node);
|
---|
| 2193 | });
|
---|
| 2194 | }
|
---|
| 2195 | }
|
---|
| 2196 | ngOnInit() {
|
---|
| 2197 | if (this.isEnabled()) {
|
---|
| 2198 | this.selected = this.tt.isSelected(this.rowNode.node);
|
---|
| 2199 | }
|
---|
| 2200 | }
|
---|
| 2201 | onClick(event) {
|
---|
| 2202 | if (this.isEnabled()) {
|
---|
| 2203 | this.tt.handleRowClick({
|
---|
| 2204 | originalEvent: event,
|
---|
| 2205 | rowNode: this.rowNode
|
---|
| 2206 | });
|
---|
| 2207 | }
|
---|
| 2208 | }
|
---|
| 2209 | isEnabled() {
|
---|
| 2210 | return this.ttSelectableRowDisabled !== true;
|
---|
| 2211 | }
|
---|
| 2212 | ngOnDestroy() {
|
---|
| 2213 | if (this.subscription) {
|
---|
| 2214 | this.subscription.unsubscribe();
|
---|
| 2215 | }
|
---|
| 2216 | }
|
---|
| 2217 | }
|
---|
| 2218 | 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 });
|
---|
| 2219 | 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 });
|
---|
| 2220 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTSelectableRowDblClick, decorators: [{
|
---|
| 2221 | type: Directive,
|
---|
| 2222 | args: [{
|
---|
| 2223 | selector: '[ttSelectableRowDblClick]',
|
---|
| 2224 | host: {
|
---|
| 2225 | 'class': 'p-element',
|
---|
| 2226 | '[class.p-highlight]': 'selected'
|
---|
| 2227 | }
|
---|
| 2228 | }]
|
---|
| 2229 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }]; }, propDecorators: { rowNode: [{
|
---|
| 2230 | type: Input,
|
---|
| 2231 | args: ["ttSelectableRowDblClick"]
|
---|
| 2232 | }], ttSelectableRowDisabled: [{
|
---|
| 2233 | type: Input
|
---|
| 2234 | }], onClick: [{
|
---|
| 2235 | type: HostListener,
|
---|
| 2236 | args: ['dblclick', ['$event']]
|
---|
| 2237 | }] } });
|
---|
| 2238 | class TTContextMenuRow {
|
---|
| 2239 | constructor(tt, tableService, el) {
|
---|
| 2240 | this.tt = tt;
|
---|
| 2241 | this.tableService = tableService;
|
---|
| 2242 | this.el = el;
|
---|
| 2243 | if (this.isEnabled()) {
|
---|
| 2244 | this.subscription = this.tt.tableService.contextMenuSource$.subscribe((node) => {
|
---|
| 2245 | this.selected = this.tt.equals(this.rowNode.node, node);
|
---|
| 2246 | });
|
---|
| 2247 | }
|
---|
| 2248 | }
|
---|
| 2249 | onContextMenu(event) {
|
---|
| 2250 | if (this.isEnabled()) {
|
---|
| 2251 | this.tt.handleRowRightClick({
|
---|
| 2252 | originalEvent: event,
|
---|
| 2253 | rowNode: this.rowNode
|
---|
| 2254 | });
|
---|
| 2255 | this.el.nativeElement.focus();
|
---|
| 2256 | event.preventDefault();
|
---|
| 2257 | }
|
---|
| 2258 | }
|
---|
| 2259 | isEnabled() {
|
---|
| 2260 | return this.ttContextMenuRowDisabled !== true;
|
---|
| 2261 | }
|
---|
| 2262 | ngOnDestroy() {
|
---|
| 2263 | if (this.subscription) {
|
---|
| 2264 | this.subscription.unsubscribe();
|
---|
| 2265 | }
|
---|
| 2266 | }
|
---|
| 2267 | }
|
---|
| 2268 | 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 });
|
---|
| 2269 | 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 });
|
---|
| 2270 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTContextMenuRow, decorators: [{
|
---|
| 2271 | type: Directive,
|
---|
| 2272 | args: [{
|
---|
| 2273 | selector: '[ttContextMenuRow]',
|
---|
| 2274 | host: {
|
---|
| 2275 | 'class': 'p-element',
|
---|
| 2276 | '[class.p-highlight-contextmenu]': 'selected',
|
---|
| 2277 | '[attr.tabindex]': 'isEnabled() ? 0 : undefined'
|
---|
| 2278 | }
|
---|
| 2279 | }]
|
---|
| 2280 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ElementRef }]; }, propDecorators: { rowNode: [{
|
---|
| 2281 | type: Input,
|
---|
| 2282 | args: ["ttContextMenuRow"]
|
---|
| 2283 | }], ttContextMenuRowDisabled: [{
|
---|
| 2284 | type: Input
|
---|
| 2285 | }], onContextMenu: [{
|
---|
| 2286 | type: HostListener,
|
---|
| 2287 | args: ['contextmenu', ['$event']]
|
---|
| 2288 | }] } });
|
---|
| 2289 | class TTCheckbox {
|
---|
| 2290 | constructor(tt, tableService, cd) {
|
---|
| 2291 | this.tt = tt;
|
---|
| 2292 | this.tableService = tableService;
|
---|
| 2293 | this.cd = cd;
|
---|
| 2294 | this.subscription = this.tt.tableService.selectionSource$.subscribe(() => {
|
---|
| 2295 | this.checked = this.tt.isSelected(this.rowNode.node);
|
---|
| 2296 | this.cd.markForCheck();
|
---|
| 2297 | });
|
---|
| 2298 | }
|
---|
| 2299 | ngOnInit() {
|
---|
| 2300 | this.checked = this.tt.isSelected(this.rowNode.node);
|
---|
| 2301 | }
|
---|
| 2302 | onClick(event) {
|
---|
| 2303 | if (!this.disabled) {
|
---|
| 2304 | this.tt.toggleNodeWithCheckbox({
|
---|
| 2305 | originalEvent: event,
|
---|
| 2306 | rowNode: this.rowNode
|
---|
| 2307 | });
|
---|
| 2308 | }
|
---|
| 2309 | DomHandler.clearSelection();
|
---|
| 2310 | }
|
---|
| 2311 | onFocus() {
|
---|
| 2312 | DomHandler.addClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 2313 | }
|
---|
| 2314 | onBlur() {
|
---|
| 2315 | DomHandler.removeClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 2316 | }
|
---|
| 2317 | ngOnDestroy() {
|
---|
| 2318 | if (this.subscription) {
|
---|
| 2319 | this.subscription.unsubscribe();
|
---|
| 2320 | }
|
---|
| 2321 | }
|
---|
| 2322 | }
|
---|
| 2323 | 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 });
|
---|
| 2324 | 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: `
|
---|
| 2325 | <div class="p-checkbox p-component" (click)="onClick($event)">
|
---|
| 2326 | <div class="p-hidden-accessible">
|
---|
| 2327 | <input type="checkbox" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()">
|
---|
| 2328 | </div>
|
---|
| 2329 | <div #box [ngClass]="{'p-checkbox-box':true,
|
---|
| 2330 | 'p-highlight':checked, 'p-indeterminate': rowNode.node.partialSelected, 'p-disabled':disabled}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 2331 | <span class="p-checkbox-icon pi" [ngClass]="{'pi-check':checked, 'pi-minus': rowNode.node.partialSelected}"></span>
|
---|
| 2332 | </div>
|
---|
| 2333 | </div>
|
---|
| 2334 | `, isInline: true, directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 2335 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTCheckbox, decorators: [{
|
---|
| 2336 | type: Component,
|
---|
| 2337 | args: [{
|
---|
| 2338 | selector: 'p-treeTableCheckbox',
|
---|
| 2339 | template: `
|
---|
| 2340 | <div class="p-checkbox p-component" (click)="onClick($event)">
|
---|
| 2341 | <div class="p-hidden-accessible">
|
---|
| 2342 | <input type="checkbox" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()">
|
---|
| 2343 | </div>
|
---|
| 2344 | <div #box [ngClass]="{'p-checkbox-box':true,
|
---|
| 2345 | 'p-highlight':checked, 'p-indeterminate': rowNode.node.partialSelected, 'p-disabled':disabled}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 2346 | <span class="p-checkbox-icon pi" [ngClass]="{'pi-check':checked, 'pi-minus': rowNode.node.partialSelected}"></span>
|
---|
| 2347 | </div>
|
---|
| 2348 | </div>
|
---|
| 2349 | `,
|
---|
| 2350 | encapsulation: ViewEncapsulation.None,
|
---|
| 2351 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 2352 | host: {
|
---|
| 2353 | 'class': 'p-element'
|
---|
| 2354 | }
|
---|
| 2355 | }]
|
---|
| 2356 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { disabled: [{
|
---|
| 2357 | type: Input
|
---|
| 2358 | }], rowNode: [{
|
---|
| 2359 | type: Input,
|
---|
| 2360 | args: ["value"]
|
---|
| 2361 | }], boxViewChild: [{
|
---|
| 2362 | type: ViewChild,
|
---|
| 2363 | args: ['box']
|
---|
| 2364 | }] } });
|
---|
| 2365 | class TTHeaderCheckbox {
|
---|
| 2366 | constructor(tt, tableService, cd) {
|
---|
| 2367 | this.tt = tt;
|
---|
| 2368 | this.tableService = tableService;
|
---|
| 2369 | this.cd = cd;
|
---|
| 2370 | this.valueChangeSubscription = this.tt.tableService.uiUpdateSource$.subscribe(() => {
|
---|
| 2371 | this.checked = this.updateCheckedState();
|
---|
| 2372 | });
|
---|
| 2373 | this.selectionChangeSubscription = this.tt.tableService.selectionSource$.subscribe(() => {
|
---|
| 2374 | this.checked = this.updateCheckedState();
|
---|
| 2375 | });
|
---|
| 2376 | }
|
---|
| 2377 | ngOnInit() {
|
---|
| 2378 | this.checked = this.updateCheckedState();
|
---|
| 2379 | }
|
---|
| 2380 | onClick(event, checked) {
|
---|
| 2381 | if (this.tt.value && this.tt.value.length > 0) {
|
---|
| 2382 | this.tt.toggleNodesWithCheckbox(event, !checked);
|
---|
| 2383 | }
|
---|
| 2384 | DomHandler.clearSelection();
|
---|
| 2385 | }
|
---|
| 2386 | onFocus() {
|
---|
| 2387 | DomHandler.addClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 2388 | }
|
---|
| 2389 | onBlur() {
|
---|
| 2390 | DomHandler.removeClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 2391 | }
|
---|
| 2392 | ngOnDestroy() {
|
---|
| 2393 | if (this.selectionChangeSubscription) {
|
---|
| 2394 | this.selectionChangeSubscription.unsubscribe();
|
---|
| 2395 | }
|
---|
| 2396 | if (this.valueChangeSubscription) {
|
---|
| 2397 | this.valueChangeSubscription.unsubscribe();
|
---|
| 2398 | }
|
---|
| 2399 | }
|
---|
| 2400 | updateCheckedState() {
|
---|
| 2401 | this.cd.markForCheck();
|
---|
| 2402 | let checked;
|
---|
| 2403 | const data = this.tt.filteredNodes || this.tt.value;
|
---|
| 2404 | if (data) {
|
---|
| 2405 | for (let node of data) {
|
---|
| 2406 | if (this.tt.isSelected(node)) {
|
---|
| 2407 | checked = true;
|
---|
| 2408 | }
|
---|
| 2409 | else {
|
---|
| 2410 | checked = false;
|
---|
| 2411 | break;
|
---|
| 2412 | }
|
---|
| 2413 | }
|
---|
| 2414 | }
|
---|
| 2415 | else {
|
---|
| 2416 | checked = false;
|
---|
| 2417 | }
|
---|
| 2418 | return checked;
|
---|
| 2419 | }
|
---|
| 2420 | }
|
---|
| 2421 | 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 });
|
---|
| 2422 | 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: `
|
---|
| 2423 | <div class="p-checkbox p-component" (click)="onClick($event, cb.checked)">
|
---|
| 2424 | <div class="p-hidden-accessible">
|
---|
| 2425 | <input #cb type="checkbox" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="!tt.value||tt.value.length === 0">
|
---|
| 2426 | </div>
|
---|
| 2427 | <div #box [ngClass]="{'p-checkbox-box':true,
|
---|
| 2428 | 'p-highlight':checked, 'p-disabled': (!tt.value || tt.value.length === 0)}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 2429 | <span class="p-checkbox-icon" [ngClass]="{'pi pi-check':checked}"></span>
|
---|
| 2430 | </div>
|
---|
| 2431 | </div>
|
---|
| 2432 | `, isInline: true, directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 2433 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTHeaderCheckbox, decorators: [{
|
---|
| 2434 | type: Component,
|
---|
| 2435 | args: [{
|
---|
| 2436 | selector: 'p-treeTableHeaderCheckbox',
|
---|
| 2437 | template: `
|
---|
| 2438 | <div class="p-checkbox p-component" (click)="onClick($event, cb.checked)">
|
---|
| 2439 | <div class="p-hidden-accessible">
|
---|
| 2440 | <input #cb type="checkbox" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="!tt.value||tt.value.length === 0">
|
---|
| 2441 | </div>
|
---|
| 2442 | <div #box [ngClass]="{'p-checkbox-box':true,
|
---|
| 2443 | 'p-highlight':checked, 'p-disabled': (!tt.value || tt.value.length === 0)}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 2444 | <span class="p-checkbox-icon" [ngClass]="{'pi pi-check':checked}"></span>
|
---|
| 2445 | </div>
|
---|
| 2446 | </div>
|
---|
| 2447 | `,
|
---|
| 2448 | encapsulation: ViewEncapsulation.None,
|
---|
| 2449 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 2450 | host: {
|
---|
| 2451 | 'class': 'p-element'
|
---|
| 2452 | }
|
---|
| 2453 | }]
|
---|
| 2454 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: TreeTableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { boxViewChild: [{
|
---|
| 2455 | type: ViewChild,
|
---|
| 2456 | args: ['box']
|
---|
| 2457 | }] } });
|
---|
| 2458 | class TTEditableColumn {
|
---|
| 2459 | constructor(tt, el, zone) {
|
---|
| 2460 | this.tt = tt;
|
---|
| 2461 | this.el = el;
|
---|
| 2462 | this.zone = zone;
|
---|
| 2463 | }
|
---|
| 2464 | ngAfterViewInit() {
|
---|
| 2465 | if (this.isEnabled()) {
|
---|
| 2466 | DomHandler.addClass(this.el.nativeElement, 'p-editable-column');
|
---|
| 2467 | }
|
---|
| 2468 | }
|
---|
| 2469 | onClick(event) {
|
---|
| 2470 | if (this.isEnabled()) {
|
---|
| 2471 | this.tt.editingCellClick = true;
|
---|
| 2472 | if (this.tt.editingCell) {
|
---|
| 2473 | if (this.tt.editingCell !== this.el.nativeElement) {
|
---|
| 2474 | if (!this.tt.isEditingCellValid()) {
|
---|
| 2475 | return;
|
---|
| 2476 | }
|
---|
| 2477 | DomHandler.removeClass(this.tt.editingCell, 'p-cell-editing');
|
---|
| 2478 | this.openCell();
|
---|
| 2479 | }
|
---|
| 2480 | }
|
---|
| 2481 | else {
|
---|
| 2482 | this.openCell();
|
---|
| 2483 | }
|
---|
| 2484 | }
|
---|
| 2485 | }
|
---|
| 2486 | openCell() {
|
---|
| 2487 | this.tt.updateEditingCell(this.el.nativeElement, this.data, this.field);
|
---|
| 2488 | DomHandler.addClass(this.el.nativeElement, 'p-cell-editing');
|
---|
| 2489 | this.tt.onEditInit.emit({ field: this.field, data: this.data });
|
---|
| 2490 | this.tt.editingCellClick = true;
|
---|
| 2491 | this.zone.runOutsideAngular(() => {
|
---|
| 2492 | setTimeout(() => {
|
---|
| 2493 | let focusable = DomHandler.findSingle(this.el.nativeElement, 'input, textarea');
|
---|
| 2494 | if (focusable) {
|
---|
| 2495 | focusable.focus();
|
---|
| 2496 | }
|
---|
| 2497 | }, 50);
|
---|
| 2498 | });
|
---|
| 2499 | }
|
---|
| 2500 | closeEditingCell() {
|
---|
| 2501 | DomHandler.removeClass(this.tt.editingCell, 'p-checkbox-icon');
|
---|
| 2502 | this.tt.editingCell = null;
|
---|
| 2503 | this.tt.unbindDocumentEditListener();
|
---|
| 2504 | }
|
---|
| 2505 | onKeyDown(event) {
|
---|
| 2506 | if (this.isEnabled()) {
|
---|
| 2507 | //enter
|
---|
| 2508 | if (event.keyCode == 13) {
|
---|
| 2509 | if (this.tt.isEditingCellValid()) {
|
---|
| 2510 | DomHandler.removeClass(this.tt.editingCell, 'p-cell-editing');
|
---|
| 2511 | this.closeEditingCell();
|
---|
| 2512 | this.tt.onEditComplete.emit({ field: this.field, data: this.data });
|
---|
| 2513 | }
|
---|
| 2514 | event.preventDefault();
|
---|
| 2515 | }
|
---|
| 2516 | //escape
|
---|
| 2517 | else if (event.keyCode == 27) {
|
---|
| 2518 | if (this.tt.isEditingCellValid()) {
|
---|
| 2519 | DomHandler.removeClass(this.tt.editingCell, 'p-cell-editing');
|
---|
| 2520 | this.closeEditingCell();
|
---|
| 2521 | this.tt.onEditCancel.emit({ field: this.field, data: this.data });
|
---|
| 2522 | }
|
---|
| 2523 | event.preventDefault();
|
---|
| 2524 | }
|
---|
| 2525 | //tab
|
---|
| 2526 | else if (event.keyCode == 9) {
|
---|
| 2527 | this.tt.onEditComplete.emit({ field: this.field, data: this.data });
|
---|
| 2528 | if (event.shiftKey)
|
---|
| 2529 | this.moveToPreviousCell(event);
|
---|
| 2530 | else
|
---|
| 2531 | this.moveToNextCell(event);
|
---|
| 2532 | }
|
---|
| 2533 | }
|
---|
| 2534 | }
|
---|
| 2535 | findCell(element) {
|
---|
| 2536 | if (element) {
|
---|
| 2537 | let cell = element;
|
---|
| 2538 | while (cell && !DomHandler.hasClass(cell, 'p-cell-editing')) {
|
---|
| 2539 | cell = cell.parentElement;
|
---|
| 2540 | }
|
---|
| 2541 | return cell;
|
---|
| 2542 | }
|
---|
| 2543 | else {
|
---|
| 2544 | return null;
|
---|
| 2545 | }
|
---|
| 2546 | }
|
---|
| 2547 | moveToPreviousCell(event) {
|
---|
| 2548 | let currentCell = this.findCell(event.target);
|
---|
| 2549 | let row = currentCell.parentElement;
|
---|
| 2550 | let targetCell = this.findPreviousEditableColumn(currentCell);
|
---|
| 2551 | if (targetCell) {
|
---|
| 2552 | DomHandler.invokeElementMethod(targetCell, 'click');
|
---|
| 2553 | event.preventDefault();
|
---|
| 2554 | }
|
---|
| 2555 | }
|
---|
| 2556 | moveToNextCell(event) {
|
---|
| 2557 | let currentCell = this.findCell(event.target);
|
---|
| 2558 | let row = currentCell.parentElement;
|
---|
| 2559 | let targetCell = this.findNextEditableColumn(currentCell);
|
---|
| 2560 | if (targetCell) {
|
---|
| 2561 | DomHandler.invokeElementMethod(targetCell, 'click');
|
---|
| 2562 | event.preventDefault();
|
---|
| 2563 | }
|
---|
| 2564 | }
|
---|
| 2565 | findPreviousEditableColumn(cell) {
|
---|
| 2566 | let prevCell = cell.previousElementSibling;
|
---|
| 2567 | if (!prevCell) {
|
---|
| 2568 | let previousRow = cell.parentElement ? cell.parentElement.previousElementSibling : null;
|
---|
| 2569 | if (previousRow) {
|
---|
| 2570 | prevCell = previousRow.lastElementChild;
|
---|
| 2571 | }
|
---|
| 2572 | }
|
---|
| 2573 | if (prevCell) {
|
---|
| 2574 | if (DomHandler.hasClass(prevCell, 'p-editable-column'))
|
---|
| 2575 | return prevCell;
|
---|
| 2576 | else
|
---|
| 2577 | return this.findPreviousEditableColumn(prevCell);
|
---|
| 2578 | }
|
---|
| 2579 | else {
|
---|
| 2580 | return null;
|
---|
| 2581 | }
|
---|
| 2582 | }
|
---|
| 2583 | findNextEditableColumn(cell) {
|
---|
| 2584 | let nextCell = cell.nextElementSibling;
|
---|
| 2585 | if (!nextCell) {
|
---|
| 2586 | let nextRow = cell.parentElement ? cell.parentElement.nextElementSibling : null;
|
---|
| 2587 | if (nextRow) {
|
---|
| 2588 | nextCell = nextRow.firstElementChild;
|
---|
| 2589 | }
|
---|
| 2590 | }
|
---|
| 2591 | if (nextCell) {
|
---|
| 2592 | if (DomHandler.hasClass(nextCell, 'p-editable-column'))
|
---|
| 2593 | return nextCell;
|
---|
| 2594 | else
|
---|
| 2595 | return this.findNextEditableColumn(nextCell);
|
---|
| 2596 | }
|
---|
| 2597 | else {
|
---|
| 2598 | return null;
|
---|
| 2599 | }
|
---|
| 2600 | }
|
---|
| 2601 | isEnabled() {
|
---|
| 2602 | return this.ttEditableColumnDisabled !== true;
|
---|
| 2603 | }
|
---|
| 2604 | }
|
---|
| 2605 | 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 });
|
---|
| 2606 | 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 });
|
---|
| 2607 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTEditableColumn, decorators: [{
|
---|
| 2608 | type: Directive,
|
---|
| 2609 | args: [{
|
---|
| 2610 | selector: '[ttEditableColumn]',
|
---|
| 2611 | host: {
|
---|
| 2612 | 'class': 'p-element'
|
---|
| 2613 | }
|
---|
| 2614 | }]
|
---|
| 2615 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { data: [{
|
---|
| 2616 | type: Input,
|
---|
| 2617 | args: ["ttEditableColumn"]
|
---|
| 2618 | }], field: [{
|
---|
| 2619 | type: Input,
|
---|
| 2620 | args: ["ttEditableColumnField"]
|
---|
| 2621 | }], ttEditableColumnDisabled: [{
|
---|
| 2622 | type: Input
|
---|
| 2623 | }], onClick: [{
|
---|
| 2624 | type: HostListener,
|
---|
| 2625 | args: ['click', ['$event']]
|
---|
| 2626 | }], onKeyDown: [{
|
---|
| 2627 | type: HostListener,
|
---|
| 2628 | args: ['keydown', ['$event']]
|
---|
| 2629 | }] } });
|
---|
| 2630 | class TreeTableCellEditor {
|
---|
| 2631 | constructor(tt, editableColumn) {
|
---|
| 2632 | this.tt = tt;
|
---|
| 2633 | this.editableColumn = editableColumn;
|
---|
| 2634 | }
|
---|
| 2635 | ngAfterContentInit() {
|
---|
| 2636 | this.templates.forEach((item) => {
|
---|
| 2637 | switch (item.getType()) {
|
---|
| 2638 | case 'input':
|
---|
| 2639 | this.inputTemplate = item.template;
|
---|
| 2640 | break;
|
---|
| 2641 | case 'output':
|
---|
| 2642 | this.outputTemplate = item.template;
|
---|
| 2643 | break;
|
---|
| 2644 | }
|
---|
| 2645 | });
|
---|
| 2646 | }
|
---|
| 2647 | }
|
---|
| 2648 | 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 });
|
---|
| 2649 | 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: `
|
---|
| 2650 | <ng-container *ngIf="tt.editingCell === editableColumn.el.nativeElement">
|
---|
| 2651 | <ng-container *ngTemplateOutlet="inputTemplate"></ng-container>
|
---|
| 2652 | </ng-container>
|
---|
| 2653 | <ng-container *ngIf="!tt.editingCell || tt.editingCell !== editableColumn.el.nativeElement">
|
---|
| 2654 | <ng-container *ngTemplateOutlet="outputTemplate"></ng-container>
|
---|
| 2655 | </ng-container>
|
---|
| 2656 | `, isInline: true, directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], encapsulation: i0.ViewEncapsulation.None });
|
---|
| 2657 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableCellEditor, decorators: [{
|
---|
| 2658 | type: Component,
|
---|
| 2659 | args: [{
|
---|
| 2660 | selector: 'p-treeTableCellEditor',
|
---|
| 2661 | template: `
|
---|
| 2662 | <ng-container *ngIf="tt.editingCell === editableColumn.el.nativeElement">
|
---|
| 2663 | <ng-container *ngTemplateOutlet="inputTemplate"></ng-container>
|
---|
| 2664 | </ng-container>
|
---|
| 2665 | <ng-container *ngIf="!tt.editingCell || tt.editingCell !== editableColumn.el.nativeElement">
|
---|
| 2666 | <ng-container *ngTemplateOutlet="outputTemplate"></ng-container>
|
---|
| 2667 | </ng-container>
|
---|
| 2668 | `,
|
---|
| 2669 | encapsulation: ViewEncapsulation.None,
|
---|
| 2670 | host: {
|
---|
| 2671 | 'class': 'p-element'
|
---|
| 2672 | }
|
---|
| 2673 | }]
|
---|
| 2674 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: TTEditableColumn }]; }, propDecorators: { templates: [{
|
---|
| 2675 | type: ContentChildren,
|
---|
| 2676 | args: [PrimeTemplate]
|
---|
| 2677 | }] } });
|
---|
| 2678 | class TTRow {
|
---|
| 2679 | constructor(tt, el, zone) {
|
---|
| 2680 | this.tt = tt;
|
---|
| 2681 | this.el = el;
|
---|
| 2682 | this.zone = zone;
|
---|
| 2683 | }
|
---|
| 2684 | onKeyDown(event) {
|
---|
| 2685 | switch (event.which) {
|
---|
| 2686 | //down arrow
|
---|
| 2687 | case 40:
|
---|
| 2688 | let nextRow = this.el.nativeElement.nextElementSibling;
|
---|
| 2689 | if (nextRow) {
|
---|
| 2690 | nextRow.focus();
|
---|
| 2691 | }
|
---|
| 2692 | event.preventDefault();
|
---|
| 2693 | break;
|
---|
| 2694 | //down arrow
|
---|
| 2695 | case 38:
|
---|
| 2696 | let prevRow = this.el.nativeElement.previousElementSibling;
|
---|
| 2697 | if (prevRow) {
|
---|
| 2698 | prevRow.focus();
|
---|
| 2699 | }
|
---|
| 2700 | event.preventDefault();
|
---|
| 2701 | break;
|
---|
| 2702 | //left arrow
|
---|
| 2703 | case 37:
|
---|
| 2704 | if (this.rowNode.node.expanded) {
|
---|
| 2705 | this.tt.toggleRowIndex = DomHandler.index(this.el.nativeElement);
|
---|
| 2706 | this.rowNode.node.expanded = false;
|
---|
| 2707 | this.tt.onNodeCollapse.emit({
|
---|
| 2708 | originalEvent: event,
|
---|
| 2709 | node: this.rowNode.node
|
---|
| 2710 | });
|
---|
| 2711 | this.tt.updateSerializedValue();
|
---|
| 2712 | this.tt.tableService.onUIUpdate(this.tt.value);
|
---|
| 2713 | this.restoreFocus();
|
---|
| 2714 | }
|
---|
| 2715 | break;
|
---|
| 2716 | //right arrow
|
---|
| 2717 | case 39:
|
---|
| 2718 | if (!this.rowNode.node.expanded) {
|
---|
| 2719 | this.tt.toggleRowIndex = DomHandler.index(this.el.nativeElement);
|
---|
| 2720 | this.rowNode.node.expanded = true;
|
---|
| 2721 | this.tt.onNodeExpand.emit({
|
---|
| 2722 | originalEvent: event,
|
---|
| 2723 | node: this.rowNode.node
|
---|
| 2724 | });
|
---|
| 2725 | this.tt.updateSerializedValue();
|
---|
| 2726 | this.tt.tableService.onUIUpdate(this.tt.value);
|
---|
| 2727 | this.restoreFocus();
|
---|
| 2728 | }
|
---|
| 2729 | break;
|
---|
| 2730 | }
|
---|
| 2731 | }
|
---|
| 2732 | restoreFocus() {
|
---|
| 2733 | this.zone.runOutsideAngular(() => {
|
---|
| 2734 | setTimeout(() => {
|
---|
| 2735 | let row = DomHandler.findSingle(this.tt.containerViewChild.nativeElement, '.p-treetable-tbody').children[this.tt.toggleRowIndex];
|
---|
| 2736 | if (row) {
|
---|
| 2737 | row.focus();
|
---|
| 2738 | }
|
---|
| 2739 | }, 25);
|
---|
| 2740 | });
|
---|
| 2741 | }
|
---|
| 2742 | }
|
---|
| 2743 | 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 });
|
---|
| 2744 | 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 });
|
---|
| 2745 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TTRow, decorators: [{
|
---|
| 2746 | type: Directive,
|
---|
| 2747 | args: [{
|
---|
| 2748 | selector: '[ttRow]',
|
---|
| 2749 | host: {
|
---|
| 2750 | 'class': 'p-element',
|
---|
| 2751 | '[attr.tabindex]': '"0"'
|
---|
| 2752 | }
|
---|
| 2753 | }]
|
---|
| 2754 | }], ctorParameters: function () { return [{ type: TreeTable }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { rowNode: [{
|
---|
| 2755 | type: Input,
|
---|
| 2756 | args: ['ttRow']
|
---|
| 2757 | }], onKeyDown: [{
|
---|
| 2758 | type: HostListener,
|
---|
| 2759 | args: ['keydown', ['$event']]
|
---|
| 2760 | }] } });
|
---|
| 2761 | class TreeTableToggler {
|
---|
| 2762 | constructor(tt) {
|
---|
| 2763 | this.tt = tt;
|
---|
| 2764 | }
|
---|
| 2765 | onClick(event) {
|
---|
| 2766 | this.rowNode.node.expanded = !this.rowNode.node.expanded;
|
---|
| 2767 | if (this.rowNode.node.expanded) {
|
---|
| 2768 | this.tt.onNodeExpand.emit({
|
---|
| 2769 | originalEvent: event,
|
---|
| 2770 | node: this.rowNode.node
|
---|
| 2771 | });
|
---|
| 2772 | }
|
---|
| 2773 | else {
|
---|
| 2774 | this.tt.onNodeCollapse.emit({
|
---|
| 2775 | originalEvent: event,
|
---|
| 2776 | node: this.rowNode.node
|
---|
| 2777 | });
|
---|
| 2778 | }
|
---|
| 2779 | this.tt.updateSerializedValue();
|
---|
| 2780 | this.tt.tableService.onUIUpdate(this.tt.value);
|
---|
| 2781 | event.preventDefault();
|
---|
| 2782 | }
|
---|
| 2783 | }
|
---|
| 2784 | TreeTableToggler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableToggler, deps: [{ token: TreeTable }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 2785 | 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: `
|
---|
| 2786 | <button type="button" class="p-treetable-toggler p-link" (click)="onClick($event)" tabindex="-1" pRipple
|
---|
| 2787 | [style.visibility]="rowNode.node.leaf === false || (rowNode.node.children && rowNode.node.children.length) ? 'visible' : 'hidden'" [style.marginLeft]="rowNode.level * 16 + 'px'">
|
---|
| 2788 | <i [ngClass]="rowNode.node.expanded ? 'pi pi-fw pi-chevron-down' : 'pi pi-fw pi-chevron-right'"></i>
|
---|
| 2789 | </button>
|
---|
| 2790 | `, isInline: true, directives: [{ type: i5.Ripple, selector: "[pRipple]" }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], encapsulation: i0.ViewEncapsulation.None });
|
---|
| 2791 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableToggler, decorators: [{
|
---|
| 2792 | type: Component,
|
---|
| 2793 | args: [{
|
---|
| 2794 | selector: 'p-treeTableToggler',
|
---|
| 2795 | template: `
|
---|
| 2796 | <button type="button" class="p-treetable-toggler p-link" (click)="onClick($event)" tabindex="-1" pRipple
|
---|
| 2797 | [style.visibility]="rowNode.node.leaf === false || (rowNode.node.children && rowNode.node.children.length) ? 'visible' : 'hidden'" [style.marginLeft]="rowNode.level * 16 + 'px'">
|
---|
| 2798 | <i [ngClass]="rowNode.node.expanded ? 'pi pi-fw pi-chevron-down' : 'pi pi-fw pi-chevron-right'"></i>
|
---|
| 2799 | </button>
|
---|
| 2800 | `,
|
---|
| 2801 | encapsulation: ViewEncapsulation.None,
|
---|
| 2802 | host: {
|
---|
| 2803 | 'class': 'p-element'
|
---|
| 2804 | }
|
---|
| 2805 | }]
|
---|
| 2806 | }], ctorParameters: function () { return [{ type: TreeTable }]; }, propDecorators: { rowNode: [{
|
---|
| 2807 | type: Input
|
---|
| 2808 | }] } });
|
---|
| 2809 | class TreeTableModule {
|
---|
| 2810 | }
|
---|
| 2811 | TreeTableModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
---|
| 2812 | 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] });
|
---|
| 2813 | TreeTableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableModule, imports: [[CommonModule, PaginatorModule, ScrollingModule, RippleModule], SharedModule, ScrollingModule] });
|
---|
| 2814 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TreeTableModule, decorators: [{
|
---|
| 2815 | type: NgModule,
|
---|
| 2816 | args: [{
|
---|
| 2817 | imports: [CommonModule, PaginatorModule, ScrollingModule, RippleModule],
|
---|
| 2818 | exports: [TreeTable, SharedModule, TreeTableToggler, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor, ScrollingModule],
|
---|
| 2819 | declarations: [TreeTable, TreeTableToggler, TTScrollableView, TTBody, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor]
|
---|
| 2820 | }]
|
---|
| 2821 | }] });
|
---|
| 2822 |
|
---|
| 2823 | /**
|
---|
| 2824 | * Generated bundle index. Do not edit.
|
---|
| 2825 | */
|
---|
| 2826 |
|
---|
| 2827 | export { TTBody, TTCheckbox, TTContextMenuRow, TTEditableColumn, TTHeaderCheckbox, TTReorderableColumn, TTResizableColumn, TTRow, TTScrollableView, TTSelectableRow, TTSelectableRowDblClick, TTSortIcon, TTSortableColumn, TreeTable, TreeTableCellEditor, TreeTableModule, TreeTableService, TreeTableToggler };
|
---|