[59329aa] | 1 | import * as i0 from '@angular/core';
|
---|
| 2 | import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, ContentChildren, Directive, HostListener, Optional, NgModule } from '@angular/core';
|
---|
| 3 | import * as i4 from '@angular/common';
|
---|
| 4 | import { CommonModule } from '@angular/common';
|
---|
| 5 | import * as i9 from '@angular/forms';
|
---|
| 6 | import { FormsModule } from '@angular/forms';
|
---|
| 7 | import * as i1 from 'primeng/api';
|
---|
| 8 | import { FilterOperator, FilterMatchMode, PrimeTemplate, TranslationKeys, SharedModule } from 'primeng/api';
|
---|
| 9 | import * as i2 from 'primeng/paginator';
|
---|
| 10 | import { PaginatorModule } from 'primeng/paginator';
|
---|
| 11 | import * as i8 from 'primeng/inputtext';
|
---|
| 12 | import { InputTextModule } from 'primeng/inputtext';
|
---|
| 13 | import * as i11 from 'primeng/button';
|
---|
| 14 | import { ButtonModule } from 'primeng/button';
|
---|
| 15 | import { SelectButtonModule } from 'primeng/selectbutton';
|
---|
| 16 | import * as i6 from 'primeng/tristatecheckbox';
|
---|
| 17 | import { TriStateCheckboxModule } from 'primeng/tristatecheckbox';
|
---|
| 18 | import * as i7 from 'primeng/calendar';
|
---|
| 19 | import { CalendarModule } from 'primeng/calendar';
|
---|
| 20 | import * as i5 from 'primeng/inputnumber';
|
---|
| 21 | import { InputNumberModule } from 'primeng/inputnumber';
|
---|
| 22 | import * as i10 from 'primeng/dropdown';
|
---|
| 23 | import { DropdownModule } from 'primeng/dropdown';
|
---|
| 24 | import { DomHandler, ConnectedOverlayScrollHandler } from 'primeng/dom';
|
---|
| 25 | import { UniqueComponentId, ObjectUtils, ZIndexUtils } from 'primeng/utils';
|
---|
| 26 | import { Subject } from 'rxjs';
|
---|
| 27 | import * as i3 from '@angular/cdk/scrolling';
|
---|
| 28 | import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
|
---|
| 29 | import { trigger, transition, style, animate } from '@angular/animations';
|
---|
| 30 |
|
---|
| 31 | class TableService {
|
---|
| 32 | constructor() {
|
---|
| 33 | this.sortSource = new Subject();
|
---|
| 34 | this.selectionSource = new Subject();
|
---|
| 35 | this.contextMenuSource = new Subject();
|
---|
| 36 | this.valueSource = new Subject();
|
---|
| 37 | this.totalRecordsSource = new Subject();
|
---|
| 38 | this.columnsSource = new Subject();
|
---|
| 39 | this.resetSource = new Subject();
|
---|
| 40 | this.sortSource$ = this.sortSource.asObservable();
|
---|
| 41 | this.selectionSource$ = this.selectionSource.asObservable();
|
---|
| 42 | this.contextMenuSource$ = this.contextMenuSource.asObservable();
|
---|
| 43 | this.valueSource$ = this.valueSource.asObservable();
|
---|
| 44 | this.totalRecordsSource$ = this.totalRecordsSource.asObservable();
|
---|
| 45 | this.columnsSource$ = this.columnsSource.asObservable();
|
---|
| 46 | this.resetSource$ = this.resetSource.asObservable();
|
---|
| 47 | }
|
---|
| 48 | onSort(sortMeta) {
|
---|
| 49 | this.sortSource.next(sortMeta);
|
---|
| 50 | }
|
---|
| 51 | onSelectionChange() {
|
---|
| 52 | this.selectionSource.next(null);
|
---|
| 53 | }
|
---|
| 54 | onResetChange() {
|
---|
| 55 | this.resetSource.next(null);
|
---|
| 56 | }
|
---|
| 57 | onContextMenu(data) {
|
---|
| 58 | this.contextMenuSource.next(data);
|
---|
| 59 | }
|
---|
| 60 | onValueChange(value) {
|
---|
| 61 | this.valueSource.next(value);
|
---|
| 62 | }
|
---|
| 63 | onTotalRecordsChange(value) {
|
---|
| 64 | this.totalRecordsSource.next(value);
|
---|
| 65 | }
|
---|
| 66 | onColumnsChange(columns) {
|
---|
| 67 | this.columnsSource.next(columns);
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 | TableService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
---|
| 71 | TableService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableService });
|
---|
| 72 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableService, decorators: [{
|
---|
| 73 | type: Injectable
|
---|
| 74 | }] });
|
---|
| 75 | class Table {
|
---|
| 76 | constructor(el, zone, tableService, cd, filterService, overlayService) {
|
---|
| 77 | this.el = el;
|
---|
| 78 | this.zone = zone;
|
---|
| 79 | this.tableService = tableService;
|
---|
| 80 | this.cd = cd;
|
---|
| 81 | this.filterService = filterService;
|
---|
| 82 | this.overlayService = overlayService;
|
---|
| 83 | this.pageLinks = 5;
|
---|
| 84 | this.alwaysShowPaginator = true;
|
---|
| 85 | this.paginatorPosition = 'bottom';
|
---|
| 86 | this.paginatorDropdownScrollHeight = '200px';
|
---|
| 87 | this.currentPageReportTemplate = '{currentPage} of {totalPages}';
|
---|
| 88 | this.showFirstLastIcon = true;
|
---|
| 89 | this.showPageLinks = true;
|
---|
| 90 | this.defaultSortOrder = 1;
|
---|
| 91 | this.sortMode = 'single';
|
---|
| 92 | this.resetPageOnSort = true;
|
---|
| 93 | this.selectionChange = new EventEmitter();
|
---|
| 94 | this.contextMenuSelectionChange = new EventEmitter();
|
---|
| 95 | this.contextMenuSelectionMode = "separate";
|
---|
| 96 | this.rowTrackBy = (index, item) => item;
|
---|
| 97 | this.lazy = false;
|
---|
| 98 | this.lazyLoadOnInit = true;
|
---|
| 99 | this.compareSelectionBy = 'deepEquals';
|
---|
| 100 | this.csvSeparator = ',';
|
---|
| 101 | this.exportFilename = 'download';
|
---|
| 102 | this.filters = {};
|
---|
| 103 | this.filterDelay = 300;
|
---|
| 104 | this.expandedRowKeys = {};
|
---|
| 105 | this.editingRowKeys = {};
|
---|
| 106 | this.rowExpandMode = 'multiple';
|
---|
| 107 | this.scrollDirection = "vertical";
|
---|
| 108 | this.virtualScrollDelay = 250;
|
---|
| 109 | this.virtualRowHeight = 28;
|
---|
| 110 | this.columnResizeMode = 'fit';
|
---|
| 111 | this.loadingIcon = 'pi pi-spinner';
|
---|
| 112 | this.showLoader = true;
|
---|
| 113 | this.showInitialSortBadge = true;
|
---|
| 114 | this.stateStorage = 'session';
|
---|
| 115 | this.editMode = 'cell';
|
---|
| 116 | this.groupRowsByOrder = 1;
|
---|
| 117 | this.responsiveLayout = 'stack';
|
---|
| 118 | this.breakpoint = '960px';
|
---|
| 119 | this.onRowSelect = new EventEmitter();
|
---|
| 120 | this.onRowUnselect = new EventEmitter();
|
---|
| 121 | this.onPage = new EventEmitter();
|
---|
| 122 | this.onSort = new EventEmitter();
|
---|
| 123 | this.onFilter = new EventEmitter();
|
---|
| 124 | this.onLazyLoad = new EventEmitter();
|
---|
| 125 | this.onRowExpand = new EventEmitter();
|
---|
| 126 | this.onRowCollapse = new EventEmitter();
|
---|
| 127 | this.onContextMenuSelect = new EventEmitter();
|
---|
| 128 | this.onColResize = new EventEmitter();
|
---|
| 129 | this.onColReorder = new EventEmitter();
|
---|
| 130 | this.onRowReorder = new EventEmitter();
|
---|
| 131 | this.onEditInit = new EventEmitter();
|
---|
| 132 | this.onEditComplete = new EventEmitter();
|
---|
| 133 | this.onEditCancel = new EventEmitter();
|
---|
| 134 | this.onHeaderCheckboxToggle = new EventEmitter();
|
---|
| 135 | this.sortFunction = new EventEmitter();
|
---|
| 136 | this.firstChange = new EventEmitter();
|
---|
| 137 | this.rowsChange = new EventEmitter();
|
---|
| 138 | this.onStateSave = new EventEmitter();
|
---|
| 139 | this.onStateRestore = new EventEmitter();
|
---|
| 140 | this._value = [];
|
---|
| 141 | this._totalRecords = 0;
|
---|
| 142 | this._first = 0;
|
---|
| 143 | this.selectionKeys = {};
|
---|
| 144 | this._sortOrder = 1;
|
---|
| 145 | this.columnResizing = false;
|
---|
| 146 | this.rowGroupHeaderStyleObject = {};
|
---|
| 147 | this.id = UniqueComponentId();
|
---|
| 148 | }
|
---|
| 149 | ngOnInit() {
|
---|
| 150 | if (this.lazy && this.lazyLoadOnInit) {
|
---|
| 151 | if (!this.virtualScroll) {
|
---|
| 152 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 153 | }
|
---|
| 154 | if (this.restoringFilter) {
|
---|
| 155 | this.restoringFilter = false;
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 | if (this.responsiveLayout === 'stack' && !this.scrollable) {
|
---|
| 159 | this.createResponsiveStyle();
|
---|
| 160 | }
|
---|
| 161 | this.initialized = true;
|
---|
| 162 | }
|
---|
| 163 | ngAfterContentInit() {
|
---|
| 164 | this.templates.forEach((item) => {
|
---|
| 165 | switch (item.getType()) {
|
---|
| 166 | case 'caption':
|
---|
| 167 | this.captionTemplate = item.template;
|
---|
| 168 | break;
|
---|
| 169 | case 'header':
|
---|
| 170 | this.headerTemplate = item.template;
|
---|
| 171 | break;
|
---|
| 172 | case 'headergrouped':
|
---|
| 173 | this.headerGroupedTemplate = item.template;
|
---|
| 174 | break;
|
---|
| 175 | case 'body':
|
---|
| 176 | this.bodyTemplate = item.template;
|
---|
| 177 | break;
|
---|
| 178 | case 'loadingbody':
|
---|
| 179 | this.loadingBodyTemplate = item.template;
|
---|
| 180 | break;
|
---|
| 181 | case 'footer':
|
---|
| 182 | this.footerTemplate = item.template;
|
---|
| 183 | break;
|
---|
| 184 | case 'footergrouped':
|
---|
| 185 | this.footerGroupedTemplate = item.template;
|
---|
| 186 | break;
|
---|
| 187 | case 'summary':
|
---|
| 188 | this.summaryTemplate = item.template;
|
---|
| 189 | break;
|
---|
| 190 | case 'colgroup':
|
---|
| 191 | this.colGroupTemplate = item.template;
|
---|
| 192 | break;
|
---|
| 193 | case 'rowexpansion':
|
---|
| 194 | this.expandedRowTemplate = item.template;
|
---|
| 195 | break;
|
---|
| 196 | case 'groupheader':
|
---|
| 197 | this.groupHeaderTemplate = item.template;
|
---|
| 198 | break;
|
---|
| 199 | case 'rowspan':
|
---|
| 200 | this.rowspanTemplate = item.template;
|
---|
| 201 | break;
|
---|
| 202 | case 'groupfooter':
|
---|
| 203 | this.groupFooterTemplate = item.template;
|
---|
| 204 | break;
|
---|
| 205 | case 'frozenrows':
|
---|
| 206 | this.frozenRowsTemplate = item.template;
|
---|
| 207 | break;
|
---|
| 208 | case 'frozenheader':
|
---|
| 209 | this.frozenHeaderTemplate = item.template;
|
---|
| 210 | break;
|
---|
| 211 | case 'frozenbody':
|
---|
| 212 | this.frozenBodyTemplate = item.template;
|
---|
| 213 | break;
|
---|
| 214 | case 'frozenfooter':
|
---|
| 215 | this.frozenFooterTemplate = item.template;
|
---|
| 216 | break;
|
---|
| 217 | case 'frozencolgroup':
|
---|
| 218 | this.frozenColGroupTemplate = item.template;
|
---|
| 219 | break;
|
---|
| 220 | case 'frozenrowexpansion':
|
---|
| 221 | this.frozenExpandedRowTemplate = item.template;
|
---|
| 222 | break;
|
---|
| 223 | case 'emptymessage':
|
---|
| 224 | this.emptyMessageTemplate = item.template;
|
---|
| 225 | break;
|
---|
| 226 | case 'paginatorleft':
|
---|
| 227 | this.paginatorLeftTemplate = item.template;
|
---|
| 228 | break;
|
---|
| 229 | case 'paginatorright':
|
---|
| 230 | this.paginatorRightTemplate = item.template;
|
---|
| 231 | break;
|
---|
| 232 | case 'paginatordropdownitem':
|
---|
| 233 | this.paginatorDropdownItemTemplate = item.template;
|
---|
| 234 | break;
|
---|
| 235 | }
|
---|
| 236 | });
|
---|
| 237 | }
|
---|
| 238 | ngAfterViewInit() {
|
---|
| 239 | if (this.isStateful() && this.resizableColumns) {
|
---|
| 240 | this.restoreColumnWidths();
|
---|
| 241 | }
|
---|
| 242 | if (this.scrollable && this.virtualScroll) {
|
---|
| 243 | this.virtualScrollSubscription = this.virtualScrollBody.renderedRangeStream.subscribe(range => {
|
---|
| 244 | let top = range.start * this.virtualRowHeight * -1;
|
---|
| 245 | this.tableHeaderViewChild.nativeElement.style.top = top + 'px';
|
---|
| 246 | });
|
---|
| 247 | }
|
---|
| 248 | }
|
---|
| 249 | ngOnChanges(simpleChange) {
|
---|
| 250 | if (simpleChange.value) {
|
---|
| 251 | if (this.isStateful() && !this.stateRestored) {
|
---|
| 252 | this.restoreState();
|
---|
| 253 | }
|
---|
| 254 | this._value = simpleChange.value.currentValue;
|
---|
| 255 | if (!this.lazy) {
|
---|
| 256 | this.totalRecords = (this._value ? this._value.length : 0);
|
---|
| 257 | if (this.sortMode == 'single' && (this.sortField || this.groupRowsBy))
|
---|
| 258 | this.sortSingle();
|
---|
| 259 | else if (this.sortMode == 'multiple' && (this.multiSortMeta || this.groupRowsBy))
|
---|
| 260 | this.sortMultiple();
|
---|
| 261 | else if (this.hasFilter()) //sort already filters
|
---|
| 262 | this._filter();
|
---|
| 263 | }
|
---|
| 264 | this.tableService.onValueChange(simpleChange.value.currentValue);
|
---|
| 265 | }
|
---|
| 266 | if (simpleChange.columns) {
|
---|
| 267 | this._columns = simpleChange.columns.currentValue;
|
---|
| 268 | this.tableService.onColumnsChange(simpleChange.columns.currentValue);
|
---|
| 269 | if (this._columns && this.isStateful() && this.reorderableColumns && !this.columnOrderStateRestored) {
|
---|
| 270 | this.restoreColumnOrder();
|
---|
| 271 | }
|
---|
| 272 | }
|
---|
| 273 | if (simpleChange.sortField) {
|
---|
| 274 | this._sortField = simpleChange.sortField.currentValue;
|
---|
| 275 | //avoid triggering lazy load prior to lazy initialization at onInit
|
---|
| 276 | if (!this.lazy || this.initialized) {
|
---|
| 277 | if (this.sortMode === 'single') {
|
---|
| 278 | this.sortSingle();
|
---|
| 279 | }
|
---|
| 280 | }
|
---|
| 281 | }
|
---|
| 282 | if (simpleChange.groupRowsBy) {
|
---|
| 283 | //avoid triggering lazy load prior to lazy initialization at onInit
|
---|
| 284 | if (!this.lazy || this.initialized) {
|
---|
| 285 | if (this.sortMode === 'single') {
|
---|
| 286 | this.sortSingle();
|
---|
| 287 | }
|
---|
| 288 | }
|
---|
| 289 | }
|
---|
| 290 | if (simpleChange.sortOrder) {
|
---|
| 291 | this._sortOrder = simpleChange.sortOrder.currentValue;
|
---|
| 292 | //avoid triggering lazy load prior to lazy initialization at onInit
|
---|
| 293 | if (!this.lazy || this.initialized) {
|
---|
| 294 | if (this.sortMode === 'single') {
|
---|
| 295 | this.sortSingle();
|
---|
| 296 | }
|
---|
| 297 | }
|
---|
| 298 | }
|
---|
| 299 | if (simpleChange.groupRowsByOrder) {
|
---|
| 300 | //avoid triggering lazy load prior to lazy initialization at onInit
|
---|
| 301 | if (!this.lazy || this.initialized) {
|
---|
| 302 | if (this.sortMode === 'single') {
|
---|
| 303 | this.sortSingle();
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 | if (simpleChange.multiSortMeta) {
|
---|
| 308 | this._multiSortMeta = simpleChange.multiSortMeta.currentValue;
|
---|
| 309 | if (this.sortMode === 'multiple' && (this.initialized || (!this.lazy && !this.virtualScroll))) {
|
---|
| 310 | this.sortMultiple();
|
---|
| 311 | }
|
---|
| 312 | }
|
---|
| 313 | if (simpleChange.selection) {
|
---|
| 314 | this._selection = simpleChange.selection.currentValue;
|
---|
| 315 | if (!this.preventSelectionSetterPropagation) {
|
---|
| 316 | this.updateSelectionKeys();
|
---|
| 317 | this.tableService.onSelectionChange();
|
---|
| 318 | }
|
---|
| 319 | this.preventSelectionSetterPropagation = false;
|
---|
| 320 | }
|
---|
| 321 | }
|
---|
| 322 | get value() {
|
---|
| 323 | return this._value;
|
---|
| 324 | }
|
---|
| 325 | set value(val) {
|
---|
| 326 | this._value = val;
|
---|
| 327 | }
|
---|
| 328 | get columns() {
|
---|
| 329 | return this._columns;
|
---|
| 330 | }
|
---|
| 331 | set columns(cols) {
|
---|
| 332 | this._columns = cols;
|
---|
| 333 | }
|
---|
| 334 | get first() {
|
---|
| 335 | return this._first;
|
---|
| 336 | }
|
---|
| 337 | set first(val) {
|
---|
| 338 | this._first = val;
|
---|
| 339 | }
|
---|
| 340 | get rows() {
|
---|
| 341 | return this._rows;
|
---|
| 342 | }
|
---|
| 343 | set rows(val) {
|
---|
| 344 | this._rows = val;
|
---|
| 345 | }
|
---|
| 346 | get totalRecords() {
|
---|
| 347 | return this._totalRecords;
|
---|
| 348 | }
|
---|
| 349 | set totalRecords(val) {
|
---|
| 350 | this._totalRecords = val;
|
---|
| 351 | this.tableService.onTotalRecordsChange(this._totalRecords);
|
---|
| 352 | }
|
---|
| 353 | get sortField() {
|
---|
| 354 | return this._sortField;
|
---|
| 355 | }
|
---|
| 356 | set sortField(val) {
|
---|
| 357 | this._sortField = val;
|
---|
| 358 | }
|
---|
| 359 | get sortOrder() {
|
---|
| 360 | return this._sortOrder;
|
---|
| 361 | }
|
---|
| 362 | set sortOrder(val) {
|
---|
| 363 | this._sortOrder = val;
|
---|
| 364 | }
|
---|
| 365 | get multiSortMeta() {
|
---|
| 366 | return this._multiSortMeta;
|
---|
| 367 | }
|
---|
| 368 | set multiSortMeta(val) {
|
---|
| 369 | this._multiSortMeta = val;
|
---|
| 370 | }
|
---|
| 371 | get selection() {
|
---|
| 372 | return this._selection;
|
---|
| 373 | }
|
---|
| 374 | set selection(val) {
|
---|
| 375 | this._selection = val;
|
---|
| 376 | }
|
---|
| 377 | get dataToRender() {
|
---|
| 378 | let data = this.filteredValue || this.value;
|
---|
| 379 | return data ? ((this.paginator && !this.lazy) ? (data.slice(this.first, this.first + this.rows)) : data) : [];
|
---|
| 380 | }
|
---|
| 381 | updateSelectionKeys() {
|
---|
| 382 | if (this.dataKey && this._selection) {
|
---|
| 383 | this.selectionKeys = {};
|
---|
| 384 | if (Array.isArray(this._selection)) {
|
---|
| 385 | for (let data of this._selection) {
|
---|
| 386 | this.selectionKeys[String(ObjectUtils.resolveFieldData(data, this.dataKey))] = 1;
|
---|
| 387 | }
|
---|
| 388 | }
|
---|
| 389 | else {
|
---|
| 390 | this.selectionKeys[String(ObjectUtils.resolveFieldData(this._selection, this.dataKey))] = 1;
|
---|
| 391 | }
|
---|
| 392 | }
|
---|
| 393 | }
|
---|
| 394 | onPageChange(event) {
|
---|
| 395 | this.first = event.first;
|
---|
| 396 | this.rows = event.rows;
|
---|
| 397 | if (this.lazy) {
|
---|
| 398 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 399 | }
|
---|
| 400 | this.onPage.emit({
|
---|
| 401 | first: this.first,
|
---|
| 402 | rows: this.rows
|
---|
| 403 | });
|
---|
| 404 | this.firstChange.emit(this.first);
|
---|
| 405 | this.rowsChange.emit(this.rows);
|
---|
| 406 | this.tableService.onValueChange(this.value);
|
---|
| 407 | if (this.isStateful()) {
|
---|
| 408 | this.saveState();
|
---|
| 409 | }
|
---|
| 410 | this.anchorRowIndex = null;
|
---|
| 411 | if (this.scrollable) {
|
---|
| 412 | this.resetScrollTop();
|
---|
| 413 | }
|
---|
| 414 | }
|
---|
| 415 | sort(event) {
|
---|
| 416 | let originalEvent = event.originalEvent;
|
---|
| 417 | if (this.sortMode === 'single') {
|
---|
| 418 | this._sortOrder = (this.sortField === event.field) ? this.sortOrder * -1 : this.defaultSortOrder;
|
---|
| 419 | this._sortField = event.field;
|
---|
| 420 | if (this.resetPageOnSort) {
|
---|
| 421 | this._first = 0;
|
---|
| 422 | this.firstChange.emit(this._first);
|
---|
| 423 | if (this.scrollable) {
|
---|
| 424 | this.resetScrollTop();
|
---|
| 425 | }
|
---|
| 426 | }
|
---|
| 427 | this.sortSingle();
|
---|
| 428 | }
|
---|
| 429 | if (this.sortMode === 'multiple') {
|
---|
| 430 | let metaKey = originalEvent.metaKey || originalEvent.ctrlKey;
|
---|
| 431 | let sortMeta = this.getSortMeta(event.field);
|
---|
| 432 | if (sortMeta) {
|
---|
| 433 | if (!metaKey) {
|
---|
| 434 | this._multiSortMeta = [{ field: event.field, order: sortMeta.order * -1 }];
|
---|
| 435 | if (this.resetPageOnSort) {
|
---|
| 436 | this._first = 0;
|
---|
| 437 | this.firstChange.emit(this._first);
|
---|
| 438 | if (this.scrollable) {
|
---|
| 439 | this.resetScrollTop();
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 | }
|
---|
| 443 | else {
|
---|
| 444 | sortMeta.order = sortMeta.order * -1;
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 | else {
|
---|
| 448 | if (!metaKey || !this.multiSortMeta) {
|
---|
| 449 | this._multiSortMeta = [];
|
---|
| 450 | if (this.resetPageOnSort) {
|
---|
| 451 | this._first = 0;
|
---|
| 452 | this.firstChange.emit(this._first);
|
---|
| 453 | }
|
---|
| 454 | }
|
---|
| 455 | this._multiSortMeta.push({ field: event.field, order: this.defaultSortOrder });
|
---|
| 456 | }
|
---|
| 457 | this.sortMultiple();
|
---|
| 458 | }
|
---|
| 459 | if (this.isStateful()) {
|
---|
| 460 | this.saveState();
|
---|
| 461 | }
|
---|
| 462 | this.anchorRowIndex = null;
|
---|
| 463 | }
|
---|
| 464 | sortSingle() {
|
---|
| 465 | let field = this.sortField || this.groupRowsBy;
|
---|
| 466 | let order = this.sortField ? this.sortOrder : this.groupRowsByOrder;
|
---|
| 467 | if (this.groupRowsBy && this.sortField && this.groupRowsBy !== this.sortField) {
|
---|
| 468 | this._multiSortMeta = [this.getGroupRowsMeta(), { field: this.sortField, order: this.sortOrder }];
|
---|
| 469 | this.sortMultiple();
|
---|
| 470 | return;
|
---|
| 471 | }
|
---|
| 472 | if (field && order) {
|
---|
| 473 | if (this.restoringSort) {
|
---|
| 474 | this.restoringSort = false;
|
---|
| 475 | }
|
---|
| 476 | if (this.lazy) {
|
---|
| 477 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 478 | }
|
---|
| 479 | else if (this.value) {
|
---|
| 480 | if (this.customSort) {
|
---|
| 481 | this.sortFunction.emit({
|
---|
| 482 | data: this.value,
|
---|
| 483 | mode: this.sortMode,
|
---|
| 484 | field: field,
|
---|
| 485 | order: order
|
---|
| 486 | });
|
---|
| 487 | }
|
---|
| 488 | else {
|
---|
| 489 | this.value.sort((data1, data2) => {
|
---|
| 490 | let value1 = ObjectUtils.resolveFieldData(data1, field);
|
---|
| 491 | let value2 = ObjectUtils.resolveFieldData(data2, field);
|
---|
| 492 | let result = null;
|
---|
| 493 | if (value1 == null && value2 != null)
|
---|
| 494 | result = -1;
|
---|
| 495 | else if (value1 != null && value2 == null)
|
---|
| 496 | result = 1;
|
---|
| 497 | else if (value1 == null && value2 == null)
|
---|
| 498 | result = 0;
|
---|
| 499 | else if (typeof value1 === 'string' && typeof value2 === 'string')
|
---|
| 500 | result = value1.localeCompare(value2);
|
---|
| 501 | else
|
---|
| 502 | result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;
|
---|
| 503 | return (order * result);
|
---|
| 504 | });
|
---|
| 505 | this._value = [...this.value];
|
---|
| 506 | }
|
---|
| 507 | if (this.hasFilter()) {
|
---|
| 508 | this._filter();
|
---|
| 509 | }
|
---|
| 510 | }
|
---|
| 511 | let sortMeta = {
|
---|
| 512 | field: field,
|
---|
| 513 | order: order
|
---|
| 514 | };
|
---|
| 515 | this.onSort.emit(sortMeta);
|
---|
| 516 | this.tableService.onSort(sortMeta);
|
---|
| 517 | }
|
---|
| 518 | }
|
---|
| 519 | sortMultiple() {
|
---|
| 520 | if (this.groupRowsBy) {
|
---|
| 521 | if (!this._multiSortMeta)
|
---|
| 522 | this._multiSortMeta = [this.getGroupRowsMeta()];
|
---|
| 523 | else if (this.multiSortMeta[0].field !== this.groupRowsBy)
|
---|
| 524 | this._multiSortMeta = [this.getGroupRowsMeta(), ...this._multiSortMeta];
|
---|
| 525 | }
|
---|
| 526 | if (this.multiSortMeta) {
|
---|
| 527 | if (this.lazy) {
|
---|
| 528 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 529 | }
|
---|
| 530 | else if (this.value) {
|
---|
| 531 | if (this.customSort) {
|
---|
| 532 | this.sortFunction.emit({
|
---|
| 533 | data: this.value,
|
---|
| 534 | mode: this.sortMode,
|
---|
| 535 | multiSortMeta: this.multiSortMeta
|
---|
| 536 | });
|
---|
| 537 | }
|
---|
| 538 | else {
|
---|
| 539 | this.value.sort((data1, data2) => {
|
---|
| 540 | return this.multisortField(data1, data2, this.multiSortMeta, 0);
|
---|
| 541 | });
|
---|
| 542 | this._value = [...this.value];
|
---|
| 543 | }
|
---|
| 544 | if (this.hasFilter()) {
|
---|
| 545 | this._filter();
|
---|
| 546 | }
|
---|
| 547 | }
|
---|
| 548 | this.onSort.emit({
|
---|
| 549 | multisortmeta: this.multiSortMeta
|
---|
| 550 | });
|
---|
| 551 | this.tableService.onSort(this.multiSortMeta);
|
---|
| 552 | }
|
---|
| 553 | }
|
---|
| 554 | multisortField(data1, data2, multiSortMeta, index) {
|
---|
| 555 | let value1 = ObjectUtils.resolveFieldData(data1, multiSortMeta[index].field);
|
---|
| 556 | let value2 = ObjectUtils.resolveFieldData(data2, multiSortMeta[index].field);
|
---|
| 557 | let result = null;
|
---|
| 558 | if (value1 == null && value2 != null)
|
---|
| 559 | result = -1;
|
---|
| 560 | else if (value1 != null && value2 == null)
|
---|
| 561 | result = 1;
|
---|
| 562 | else if (value1 == null && value2 == null)
|
---|
| 563 | result = 0;
|
---|
| 564 | else if (typeof value1 == 'string' || value1 instanceof String) {
|
---|
| 565 | if (value1.localeCompare && (value1 != value2)) {
|
---|
| 566 | return (multiSortMeta[index].order * value1.localeCompare(value2));
|
---|
| 567 | }
|
---|
| 568 | }
|
---|
| 569 | else {
|
---|
| 570 | result = (value1 < value2) ? -1 : 1;
|
---|
| 571 | }
|
---|
| 572 | if (value1 == value2) {
|
---|
| 573 | return (multiSortMeta.length - 1) > (index) ? (this.multisortField(data1, data2, multiSortMeta, index + 1)) : 0;
|
---|
| 574 | }
|
---|
| 575 | return (multiSortMeta[index].order * result);
|
---|
| 576 | }
|
---|
| 577 | getSortMeta(field) {
|
---|
| 578 | if (this.multiSortMeta && this.multiSortMeta.length) {
|
---|
| 579 | for (let i = 0; i < this.multiSortMeta.length; i++) {
|
---|
| 580 | if (this.multiSortMeta[i].field === field) {
|
---|
| 581 | return this.multiSortMeta[i];
|
---|
| 582 | }
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
| 585 | return null;
|
---|
| 586 | }
|
---|
| 587 | isSorted(field) {
|
---|
| 588 | if (this.sortMode === 'single') {
|
---|
| 589 | return (this.sortField && this.sortField === field);
|
---|
| 590 | }
|
---|
| 591 | else if (this.sortMode === 'multiple') {
|
---|
| 592 | let sorted = false;
|
---|
| 593 | if (this.multiSortMeta) {
|
---|
| 594 | for (let i = 0; i < this.multiSortMeta.length; i++) {
|
---|
| 595 | if (this.multiSortMeta[i].field == field) {
|
---|
| 596 | sorted = true;
|
---|
| 597 | break;
|
---|
| 598 | }
|
---|
| 599 | }
|
---|
| 600 | }
|
---|
| 601 | return sorted;
|
---|
| 602 | }
|
---|
| 603 | }
|
---|
| 604 | handleRowClick(event) {
|
---|
| 605 | let target = event.originalEvent.target;
|
---|
| 606 | let targetNode = target.nodeName;
|
---|
| 607 | let parentNode = target.parentElement && target.parentElement.nodeName;
|
---|
| 608 | if (targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A' ||
|
---|
| 609 | parentNode == 'INPUT' || parentNode == 'BUTTON' || parentNode == 'A' ||
|
---|
| 610 | (DomHandler.hasClass(event.originalEvent.target, 'p-clickable'))) {
|
---|
| 611 | return;
|
---|
| 612 | }
|
---|
| 613 | if (this.selectionMode) {
|
---|
| 614 | this.preventSelectionSetterPropagation = true;
|
---|
| 615 | if (this.isMultipleSelectionMode() && event.originalEvent.shiftKey && this.anchorRowIndex != null) {
|
---|
| 616 | DomHandler.clearSelection();
|
---|
| 617 | if (this.rangeRowIndex != null) {
|
---|
| 618 | this.clearSelectionRange(event.originalEvent);
|
---|
| 619 | }
|
---|
| 620 | this.rangeRowIndex = event.rowIndex;
|
---|
| 621 | this.selectRange(event.originalEvent, event.rowIndex);
|
---|
| 622 | }
|
---|
| 623 | else {
|
---|
| 624 | let rowData = event.rowData;
|
---|
| 625 | let selected = this.isSelected(rowData);
|
---|
| 626 | let metaSelection = this.rowTouched ? false : this.metaKeySelection;
|
---|
| 627 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(rowData, this.dataKey)) : null;
|
---|
| 628 | this.anchorRowIndex = event.rowIndex;
|
---|
| 629 | this.rangeRowIndex = event.rowIndex;
|
---|
| 630 | if (metaSelection) {
|
---|
| 631 | let metaKey = event.originalEvent.metaKey || event.originalEvent.ctrlKey;
|
---|
| 632 | if (selected && metaKey) {
|
---|
| 633 | if (this.isSingleSelectionMode()) {
|
---|
| 634 | this._selection = null;
|
---|
| 635 | this.selectionKeys = {};
|
---|
| 636 | this.selectionChange.emit(null);
|
---|
| 637 | }
|
---|
| 638 | else {
|
---|
| 639 | let selectionIndex = this.findIndexInSelection(rowData);
|
---|
| 640 | this._selection = this.selection.filter((val, i) => i != selectionIndex);
|
---|
| 641 | this.selectionChange.emit(this.selection);
|
---|
| 642 | if (dataKeyValue) {
|
---|
| 643 | delete this.selectionKeys[dataKeyValue];
|
---|
| 644 | }
|
---|
| 645 | }
|
---|
| 646 | this.onRowUnselect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row' });
|
---|
| 647 | }
|
---|
| 648 | else {
|
---|
| 649 | if (this.isSingleSelectionMode()) {
|
---|
| 650 | this._selection = rowData;
|
---|
| 651 | this.selectionChange.emit(rowData);
|
---|
| 652 | if (dataKeyValue) {
|
---|
| 653 | this.selectionKeys = {};
|
---|
| 654 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 655 | }
|
---|
| 656 | }
|
---|
| 657 | else if (this.isMultipleSelectionMode()) {
|
---|
| 658 | if (metaKey) {
|
---|
| 659 | this._selection = this.selection || [];
|
---|
| 660 | }
|
---|
| 661 | else {
|
---|
| 662 | this._selection = [];
|
---|
| 663 | this.selectionKeys = {};
|
---|
| 664 | }
|
---|
| 665 | this._selection = [...this.selection, rowData];
|
---|
| 666 | this.selectionChange.emit(this.selection);
|
---|
| 667 | if (dataKeyValue) {
|
---|
| 668 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 669 | }
|
---|
| 670 | }
|
---|
| 671 | this.onRowSelect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
|
---|
| 672 | }
|
---|
| 673 | }
|
---|
| 674 | else {
|
---|
| 675 | if (this.selectionMode === 'single') {
|
---|
| 676 | if (selected) {
|
---|
| 677 | this._selection = null;
|
---|
| 678 | this.selectionKeys = {};
|
---|
| 679 | this.selectionChange.emit(this.selection);
|
---|
| 680 | this.onRowUnselect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
|
---|
| 681 | }
|
---|
| 682 | else {
|
---|
| 683 | this._selection = rowData;
|
---|
| 684 | this.selectionChange.emit(this.selection);
|
---|
| 685 | this.onRowSelect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
|
---|
| 686 | if (dataKeyValue) {
|
---|
| 687 | this.selectionKeys = {};
|
---|
| 688 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 689 | }
|
---|
| 690 | }
|
---|
| 691 | }
|
---|
| 692 | else if (this.selectionMode === 'multiple') {
|
---|
| 693 | if (selected) {
|
---|
| 694 | let selectionIndex = this.findIndexInSelection(rowData);
|
---|
| 695 | this._selection = this.selection.filter((val, i) => i != selectionIndex);
|
---|
| 696 | this.selectionChange.emit(this.selection);
|
---|
| 697 | this.onRowUnselect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
|
---|
| 698 | if (dataKeyValue) {
|
---|
| 699 | delete this.selectionKeys[dataKeyValue];
|
---|
| 700 | }
|
---|
| 701 | }
|
---|
| 702 | else {
|
---|
| 703 | this._selection = this.selection ? [...this.selection, rowData] : [rowData];
|
---|
| 704 | this.selectionChange.emit(this.selection);
|
---|
| 705 | this.onRowSelect.emit({ originalEvent: event.originalEvent, data: rowData, type: 'row', index: event.rowIndex });
|
---|
| 706 | if (dataKeyValue) {
|
---|
| 707 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 708 | }
|
---|
| 709 | }
|
---|
| 710 | }
|
---|
| 711 | }
|
---|
| 712 | }
|
---|
| 713 | this.tableService.onSelectionChange();
|
---|
| 714 | if (this.isStateful()) {
|
---|
| 715 | this.saveState();
|
---|
| 716 | }
|
---|
| 717 | }
|
---|
| 718 | this.rowTouched = false;
|
---|
| 719 | }
|
---|
| 720 | handleRowTouchEnd(event) {
|
---|
| 721 | this.rowTouched = true;
|
---|
| 722 | }
|
---|
| 723 | handleRowRightClick(event) {
|
---|
| 724 | if (this.contextMenu) {
|
---|
| 725 | const rowData = event.rowData;
|
---|
| 726 | if (this.contextMenuSelectionMode === 'separate') {
|
---|
| 727 | this.contextMenuSelection = rowData;
|
---|
| 728 | this.contextMenuSelectionChange.emit(rowData);
|
---|
| 729 | this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, data: rowData, index: event.rowIndex });
|
---|
| 730 | this.contextMenu.show(event.originalEvent);
|
---|
| 731 | this.tableService.onContextMenu(rowData);
|
---|
| 732 | }
|
---|
| 733 | else if (this.contextMenuSelectionMode === 'joint') {
|
---|
| 734 | this.preventSelectionSetterPropagation = true;
|
---|
| 735 | let selected = this.isSelected(rowData);
|
---|
| 736 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(rowData, this.dataKey)) : null;
|
---|
| 737 | if (!selected) {
|
---|
| 738 | if (this.isSingleSelectionMode()) {
|
---|
| 739 | this.selection = rowData;
|
---|
| 740 | this.selectionChange.emit(rowData);
|
---|
| 741 | if (dataKeyValue) {
|
---|
| 742 | this.selectionKeys = {};
|
---|
| 743 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 744 | }
|
---|
| 745 | }
|
---|
| 746 | else if (this.isMultipleSelectionMode()) {
|
---|
| 747 | this._selection = this.selection ? [...this.selection, rowData] : [rowData];
|
---|
| 748 | this.selectionChange.emit(this.selection);
|
---|
| 749 | if (dataKeyValue) {
|
---|
| 750 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 751 | }
|
---|
| 752 | }
|
---|
| 753 | }
|
---|
| 754 | this.tableService.onSelectionChange();
|
---|
| 755 | this.contextMenu.show(event.originalEvent);
|
---|
| 756 | this.onContextMenuSelect.emit({ originalEvent: event, data: rowData, index: event.rowIndex });
|
---|
| 757 | }
|
---|
| 758 | }
|
---|
| 759 | }
|
---|
| 760 | selectRange(event, rowIndex) {
|
---|
| 761 | let rangeStart, rangeEnd;
|
---|
| 762 | if (this.anchorRowIndex > rowIndex) {
|
---|
| 763 | rangeStart = rowIndex;
|
---|
| 764 | rangeEnd = this.anchorRowIndex;
|
---|
| 765 | }
|
---|
| 766 | else if (this.anchorRowIndex < rowIndex) {
|
---|
| 767 | rangeStart = this.anchorRowIndex;
|
---|
| 768 | rangeEnd = rowIndex;
|
---|
| 769 | }
|
---|
| 770 | else {
|
---|
| 771 | rangeStart = rowIndex;
|
---|
| 772 | rangeEnd = rowIndex;
|
---|
| 773 | }
|
---|
| 774 | if (this.lazy && this.paginator) {
|
---|
| 775 | rangeStart -= this.first;
|
---|
| 776 | rangeEnd -= this.first;
|
---|
| 777 | }
|
---|
| 778 | let rangeRowsData = [];
|
---|
| 779 | for (let i = rangeStart; i <= rangeEnd; i++) {
|
---|
| 780 | let rangeRowData = this.filteredValue ? this.filteredValue[i] : this.value[i];
|
---|
| 781 | if (!this.isSelected(rangeRowData)) {
|
---|
| 782 | rangeRowsData.push(rangeRowData);
|
---|
| 783 | this._selection = [...this.selection, rangeRowData];
|
---|
| 784 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(rangeRowData, this.dataKey)) : null;
|
---|
| 785 | if (dataKeyValue) {
|
---|
| 786 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 787 | }
|
---|
| 788 | }
|
---|
| 789 | }
|
---|
| 790 | this.selectionChange.emit(this.selection);
|
---|
| 791 | this.onRowSelect.emit({ originalEvent: event, data: rangeRowsData, type: 'row' });
|
---|
| 792 | }
|
---|
| 793 | clearSelectionRange(event) {
|
---|
| 794 | let rangeStart, rangeEnd;
|
---|
| 795 | if (this.rangeRowIndex > this.anchorRowIndex) {
|
---|
| 796 | rangeStart = this.anchorRowIndex;
|
---|
| 797 | rangeEnd = this.rangeRowIndex;
|
---|
| 798 | }
|
---|
| 799 | else if (this.rangeRowIndex < this.anchorRowIndex) {
|
---|
| 800 | rangeStart = this.rangeRowIndex;
|
---|
| 801 | rangeEnd = this.anchorRowIndex;
|
---|
| 802 | }
|
---|
| 803 | else {
|
---|
| 804 | rangeStart = this.rangeRowIndex;
|
---|
| 805 | rangeEnd = this.rangeRowIndex;
|
---|
| 806 | }
|
---|
| 807 | for (let i = rangeStart; i <= rangeEnd; i++) {
|
---|
| 808 | let rangeRowData = this.value[i];
|
---|
| 809 | let selectionIndex = this.findIndexInSelection(rangeRowData);
|
---|
| 810 | this._selection = this.selection.filter((val, i) => i != selectionIndex);
|
---|
| 811 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(rangeRowData, this.dataKey)) : null;
|
---|
| 812 | if (dataKeyValue) {
|
---|
| 813 | delete this.selectionKeys[dataKeyValue];
|
---|
| 814 | }
|
---|
| 815 | this.onRowUnselect.emit({ originalEvent: event, data: rangeRowData, type: 'row' });
|
---|
| 816 | }
|
---|
| 817 | }
|
---|
| 818 | isSelected(rowData) {
|
---|
| 819 | if (rowData && this.selection) {
|
---|
| 820 | if (this.dataKey) {
|
---|
| 821 | return this.selectionKeys[ObjectUtils.resolveFieldData(rowData, this.dataKey)] !== undefined;
|
---|
| 822 | }
|
---|
| 823 | else {
|
---|
| 824 | if (this.selection instanceof Array)
|
---|
| 825 | return this.findIndexInSelection(rowData) > -1;
|
---|
| 826 | else
|
---|
| 827 | return this.equals(rowData, this.selection);
|
---|
| 828 | }
|
---|
| 829 | }
|
---|
| 830 | return false;
|
---|
| 831 | }
|
---|
| 832 | findIndexInSelection(rowData) {
|
---|
| 833 | let index = -1;
|
---|
| 834 | if (this.selection && this.selection.length) {
|
---|
| 835 | for (let i = 0; i < this.selection.length; i++) {
|
---|
| 836 | if (this.equals(rowData, this.selection[i])) {
|
---|
| 837 | index = i;
|
---|
| 838 | break;
|
---|
| 839 | }
|
---|
| 840 | }
|
---|
| 841 | }
|
---|
| 842 | return index;
|
---|
| 843 | }
|
---|
| 844 | toggleRowWithRadio(event, rowData) {
|
---|
| 845 | this.preventSelectionSetterPropagation = true;
|
---|
| 846 | if (this.selection != rowData) {
|
---|
| 847 | this._selection = rowData;
|
---|
| 848 | this.selectionChange.emit(this.selection);
|
---|
| 849 | this.onRowSelect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'radiobutton' });
|
---|
| 850 | if (this.dataKey) {
|
---|
| 851 | this.selectionKeys = {};
|
---|
| 852 | this.selectionKeys[String(ObjectUtils.resolveFieldData(rowData, this.dataKey))] = 1;
|
---|
| 853 | }
|
---|
| 854 | }
|
---|
| 855 | else {
|
---|
| 856 | this._selection = null;
|
---|
| 857 | this.selectionChange.emit(this.selection);
|
---|
| 858 | this.onRowUnselect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'radiobutton' });
|
---|
| 859 | }
|
---|
| 860 | this.tableService.onSelectionChange();
|
---|
| 861 | if (this.isStateful()) {
|
---|
| 862 | this.saveState();
|
---|
| 863 | }
|
---|
| 864 | }
|
---|
| 865 | toggleRowWithCheckbox(event, rowData) {
|
---|
| 866 | this.selection = this.selection || [];
|
---|
| 867 | let selected = this.isSelected(rowData);
|
---|
| 868 | let dataKeyValue = this.dataKey ? String(ObjectUtils.resolveFieldData(rowData, this.dataKey)) : null;
|
---|
| 869 | this.preventSelectionSetterPropagation = true;
|
---|
| 870 | if (selected) {
|
---|
| 871 | let selectionIndex = this.findIndexInSelection(rowData);
|
---|
| 872 | this._selection = this.selection.filter((val, i) => i != selectionIndex);
|
---|
| 873 | this.selectionChange.emit(this.selection);
|
---|
| 874 | this.onRowUnselect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'checkbox' });
|
---|
| 875 | if (dataKeyValue) {
|
---|
| 876 | delete this.selectionKeys[dataKeyValue];
|
---|
| 877 | }
|
---|
| 878 | }
|
---|
| 879 | else {
|
---|
| 880 | this._selection = this.selection ? [...this.selection, rowData] : [rowData];
|
---|
| 881 | this.selectionChange.emit(this.selection);
|
---|
| 882 | this.onRowSelect.emit({ originalEvent: event.originalEvent, index: event.rowIndex, data: rowData, type: 'checkbox' });
|
---|
| 883 | if (dataKeyValue) {
|
---|
| 884 | this.selectionKeys[dataKeyValue] = 1;
|
---|
| 885 | }
|
---|
| 886 | }
|
---|
| 887 | this.tableService.onSelectionChange();
|
---|
| 888 | if (this.isStateful()) {
|
---|
| 889 | this.saveState();
|
---|
| 890 | }
|
---|
| 891 | }
|
---|
| 892 | toggleRowsWithCheckbox(event, check) {
|
---|
| 893 | this._selection = check ? this.filteredValue ? this.filteredValue.slice() : this.value.slice() : [];
|
---|
| 894 | this.preventSelectionSetterPropagation = true;
|
---|
| 895 | this.updateSelectionKeys();
|
---|
| 896 | this.selectionChange.emit(this._selection);
|
---|
| 897 | this.tableService.onSelectionChange();
|
---|
| 898 | this.onHeaderCheckboxToggle.emit({ originalEvent: event, checked: check });
|
---|
| 899 | if (this.isStateful()) {
|
---|
| 900 | this.saveState();
|
---|
| 901 | }
|
---|
| 902 | }
|
---|
| 903 | equals(data1, data2) {
|
---|
| 904 | return this.compareSelectionBy === 'equals' ? (data1 === data2) : ObjectUtils.equals(data1, data2, this.dataKey);
|
---|
| 905 | }
|
---|
| 906 | /* Legacy Filtering for custom elements */
|
---|
| 907 | filter(value, field, matchMode) {
|
---|
| 908 | if (this.filterTimeout) {
|
---|
| 909 | clearTimeout(this.filterTimeout);
|
---|
| 910 | }
|
---|
| 911 | if (!this.isFilterBlank(value)) {
|
---|
| 912 | this.filters[field] = { value: value, matchMode: matchMode };
|
---|
| 913 | }
|
---|
| 914 | else if (this.filters[field]) {
|
---|
| 915 | delete this.filters[field];
|
---|
| 916 | }
|
---|
| 917 | this.filterTimeout = setTimeout(() => {
|
---|
| 918 | this._filter();
|
---|
| 919 | this.filterTimeout = null;
|
---|
| 920 | }, this.filterDelay);
|
---|
| 921 | this.anchorRowIndex = null;
|
---|
| 922 | }
|
---|
| 923 | filterGlobal(value, matchMode) {
|
---|
| 924 | this.filter(value, 'global', matchMode);
|
---|
| 925 | }
|
---|
| 926 | isFilterBlank(filter) {
|
---|
| 927 | if (filter !== null && filter !== undefined) {
|
---|
| 928 | if ((typeof filter === 'string' && filter.trim().length == 0) || (filter instanceof Array && filter.length == 0))
|
---|
| 929 | return true;
|
---|
| 930 | else
|
---|
| 931 | return false;
|
---|
| 932 | }
|
---|
| 933 | return true;
|
---|
| 934 | }
|
---|
| 935 | _filter() {
|
---|
| 936 | if (!this.restoringFilter) {
|
---|
| 937 | this.first = 0;
|
---|
| 938 | this.firstChange.emit(this.first);
|
---|
| 939 | }
|
---|
| 940 | if (this.lazy) {
|
---|
| 941 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 942 | }
|
---|
| 943 | else {
|
---|
| 944 | if (!this.value) {
|
---|
| 945 | return;
|
---|
| 946 | }
|
---|
| 947 | if (!this.hasFilter()) {
|
---|
| 948 | this.filteredValue = null;
|
---|
| 949 | if (this.paginator) {
|
---|
| 950 | this.totalRecords = this.value ? this.value.length : 0;
|
---|
| 951 | }
|
---|
| 952 | }
|
---|
| 953 | else {
|
---|
| 954 | let globalFilterFieldsArray;
|
---|
| 955 | if (this.filters['global']) {
|
---|
| 956 | if (!this.columns && !this.globalFilterFields)
|
---|
| 957 | throw new Error('Global filtering requires dynamic columns or globalFilterFields to be defined.');
|
---|
| 958 | else
|
---|
| 959 | globalFilterFieldsArray = this.globalFilterFields || this.columns;
|
---|
| 960 | }
|
---|
| 961 | this.filteredValue = [];
|
---|
| 962 | for (let i = 0; i < this.value.length; i++) {
|
---|
| 963 | let localMatch = true;
|
---|
| 964 | let globalMatch = false;
|
---|
| 965 | let localFiltered = false;
|
---|
| 966 | for (let prop in this.filters) {
|
---|
| 967 | if (this.filters.hasOwnProperty(prop) && prop !== 'global') {
|
---|
| 968 | localFiltered = true;
|
---|
| 969 | let filterField = prop;
|
---|
| 970 | let filterMeta = this.filters[filterField];
|
---|
| 971 | if (Array.isArray(filterMeta)) {
|
---|
| 972 | for (let meta of filterMeta) {
|
---|
| 973 | localMatch = this.executeLocalFilter(filterField, this.value[i], meta);
|
---|
| 974 | if ((meta.operator === FilterOperator.OR && localMatch) || (meta.operator === FilterOperator.AND && !localMatch)) {
|
---|
| 975 | break;
|
---|
| 976 | }
|
---|
| 977 | }
|
---|
| 978 | }
|
---|
| 979 | else {
|
---|
| 980 | localMatch = this.executeLocalFilter(filterField, this.value[i], filterMeta);
|
---|
| 981 | }
|
---|
| 982 | if (!localMatch) {
|
---|
| 983 | break;
|
---|
| 984 | }
|
---|
| 985 | }
|
---|
| 986 | }
|
---|
| 987 | if (this.filters['global'] && !globalMatch && globalFilterFieldsArray) {
|
---|
| 988 | for (let j = 0; j < globalFilterFieldsArray.length; j++) {
|
---|
| 989 | let globalFilterField = globalFilterFieldsArray[j].field || globalFilterFieldsArray[j];
|
---|
| 990 | globalMatch = this.filterService.filters[this.filters['global'].matchMode](ObjectUtils.resolveFieldData(this.value[i], globalFilterField), this.filters['global'].value, this.filterLocale);
|
---|
| 991 | if (globalMatch) {
|
---|
| 992 | break;
|
---|
| 993 | }
|
---|
| 994 | }
|
---|
| 995 | }
|
---|
| 996 | let matches;
|
---|
| 997 | if (this.filters['global']) {
|
---|
| 998 | matches = localFiltered ? (localFiltered && localMatch && globalMatch) : globalMatch;
|
---|
| 999 | }
|
---|
| 1000 | else {
|
---|
| 1001 | matches = localFiltered && localMatch;
|
---|
| 1002 | }
|
---|
| 1003 | if (matches) {
|
---|
| 1004 | this.filteredValue.push(this.value[i]);
|
---|
| 1005 | }
|
---|
| 1006 | }
|
---|
| 1007 | if (this.filteredValue.length === this.value.length) {
|
---|
| 1008 | this.filteredValue = null;
|
---|
| 1009 | }
|
---|
| 1010 | if (this.paginator) {
|
---|
| 1011 | this.totalRecords = this.filteredValue ? this.filteredValue.length : this.value ? this.value.length : 0;
|
---|
| 1012 | }
|
---|
| 1013 | }
|
---|
| 1014 | }
|
---|
| 1015 | this.onFilter.emit({
|
---|
| 1016 | filters: this.filters,
|
---|
| 1017 | filteredValue: this.filteredValue || this.value
|
---|
| 1018 | });
|
---|
| 1019 | this.tableService.onValueChange(this.value);
|
---|
| 1020 | if (this.isStateful() && !this.restoringFilter) {
|
---|
| 1021 | this.saveState();
|
---|
| 1022 | }
|
---|
| 1023 | if (this.restoringFilter) {
|
---|
| 1024 | this.restoringFilter = false;
|
---|
| 1025 | }
|
---|
| 1026 | this.cd.markForCheck();
|
---|
| 1027 | if (this.scrollable) {
|
---|
| 1028 | this.resetScrollTop();
|
---|
| 1029 | }
|
---|
| 1030 | }
|
---|
| 1031 | executeLocalFilter(field, rowData, filterMeta) {
|
---|
| 1032 | let filterValue = filterMeta.value;
|
---|
| 1033 | let filterMatchMode = filterMeta.matchMode || FilterMatchMode.STARTS_WITH;
|
---|
| 1034 | let dataFieldValue = ObjectUtils.resolveFieldData(rowData, field);
|
---|
| 1035 | let filterConstraint = this.filterService.filters[filterMatchMode];
|
---|
| 1036 | return filterConstraint(dataFieldValue, filterValue, this.filterLocale);
|
---|
| 1037 | }
|
---|
| 1038 | hasFilter() {
|
---|
| 1039 | let empty = true;
|
---|
| 1040 | for (let prop in this.filters) {
|
---|
| 1041 | if (this.filters.hasOwnProperty(prop)) {
|
---|
| 1042 | empty = false;
|
---|
| 1043 | break;
|
---|
| 1044 | }
|
---|
| 1045 | }
|
---|
| 1046 | return !empty;
|
---|
| 1047 | }
|
---|
| 1048 | createLazyLoadMetadata() {
|
---|
| 1049 | return {
|
---|
| 1050 | first: this.first,
|
---|
| 1051 | rows: this.rows,
|
---|
| 1052 | sortField: this.sortField,
|
---|
| 1053 | sortOrder: this.sortOrder,
|
---|
| 1054 | filters: this.filters,
|
---|
| 1055 | globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null,
|
---|
| 1056 | multiSortMeta: this.multiSortMeta
|
---|
| 1057 | };
|
---|
| 1058 | }
|
---|
| 1059 | clear() {
|
---|
| 1060 | this._sortField = null;
|
---|
| 1061 | this._sortOrder = this.defaultSortOrder;
|
---|
| 1062 | this._multiSortMeta = null;
|
---|
| 1063 | this.tableService.onSort(null);
|
---|
| 1064 | this.filteredValue = null;
|
---|
| 1065 | this.tableService.onResetChange();
|
---|
| 1066 | this.first = 0;
|
---|
| 1067 | this.firstChange.emit(this.first);
|
---|
| 1068 | if (this.lazy) {
|
---|
| 1069 | this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
---|
| 1070 | }
|
---|
| 1071 | else {
|
---|
| 1072 | this.totalRecords = (this._value ? this._value.length : 0);
|
---|
| 1073 | }
|
---|
| 1074 | }
|
---|
| 1075 | reset() {
|
---|
| 1076 | this.clear();
|
---|
| 1077 | }
|
---|
| 1078 | exportCSV(options) {
|
---|
| 1079 | let data;
|
---|
| 1080 | let csv = '';
|
---|
| 1081 | let columns = this.frozenColumns ? [...this.frozenColumns, ...this.columns] : this.columns;
|
---|
| 1082 | if (options && options.selectionOnly) {
|
---|
| 1083 | data = this.selection || [];
|
---|
| 1084 | }
|
---|
| 1085 | else {
|
---|
| 1086 | data = this.filteredValue || this.value;
|
---|
| 1087 | if (this.frozenValue) {
|
---|
| 1088 | data = data ? [...this.frozenValue, ...data] : this.frozenValue;
|
---|
| 1089 | }
|
---|
| 1090 | }
|
---|
| 1091 | //headers
|
---|
| 1092 | for (let i = 0; i < columns.length; i++) {
|
---|
| 1093 | let column = columns[i];
|
---|
| 1094 | if (column.exportable !== false && column.field) {
|
---|
| 1095 | csv += '"' + (column.header || column.field) + '"';
|
---|
| 1096 | if (i < (columns.length - 1)) {
|
---|
| 1097 | csv += this.csvSeparator;
|
---|
| 1098 | }
|
---|
| 1099 | }
|
---|
| 1100 | }
|
---|
| 1101 | //body
|
---|
| 1102 | data.forEach((record, i) => {
|
---|
| 1103 | csv += '\n';
|
---|
| 1104 | for (let i = 0; i < columns.length; i++) {
|
---|
| 1105 | let column = columns[i];
|
---|
| 1106 | if (column.exportable !== false && column.field) {
|
---|
| 1107 | let cellData = ObjectUtils.resolveFieldData(record, column.field);
|
---|
| 1108 | if (cellData != null) {
|
---|
| 1109 | if (this.exportFunction) {
|
---|
| 1110 | cellData = this.exportFunction({
|
---|
| 1111 | data: cellData,
|
---|
| 1112 | field: column.field
|
---|
| 1113 | });
|
---|
| 1114 | }
|
---|
| 1115 | else
|
---|
| 1116 | cellData = String(cellData).replace(/"/g, '""');
|
---|
| 1117 | }
|
---|
| 1118 | else
|
---|
| 1119 | cellData = '';
|
---|
| 1120 | csv += '"' + cellData + '"';
|
---|
| 1121 | if (i < (columns.length - 1)) {
|
---|
| 1122 | csv += this.csvSeparator;
|
---|
| 1123 | }
|
---|
| 1124 | }
|
---|
| 1125 | }
|
---|
| 1126 | });
|
---|
| 1127 | let blob = new Blob([csv], {
|
---|
| 1128 | type: 'text/csv;charset=utf-8;'
|
---|
| 1129 | });
|
---|
| 1130 | let link = document.createElement("a");
|
---|
| 1131 | link.style.display = 'none';
|
---|
| 1132 | document.body.appendChild(link);
|
---|
| 1133 | if (link.download !== undefined) {
|
---|
| 1134 | link.setAttribute('href', URL.createObjectURL(blob));
|
---|
| 1135 | link.setAttribute('download', this.exportFilename + '.csv');
|
---|
| 1136 | link.click();
|
---|
| 1137 | }
|
---|
| 1138 | else {
|
---|
| 1139 | csv = 'data:text/csv;charset=utf-8,' + csv;
|
---|
| 1140 | window.open(encodeURI(csv));
|
---|
| 1141 | }
|
---|
| 1142 | document.body.removeChild(link);
|
---|
| 1143 | }
|
---|
| 1144 | resetScrollTop() {
|
---|
| 1145 | if (this.virtualScroll)
|
---|
| 1146 | this.scrollToVirtualIndex(0);
|
---|
| 1147 | else
|
---|
| 1148 | this.scrollTo({ top: 0 });
|
---|
| 1149 | }
|
---|
| 1150 | scrollToVirtualIndex(index) {
|
---|
| 1151 | if (this.virtualScrollBody) {
|
---|
| 1152 | this.virtualScrollBody.scrollToIndex(index);
|
---|
| 1153 | }
|
---|
| 1154 | }
|
---|
| 1155 | onScrollIndexChange(index) {
|
---|
| 1156 | if (this.lazy) {
|
---|
| 1157 | if (this.virtualScrollTimeout) {
|
---|
| 1158 | clearTimeout(this.virtualScrollTimeout);
|
---|
| 1159 | }
|
---|
| 1160 | this.virtualScrollTimeout = setTimeout(() => {
|
---|
| 1161 | let page = Math.floor(index / this.rows);
|
---|
| 1162 | let virtualScrollOffset = page === 0 ? 0 : (page - 1) * this.rows;
|
---|
| 1163 | let virtualScrollChunkSize = page === 0 ? this.rows * 2 : this.rows * 3;
|
---|
| 1164 | if (page !== this.virtualPage) {
|
---|
| 1165 | this.virtualPage = page;
|
---|
| 1166 | this.onLazyLoad.emit({
|
---|
| 1167 | first: virtualScrollOffset,
|
---|
| 1168 | rows: virtualScrollChunkSize,
|
---|
| 1169 | sortField: this.sortField,
|
---|
| 1170 | sortOrder: this.sortOrder,
|
---|
| 1171 | filters: this.filters,
|
---|
| 1172 | globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null,
|
---|
| 1173 | multiSortMeta: this.multiSortMeta
|
---|
| 1174 | });
|
---|
| 1175 | }
|
---|
| 1176 | }, this.virtualScrollDelay);
|
---|
| 1177 | }
|
---|
| 1178 | }
|
---|
| 1179 | scrollTo(options) {
|
---|
| 1180 | if (this.virtualScrollBody) {
|
---|
| 1181 | this.virtualScrollBody.scrollTo(options);
|
---|
| 1182 | }
|
---|
| 1183 | else {
|
---|
| 1184 | if (this.wrapperViewChild.nativeElement.scrollTo) {
|
---|
| 1185 | this.wrapperViewChild.nativeElement.scrollTo(options);
|
---|
| 1186 | }
|
---|
| 1187 | else {
|
---|
| 1188 | this.wrapperViewChild.nativeElement.scrollLeft = options.left;
|
---|
| 1189 | this.wrapperViewChild.nativeElement.scrollTop = options.top;
|
---|
| 1190 | }
|
---|
| 1191 | }
|
---|
| 1192 | }
|
---|
| 1193 | updateEditingCell(cell, data, field, index) {
|
---|
| 1194 | this.editingCell = cell;
|
---|
| 1195 | this.editingCellData = data;
|
---|
| 1196 | this.editingCellField = field;
|
---|
| 1197 | this.editingCellRowIndex = index;
|
---|
| 1198 | this.bindDocumentEditListener();
|
---|
| 1199 | }
|
---|
| 1200 | isEditingCellValid() {
|
---|
| 1201 | return (this.editingCell && DomHandler.find(this.editingCell, '.ng-invalid.ng-dirty').length === 0);
|
---|
| 1202 | }
|
---|
| 1203 | bindDocumentEditListener() {
|
---|
| 1204 | if (!this.documentEditListener) {
|
---|
| 1205 | this.documentEditListener = (event) => {
|
---|
| 1206 | if (this.editingCell && !this.selfClick && this.isEditingCellValid()) {
|
---|
| 1207 | DomHandler.removeClass(this.editingCell, 'p-cell-editing');
|
---|
| 1208 | this.editingCell = null;
|
---|
| 1209 | this.onEditComplete.emit({ field: this.editingCellField, data: this.editingCellData, originalEvent: event, index: this.editingCellRowIndex });
|
---|
| 1210 | this.editingCellField = null;
|
---|
| 1211 | this.editingCellData = null;
|
---|
| 1212 | this.editingCellRowIndex = null;
|
---|
| 1213 | this.unbindDocumentEditListener();
|
---|
| 1214 | this.cd.markForCheck();
|
---|
| 1215 | if (this.overlaySubscription) {
|
---|
| 1216 | this.overlaySubscription.unsubscribe();
|
---|
| 1217 | }
|
---|
| 1218 | }
|
---|
| 1219 | this.selfClick = false;
|
---|
| 1220 | };
|
---|
| 1221 | document.addEventListener('click', this.documentEditListener);
|
---|
| 1222 | }
|
---|
| 1223 | }
|
---|
| 1224 | unbindDocumentEditListener() {
|
---|
| 1225 | if (this.documentEditListener) {
|
---|
| 1226 | document.removeEventListener('click', this.documentEditListener);
|
---|
| 1227 | this.documentEditListener = null;
|
---|
| 1228 | }
|
---|
| 1229 | }
|
---|
| 1230 | initRowEdit(rowData) {
|
---|
| 1231 | let dataKeyValue = String(ObjectUtils.resolveFieldData(rowData, this.dataKey));
|
---|
| 1232 | this.editingRowKeys[dataKeyValue] = true;
|
---|
| 1233 | }
|
---|
| 1234 | saveRowEdit(rowData, rowElement) {
|
---|
| 1235 | if (DomHandler.find(rowElement, '.ng-invalid.ng-dirty').length === 0) {
|
---|
| 1236 | let dataKeyValue = String(ObjectUtils.resolveFieldData(rowData, this.dataKey));
|
---|
| 1237 | delete this.editingRowKeys[dataKeyValue];
|
---|
| 1238 | }
|
---|
| 1239 | }
|
---|
| 1240 | cancelRowEdit(rowData) {
|
---|
| 1241 | let dataKeyValue = String(ObjectUtils.resolveFieldData(rowData, this.dataKey));
|
---|
| 1242 | delete this.editingRowKeys[dataKeyValue];
|
---|
| 1243 | }
|
---|
| 1244 | toggleRow(rowData, event) {
|
---|
| 1245 | if (!this.dataKey) {
|
---|
| 1246 | throw new Error('dataKey must be defined to use row expansion');
|
---|
| 1247 | }
|
---|
| 1248 | let dataKeyValue = String(ObjectUtils.resolveFieldData(rowData, this.dataKey));
|
---|
| 1249 | if (this.expandedRowKeys[dataKeyValue] != null) {
|
---|
| 1250 | delete this.expandedRowKeys[dataKeyValue];
|
---|
| 1251 | this.onRowCollapse.emit({
|
---|
| 1252 | originalEvent: event,
|
---|
| 1253 | data: rowData
|
---|
| 1254 | });
|
---|
| 1255 | }
|
---|
| 1256 | else {
|
---|
| 1257 | if (this.rowExpandMode === 'single') {
|
---|
| 1258 | this.expandedRowKeys = {};
|
---|
| 1259 | }
|
---|
| 1260 | this.expandedRowKeys[dataKeyValue] = true;
|
---|
| 1261 | this.onRowExpand.emit({
|
---|
| 1262 | originalEvent: event,
|
---|
| 1263 | data: rowData
|
---|
| 1264 | });
|
---|
| 1265 | }
|
---|
| 1266 | if (event) {
|
---|
| 1267 | event.preventDefault();
|
---|
| 1268 | }
|
---|
| 1269 | if (this.isStateful()) {
|
---|
| 1270 | this.saveState();
|
---|
| 1271 | }
|
---|
| 1272 | }
|
---|
| 1273 | isRowExpanded(rowData) {
|
---|
| 1274 | return this.expandedRowKeys[String(ObjectUtils.resolveFieldData(rowData, this.dataKey))] === true;
|
---|
| 1275 | }
|
---|
| 1276 | isRowEditing(rowData) {
|
---|
| 1277 | return this.editingRowKeys[String(ObjectUtils.resolveFieldData(rowData, this.dataKey))] === true;
|
---|
| 1278 | }
|
---|
| 1279 | isSingleSelectionMode() {
|
---|
| 1280 | return this.selectionMode === 'single';
|
---|
| 1281 | }
|
---|
| 1282 | isMultipleSelectionMode() {
|
---|
| 1283 | return this.selectionMode === 'multiple';
|
---|
| 1284 | }
|
---|
| 1285 | onColumnResizeBegin(event) {
|
---|
| 1286 | let containerLeft = DomHandler.getOffset(this.containerViewChild.nativeElement).left;
|
---|
| 1287 | this.resizeColumnElement = event.target.parentElement;
|
---|
| 1288 | this.columnResizing = true;
|
---|
| 1289 | this.lastResizerHelperX = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft);
|
---|
| 1290 | this.onColumnResize(event);
|
---|
| 1291 | event.preventDefault();
|
---|
| 1292 | }
|
---|
| 1293 | onColumnResize(event) {
|
---|
| 1294 | let containerLeft = DomHandler.getOffset(this.containerViewChild.nativeElement).left;
|
---|
| 1295 | DomHandler.addClass(this.containerViewChild.nativeElement, 'p-unselectable-text');
|
---|
| 1296 | this.resizeHelperViewChild.nativeElement.style.height = this.containerViewChild.nativeElement.offsetHeight + 'px';
|
---|
| 1297 | this.resizeHelperViewChild.nativeElement.style.top = 0 + 'px';
|
---|
| 1298 | this.resizeHelperViewChild.nativeElement.style.left = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft) + 'px';
|
---|
| 1299 | this.resizeHelperViewChild.nativeElement.style.display = 'block';
|
---|
| 1300 | }
|
---|
| 1301 | onColumnResizeEnd() {
|
---|
| 1302 | let delta = this.resizeHelperViewChild.nativeElement.offsetLeft - this.lastResizerHelperX;
|
---|
| 1303 | let columnWidth = this.resizeColumnElement.offsetWidth;
|
---|
| 1304 | let newColumnWidth = columnWidth + delta;
|
---|
| 1305 | let minWidth = this.resizeColumnElement.style.minWidth || 15;
|
---|
| 1306 | if (newColumnWidth >= minWidth) {
|
---|
| 1307 | if (this.columnResizeMode === 'fit') {
|
---|
| 1308 | let nextColumn = this.resizeColumnElement.nextElementSibling;
|
---|
| 1309 | let nextColumnWidth = nextColumn.offsetWidth - delta;
|
---|
| 1310 | if (newColumnWidth > 15 && nextColumnWidth > 15) {
|
---|
| 1311 | if (!this.scrollable) {
|
---|
| 1312 | this.resizeColumnElement.style.width = newColumnWidth + 'px';
|
---|
| 1313 | if (nextColumn) {
|
---|
| 1314 | nextColumn.style.width = nextColumnWidth + 'px';
|
---|
| 1315 | }
|
---|
| 1316 | }
|
---|
| 1317 | else {
|
---|
| 1318 | this.resizeTableCells(newColumnWidth, nextColumnWidth);
|
---|
| 1319 | }
|
---|
| 1320 | }
|
---|
| 1321 | }
|
---|
| 1322 | else if (this.columnResizeMode === 'expand') {
|
---|
| 1323 | let tableWidth = this.tableViewChild.nativeElement.offsetWidth + delta;
|
---|
| 1324 | this.tableViewChild.nativeElement.style.minWidth = tableWidth + 'px';
|
---|
| 1325 | this.resizeColumnElement.style.width = newColumnWidth + 'px';
|
---|
| 1326 | if (!this.scrollable)
|
---|
| 1327 | this.tableViewChild.nativeElement.style.width = tableWidth + 'px';
|
---|
| 1328 | else
|
---|
| 1329 | this.resizeTableCells(newColumnWidth, null);
|
---|
| 1330 | }
|
---|
| 1331 | this.onColResize.emit({
|
---|
| 1332 | element: this.resizeColumnElement,
|
---|
| 1333 | delta: delta
|
---|
| 1334 | });
|
---|
| 1335 | if (this.isStateful()) {
|
---|
| 1336 | this.saveState();
|
---|
| 1337 | }
|
---|
| 1338 | }
|
---|
| 1339 | this.resizeHelperViewChild.nativeElement.style.display = 'none';
|
---|
| 1340 | DomHandler.removeClass(this.containerViewChild.nativeElement, 'p-unselectable-text');
|
---|
| 1341 | }
|
---|
| 1342 | resizeTableCells(newColumnWidth, nextColumnWidth) {
|
---|
| 1343 | let colIndex = DomHandler.index(this.resizeColumnElement);
|
---|
| 1344 | let widths = [];
|
---|
| 1345 | const tableHead = DomHandler.findSingle(this.containerViewChild.nativeElement, '.p-datatable-thead');
|
---|
| 1346 | let headers = DomHandler.find(tableHead, 'tr > th');
|
---|
| 1347 | headers.forEach(header => widths.push(DomHandler.getOuterWidth(header)));
|
---|
| 1348 | this.destroyStyleElement();
|
---|
| 1349 | this.createStyleElement();
|
---|
| 1350 | let innerHTML = '';
|
---|
| 1351 | widths.forEach((width, index) => {
|
---|
| 1352 | let colWidth = index === colIndex ? newColumnWidth : (nextColumnWidth && index === colIndex + 1) ? nextColumnWidth : width;
|
---|
| 1353 | innerHTML += `
|
---|
| 1354 | #${this.id}-table > .p-datatable-thead > tr > th:nth-child(${index + 1}) {
|
---|
| 1355 | flex: 0 0 ${colWidth}px !important;
|
---|
| 1356 | }
|
---|
| 1357 |
|
---|
| 1358 | #${this.id}-table > .p-datatable-tbody > tr > td:nth-child(${index + 1}) {
|
---|
| 1359 | flex: 0 0 ${colWidth}px !important;
|
---|
| 1360 | }
|
---|
| 1361 | `;
|
---|
| 1362 | });
|
---|
| 1363 | this.styleElement.innerHTML = innerHTML;
|
---|
| 1364 | }
|
---|
| 1365 | onColumnDragStart(event, columnElement) {
|
---|
| 1366 | this.reorderIconWidth = DomHandler.getHiddenElementOuterWidth(this.reorderIndicatorUpViewChild.nativeElement);
|
---|
| 1367 | this.reorderIconHeight = DomHandler.getHiddenElementOuterHeight(this.reorderIndicatorDownViewChild.nativeElement);
|
---|
| 1368 | this.draggedColumn = columnElement;
|
---|
| 1369 | event.dataTransfer.setData('text', 'b'); // For firefox
|
---|
| 1370 | }
|
---|
| 1371 | onColumnDragEnter(event, dropHeader) {
|
---|
| 1372 | if (this.reorderableColumns && this.draggedColumn && dropHeader) {
|
---|
| 1373 | event.preventDefault();
|
---|
| 1374 | let containerOffset = DomHandler.getOffset(this.containerViewChild.nativeElement);
|
---|
| 1375 | let dropHeaderOffset = DomHandler.getOffset(dropHeader);
|
---|
| 1376 | if (this.draggedColumn != dropHeader) {
|
---|
| 1377 | let dragIndex = DomHandler.indexWithinGroup(this.draggedColumn, 'preorderablecolumn');
|
---|
| 1378 | let dropIndex = DomHandler.indexWithinGroup(dropHeader, 'preorderablecolumn');
|
---|
| 1379 | let targetLeft = dropHeaderOffset.left - containerOffset.left;
|
---|
| 1380 | let targetTop = containerOffset.top - dropHeaderOffset.top;
|
---|
| 1381 | let columnCenter = dropHeaderOffset.left + dropHeader.offsetWidth / 2;
|
---|
| 1382 | this.reorderIndicatorUpViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top - (this.reorderIconHeight - 1) + 'px';
|
---|
| 1383 | this.reorderIndicatorDownViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top + dropHeader.offsetHeight + 'px';
|
---|
| 1384 | if (event.pageX > columnCenter) {
|
---|
| 1385 | this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 1386 | this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 1387 | this.dropPosition = 1;
|
---|
| 1388 | }
|
---|
| 1389 | else {
|
---|
| 1390 | this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 1391 | this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
---|
| 1392 | this.dropPosition = -1;
|
---|
| 1393 | }
|
---|
| 1394 | if ((dropIndex - dragIndex === 1 && this.dropPosition === -1) || (dropIndex - dragIndex === -1 && this.dropPosition === 1)) {
|
---|
| 1395 | this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
|
---|
| 1396 | this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
|
---|
| 1397 | }
|
---|
| 1398 | else {
|
---|
| 1399 | this.reorderIndicatorUpViewChild.nativeElement.style.display = 'block';
|
---|
| 1400 | this.reorderIndicatorDownViewChild.nativeElement.style.display = 'block';
|
---|
| 1401 | }
|
---|
| 1402 | }
|
---|
| 1403 | else {
|
---|
| 1404 | event.dataTransfer.dropEffect = 'none';
|
---|
| 1405 | }
|
---|
| 1406 | }
|
---|
| 1407 | }
|
---|
| 1408 | onColumnDragLeave(event) {
|
---|
| 1409 | if (this.reorderableColumns && this.draggedColumn) {
|
---|
| 1410 | event.preventDefault();
|
---|
| 1411 | this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
|
---|
| 1412 | this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
|
---|
| 1413 | }
|
---|
| 1414 | }
|
---|
| 1415 | onColumnDrop(event, dropColumn) {
|
---|
| 1416 | event.preventDefault();
|
---|
| 1417 | if (this.draggedColumn) {
|
---|
| 1418 | let dragIndex = DomHandler.indexWithinGroup(this.draggedColumn, 'preorderablecolumn');
|
---|
| 1419 | let dropIndex = DomHandler.indexWithinGroup(dropColumn, 'preorderablecolumn');
|
---|
| 1420 | let allowDrop = (dragIndex != dropIndex);
|
---|
| 1421 | if (allowDrop && ((dropIndex - dragIndex == 1 && this.dropPosition === -1) || (dragIndex - dropIndex == 1 && this.dropPosition === 1))) {
|
---|
| 1422 | allowDrop = false;
|
---|
| 1423 | }
|
---|
| 1424 | if (allowDrop && ((dropIndex < dragIndex && this.dropPosition === 1))) {
|
---|
| 1425 | dropIndex = dropIndex + 1;
|
---|
| 1426 | }
|
---|
| 1427 | if (allowDrop && ((dropIndex > dragIndex && this.dropPosition === -1))) {
|
---|
| 1428 | dropIndex = dropIndex - 1;
|
---|
| 1429 | }
|
---|
| 1430 | if (allowDrop) {
|
---|
| 1431 | ObjectUtils.reorderArray(this.columns, dragIndex, dropIndex);
|
---|
| 1432 | this.onColReorder.emit({
|
---|
| 1433 | dragIndex: dragIndex,
|
---|
| 1434 | dropIndex: dropIndex,
|
---|
| 1435 | columns: this.columns
|
---|
| 1436 | });
|
---|
| 1437 | if (this.isStateful()) {
|
---|
| 1438 | this.zone.runOutsideAngular(() => {
|
---|
| 1439 | setTimeout(() => {
|
---|
| 1440 | this.saveState();
|
---|
| 1441 | });
|
---|
| 1442 | });
|
---|
| 1443 | }
|
---|
| 1444 | }
|
---|
| 1445 | this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
|
---|
| 1446 | this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
|
---|
| 1447 | this.draggedColumn.draggable = false;
|
---|
| 1448 | this.draggedColumn = null;
|
---|
| 1449 | this.dropPosition = null;
|
---|
| 1450 | }
|
---|
| 1451 | }
|
---|
| 1452 | onRowDragStart(event, index) {
|
---|
| 1453 | this.rowDragging = true;
|
---|
| 1454 | this.draggedRowIndex = index;
|
---|
| 1455 | event.dataTransfer.setData('text', 'b'); // For firefox
|
---|
| 1456 | }
|
---|
| 1457 | onRowDragOver(event, index, rowElement) {
|
---|
| 1458 | if (this.rowDragging && this.draggedRowIndex !== index) {
|
---|
| 1459 | let rowY = DomHandler.getOffset(rowElement).top + DomHandler.getWindowScrollTop();
|
---|
| 1460 | let pageY = event.pageY;
|
---|
| 1461 | let rowMidY = rowY + DomHandler.getOuterHeight(rowElement) / 2;
|
---|
| 1462 | let prevRowElement = rowElement.previousElementSibling;
|
---|
| 1463 | if (pageY < rowMidY) {
|
---|
| 1464 | DomHandler.removeClass(rowElement, 'p-datatable-dragpoint-bottom');
|
---|
| 1465 | this.droppedRowIndex = index;
|
---|
| 1466 | if (prevRowElement)
|
---|
| 1467 | DomHandler.addClass(prevRowElement, 'p-datatable-dragpoint-bottom');
|
---|
| 1468 | else
|
---|
| 1469 | DomHandler.addClass(rowElement, 'p-datatable-dragpoint-top');
|
---|
| 1470 | }
|
---|
| 1471 | else {
|
---|
| 1472 | if (prevRowElement)
|
---|
| 1473 | DomHandler.removeClass(prevRowElement, 'p-datatable-dragpoint-bottom');
|
---|
| 1474 | else
|
---|
| 1475 | DomHandler.addClass(rowElement, 'p-datatable-dragpoint-top');
|
---|
| 1476 | this.droppedRowIndex = index + 1;
|
---|
| 1477 | DomHandler.addClass(rowElement, 'p-datatable-dragpoint-bottom');
|
---|
| 1478 | }
|
---|
| 1479 | }
|
---|
| 1480 | }
|
---|
| 1481 | onRowDragLeave(event, rowElement) {
|
---|
| 1482 | let prevRowElement = rowElement.previousElementSibling;
|
---|
| 1483 | if (prevRowElement) {
|
---|
| 1484 | DomHandler.removeClass(prevRowElement, 'p-datatable-dragpoint-bottom');
|
---|
| 1485 | }
|
---|
| 1486 | DomHandler.removeClass(rowElement, 'p-datatable-dragpoint-bottom');
|
---|
| 1487 | DomHandler.removeClass(rowElement, 'p-datatable-dragpoint-top');
|
---|
| 1488 | }
|
---|
| 1489 | onRowDragEnd(event) {
|
---|
| 1490 | this.rowDragging = false;
|
---|
| 1491 | this.draggedRowIndex = null;
|
---|
| 1492 | this.droppedRowIndex = null;
|
---|
| 1493 | }
|
---|
| 1494 | onRowDrop(event, rowElement) {
|
---|
| 1495 | if (this.droppedRowIndex != null) {
|
---|
| 1496 | let dropIndex = (this.draggedRowIndex > this.droppedRowIndex) ? this.droppedRowIndex : (this.droppedRowIndex === 0) ? 0 : this.droppedRowIndex - 1;
|
---|
| 1497 | ObjectUtils.reorderArray(this.value, this.draggedRowIndex, dropIndex);
|
---|
| 1498 | this.onRowReorder.emit({
|
---|
| 1499 | dragIndex: this.draggedRowIndex,
|
---|
| 1500 | dropIndex: dropIndex
|
---|
| 1501 | });
|
---|
| 1502 | }
|
---|
| 1503 | //cleanup
|
---|
| 1504 | this.onRowDragLeave(event, rowElement);
|
---|
| 1505 | this.onRowDragEnd(event);
|
---|
| 1506 | }
|
---|
| 1507 | isEmpty() {
|
---|
| 1508 | let data = this.filteredValue || this.value;
|
---|
| 1509 | return data == null || data.length == 0;
|
---|
| 1510 | }
|
---|
| 1511 | getBlockableElement() {
|
---|
| 1512 | return this.el.nativeElement.children[0];
|
---|
| 1513 | }
|
---|
| 1514 | getStorage() {
|
---|
| 1515 | switch (this.stateStorage) {
|
---|
| 1516 | case 'local':
|
---|
| 1517 | return window.localStorage;
|
---|
| 1518 | case 'session':
|
---|
| 1519 | return window.sessionStorage;
|
---|
| 1520 | default:
|
---|
| 1521 | throw new Error(this.stateStorage + ' is not a valid value for the state storage, supported values are "local" and "session".');
|
---|
| 1522 | }
|
---|
| 1523 | }
|
---|
| 1524 | isStateful() {
|
---|
| 1525 | return this.stateKey != null;
|
---|
| 1526 | }
|
---|
| 1527 | saveState() {
|
---|
| 1528 | const storage = this.getStorage();
|
---|
| 1529 | let state = {};
|
---|
| 1530 | if (this.paginator) {
|
---|
| 1531 | state.first = this.first;
|
---|
| 1532 | state.rows = this.rows;
|
---|
| 1533 | }
|
---|
| 1534 | if (this.sortField) {
|
---|
| 1535 | state.sortField = this.sortField;
|
---|
| 1536 | state.sortOrder = this.sortOrder;
|
---|
| 1537 | }
|
---|
| 1538 | if (this.multiSortMeta) {
|
---|
| 1539 | state.multiSortMeta = this.multiSortMeta;
|
---|
| 1540 | }
|
---|
| 1541 | if (this.hasFilter()) {
|
---|
| 1542 | state.filters = this.filters;
|
---|
| 1543 | }
|
---|
| 1544 | if (this.resizableColumns) {
|
---|
| 1545 | this.saveColumnWidths(state);
|
---|
| 1546 | }
|
---|
| 1547 | if (this.reorderableColumns) {
|
---|
| 1548 | this.saveColumnOrder(state);
|
---|
| 1549 | }
|
---|
| 1550 | if (this.selection) {
|
---|
| 1551 | state.selection = this.selection;
|
---|
| 1552 | }
|
---|
| 1553 | if (Object.keys(this.expandedRowKeys).length) {
|
---|
| 1554 | state.expandedRowKeys = this.expandedRowKeys;
|
---|
| 1555 | }
|
---|
| 1556 | storage.setItem(this.stateKey, JSON.stringify(state));
|
---|
| 1557 | this.onStateSave.emit(state);
|
---|
| 1558 | }
|
---|
| 1559 | clearState() {
|
---|
| 1560 | const storage = this.getStorage();
|
---|
| 1561 | if (this.stateKey) {
|
---|
| 1562 | storage.removeItem(this.stateKey);
|
---|
| 1563 | }
|
---|
| 1564 | }
|
---|
| 1565 | restoreState() {
|
---|
| 1566 | const storage = this.getStorage();
|
---|
| 1567 | const stateString = storage.getItem(this.stateKey);
|
---|
| 1568 | const dateFormat = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;
|
---|
| 1569 | const reviver = function (key, value) {
|
---|
| 1570 | if (typeof value === "string" && dateFormat.test(value)) {
|
---|
| 1571 | return new Date(value);
|
---|
| 1572 | }
|
---|
| 1573 | return value;
|
---|
| 1574 | };
|
---|
| 1575 | if (stateString) {
|
---|
| 1576 | let state = JSON.parse(stateString, reviver);
|
---|
| 1577 | if (this.paginator) {
|
---|
| 1578 | if (this.first !== undefined) {
|
---|
| 1579 | this.first = state.first;
|
---|
| 1580 | this.firstChange.emit(this.first);
|
---|
| 1581 | }
|
---|
| 1582 | if (this.rows !== undefined) {
|
---|
| 1583 | this.rows = state.rows;
|
---|
| 1584 | this.rowsChange.emit(this.rows);
|
---|
| 1585 | }
|
---|
| 1586 | }
|
---|
| 1587 | if (state.sortField) {
|
---|
| 1588 | this.restoringSort = true;
|
---|
| 1589 | this._sortField = state.sortField;
|
---|
| 1590 | this._sortOrder = state.sortOrder;
|
---|
| 1591 | }
|
---|
| 1592 | if (state.multiSortMeta) {
|
---|
| 1593 | this.restoringSort = true;
|
---|
| 1594 | this._multiSortMeta = state.multiSortMeta;
|
---|
| 1595 | }
|
---|
| 1596 | if (state.filters) {
|
---|
| 1597 | this.restoringFilter = true;
|
---|
| 1598 | this.filters = state.filters;
|
---|
| 1599 | }
|
---|
| 1600 | if (this.resizableColumns) {
|
---|
| 1601 | this.columnWidthsState = state.columnWidths;
|
---|
| 1602 | this.tableWidthState = state.tableWidth;
|
---|
| 1603 | }
|
---|
| 1604 | if (state.expandedRowKeys) {
|
---|
| 1605 | this.expandedRowKeys = state.expandedRowKeys;
|
---|
| 1606 | }
|
---|
| 1607 | if (state.selection) {
|
---|
| 1608 | Promise.resolve(null).then(() => this.selectionChange.emit(state.selection));
|
---|
| 1609 | }
|
---|
| 1610 | this.stateRestored = true;
|
---|
| 1611 | this.onStateRestore.emit(state);
|
---|
| 1612 | }
|
---|
| 1613 | }
|
---|
| 1614 | saveColumnWidths(state) {
|
---|
| 1615 | let widths = [];
|
---|
| 1616 | let headers = DomHandler.find(this.containerViewChild.nativeElement, '.p-datatable-thead > tr > th');
|
---|
| 1617 | headers.forEach(header => widths.push(DomHandler.getOuterWidth(header)));
|
---|
| 1618 | state.columnWidths = widths.join(',');
|
---|
| 1619 | if (this.columnResizeMode === 'expand') {
|
---|
| 1620 | state.tableWidth = DomHandler.getOuterWidth(this.tableViewChild.nativeElement) + 'px';
|
---|
| 1621 | }
|
---|
| 1622 | }
|
---|
| 1623 | restoreColumnWidths() {
|
---|
| 1624 | if (this.columnWidthsState) {
|
---|
| 1625 | let widths = this.columnWidthsState.split(',');
|
---|
| 1626 | if (this.columnResizeMode === 'expand' && this.tableWidthState) {
|
---|
| 1627 | this.tableViewChild.nativeElement.style.width = this.tableWidthState;
|
---|
| 1628 | this.tableViewChild.nativeElement.style.minWidth = this.tableWidthState;
|
---|
| 1629 | this.containerViewChild.nativeElement.style.width = this.tableWidthState;
|
---|
| 1630 | }
|
---|
| 1631 | this.createStyleElement();
|
---|
| 1632 | if (this.scrollable && widths && widths.length > 0) {
|
---|
| 1633 | let innerHTML = '';
|
---|
| 1634 | widths.forEach((width, index) => {
|
---|
| 1635 | innerHTML += `
|
---|
| 1636 | #${this.id}-table > .p-datatable-thead > tr > th:nth-child(${index + 1}) {
|
---|
| 1637 | flex: 0 0 ${width}px;
|
---|
| 1638 | }
|
---|
| 1639 |
|
---|
| 1640 | #${this.id}-table > .p-datatable-tbody > tr > td:nth-child(${index + 1}) {
|
---|
| 1641 | flex: 0 0 ${width}px;
|
---|
| 1642 | }
|
---|
| 1643 | `;
|
---|
| 1644 | });
|
---|
| 1645 | this.styleElement.innerHTML = innerHTML;
|
---|
| 1646 | }
|
---|
| 1647 | else {
|
---|
| 1648 | DomHandler.find(this.tableViewChild.nativeElement, '.p-datatable-thead > tr > th').forEach((header, index) => {
|
---|
| 1649 | header.style.width = widths[index] + 'px';
|
---|
| 1650 | });
|
---|
| 1651 | }
|
---|
| 1652 | }
|
---|
| 1653 | }
|
---|
| 1654 | saveColumnOrder(state) {
|
---|
| 1655 | if (this.columns) {
|
---|
| 1656 | let columnOrder = [];
|
---|
| 1657 | this.columns.map(column => {
|
---|
| 1658 | columnOrder.push(column.field || column.key);
|
---|
| 1659 | });
|
---|
| 1660 | state.columnOrder = columnOrder;
|
---|
| 1661 | }
|
---|
| 1662 | }
|
---|
| 1663 | restoreColumnOrder() {
|
---|
| 1664 | const storage = this.getStorage();
|
---|
| 1665 | const stateString = storage.getItem(this.stateKey);
|
---|
| 1666 | if (stateString) {
|
---|
| 1667 | let state = JSON.parse(stateString);
|
---|
| 1668 | let columnOrder = state.columnOrder;
|
---|
| 1669 | if (columnOrder) {
|
---|
| 1670 | let reorderedColumns = [];
|
---|
| 1671 | columnOrder.map(key => {
|
---|
| 1672 | let col = this.findColumnByKey(key);
|
---|
| 1673 | if (col) {
|
---|
| 1674 | reorderedColumns.push(col);
|
---|
| 1675 | }
|
---|
| 1676 | });
|
---|
| 1677 | this.columnOrderStateRestored = true;
|
---|
| 1678 | this.columns = reorderedColumns;
|
---|
| 1679 | }
|
---|
| 1680 | }
|
---|
| 1681 | }
|
---|
| 1682 | findColumnByKey(key) {
|
---|
| 1683 | if (this.columns) {
|
---|
| 1684 | for (let col of this.columns) {
|
---|
| 1685 | if (col.key === key || col.field === key)
|
---|
| 1686 | return col;
|
---|
| 1687 | else
|
---|
| 1688 | continue;
|
---|
| 1689 | }
|
---|
| 1690 | }
|
---|
| 1691 | else {
|
---|
| 1692 | return null;
|
---|
| 1693 | }
|
---|
| 1694 | }
|
---|
| 1695 | createStyleElement() {
|
---|
| 1696 | this.styleElement = document.createElement('style');
|
---|
| 1697 | this.styleElement.type = 'text/css';
|
---|
| 1698 | document.head.appendChild(this.styleElement);
|
---|
| 1699 | }
|
---|
| 1700 | getGroupRowsMeta() {
|
---|
| 1701 | return { field: this.groupRowsBy, order: this.groupRowsByOrder };
|
---|
| 1702 | }
|
---|
| 1703 | createResponsiveStyle() {
|
---|
| 1704 | if (!this.responsiveStyleElement) {
|
---|
| 1705 | this.responsiveStyleElement = document.createElement('style');
|
---|
| 1706 | this.responsiveStyleElement.type = 'text/css';
|
---|
| 1707 | document.head.appendChild(this.responsiveStyleElement);
|
---|
| 1708 | let innerHTML = `
|
---|
| 1709 | @media screen and (max-width: ${this.breakpoint}) {
|
---|
| 1710 | #${this.id} .p-datatable-thead > tr > th,
|
---|
| 1711 | #${this.id} .p-datatable-tfoot > tr > td {
|
---|
| 1712 | display: none !important;
|
---|
| 1713 | }
|
---|
| 1714 |
|
---|
| 1715 | #${this.id} .p-datatable-tbody > tr > td {
|
---|
| 1716 | display: flex;
|
---|
| 1717 | width: 100% !important;
|
---|
| 1718 | align-items: center;
|
---|
| 1719 | justify-content: space-between;
|
---|
| 1720 | }
|
---|
| 1721 |
|
---|
| 1722 | #${this.id} .p-datatable-tbody > tr > td:not(:last-child) {
|
---|
| 1723 | border: 0 none;
|
---|
| 1724 | }
|
---|
| 1725 |
|
---|
| 1726 | #${this.id}.p-datatable-gridlines .p-datatable-tbody > tr > td:last-child {
|
---|
| 1727 | border-top: 0;
|
---|
| 1728 | border-right: 0;
|
---|
| 1729 | border-left: 0;
|
---|
| 1730 | }
|
---|
| 1731 |
|
---|
| 1732 | #${this.id} .p-datatable-tbody > tr > td > .p-column-title {
|
---|
| 1733 | display: block;
|
---|
| 1734 | }
|
---|
| 1735 | }
|
---|
| 1736 | `;
|
---|
| 1737 | this.responsiveStyleElement.innerHTML = innerHTML;
|
---|
| 1738 | }
|
---|
| 1739 | }
|
---|
| 1740 | destroyResponsiveStyle() {
|
---|
| 1741 | if (this.responsiveStyleElement) {
|
---|
| 1742 | document.head.removeChild(this.responsiveStyleElement);
|
---|
| 1743 | this.responsiveStyleElement = null;
|
---|
| 1744 | }
|
---|
| 1745 | }
|
---|
| 1746 | destroyStyleElement() {
|
---|
| 1747 | if (this.styleElement) {
|
---|
| 1748 | document.head.removeChild(this.styleElement);
|
---|
| 1749 | this.styleElement = null;
|
---|
| 1750 | }
|
---|
| 1751 | }
|
---|
| 1752 | ngOnDestroy() {
|
---|
| 1753 | this.unbindDocumentEditListener();
|
---|
| 1754 | this.editingCell = null;
|
---|
| 1755 | this.initialized = null;
|
---|
| 1756 | if (this.virtualScrollSubscription) {
|
---|
| 1757 | this.virtualScrollSubscription.unsubscribe();
|
---|
| 1758 | }
|
---|
| 1759 | this.destroyStyleElement();
|
---|
| 1760 | this.destroyResponsiveStyle();
|
---|
| 1761 | }
|
---|
| 1762 | }
|
---|
| 1763 | Table.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Table, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: TableService }, { token: i0.ChangeDetectorRef }, { token: i1.FilterService }, { token: i1.OverlayService }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 1764 | Table.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Table, selector: "p-table", inputs: { frozenColumns: "frozenColumns", frozenValue: "frozenValue", style: "style", styleClass: "styleClass", tableStyle: "tableStyle", tableStyleClass: "tableStyleClass", paginator: "paginator", pageLinks: "pageLinks", rowsPerPageOptions: "rowsPerPageOptions", alwaysShowPaginator: "alwaysShowPaginator", paginatorPosition: "paginatorPosition", paginatorDropdownAppendTo: "paginatorDropdownAppendTo", paginatorDropdownScrollHeight: "paginatorDropdownScrollHeight", currentPageReportTemplate: "currentPageReportTemplate", showCurrentPageReport: "showCurrentPageReport", showJumpToPageDropdown: "showJumpToPageDropdown", showJumpToPageInput: "showJumpToPageInput", showFirstLastIcon: "showFirstLastIcon", showPageLinks: "showPageLinks", defaultSortOrder: "defaultSortOrder", sortMode: "sortMode", resetPageOnSort: "resetPageOnSort", selectionMode: "selectionMode", contextMenuSelection: "contextMenuSelection", contextMenuSelectionMode: "contextMenuSelectionMode", dataKey: "dataKey", metaKeySelection: "metaKeySelection", rowTrackBy: "rowTrackBy", lazy: "lazy", lazyLoadOnInit: "lazyLoadOnInit", compareSelectionBy: "compareSelectionBy", csvSeparator: "csvSeparator", exportFilename: "exportFilename", filters: "filters", globalFilterFields: "globalFilterFields", filterDelay: "filterDelay", filterLocale: "filterLocale", expandedRowKeys: "expandedRowKeys", editingRowKeys: "editingRowKeys", rowExpandMode: "rowExpandMode", scrollable: "scrollable", scrollDirection: "scrollDirection", rowGroupMode: "rowGroupMode", scrollHeight: "scrollHeight", virtualScroll: "virtualScroll", virtualScrollDelay: "virtualScrollDelay", virtualRowHeight: "virtualRowHeight", frozenWidth: "frozenWidth", responsive: "responsive", contextMenu: "contextMenu", resizableColumns: "resizableColumns", columnResizeMode: "columnResizeMode", reorderableColumns: "reorderableColumns", loading: "loading", loadingIcon: "loadingIcon", showLoader: "showLoader", rowHover: "rowHover", customSort: "customSort", showInitialSortBadge: "showInitialSortBadge", autoLayout: "autoLayout", exportFunction: "exportFunction", stateKey: "stateKey", stateStorage: "stateStorage", editMode: "editMode", groupRowsBy: "groupRowsBy", groupRowsByOrder: "groupRowsByOrder", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx", responsiveLayout: "responsiveLayout", breakpoint: "breakpoint", value: "value", columns: "columns", first: "first", rows: "rows", totalRecords: "totalRecords", sortField: "sortField", sortOrder: "sortOrder", multiSortMeta: "multiSortMeta", selection: "selection" }, outputs: { selectionChange: "selectionChange", contextMenuSelectionChange: "contextMenuSelectionChange", onRowSelect: "onRowSelect", onRowUnselect: "onRowUnselect", onPage: "onPage", onSort: "onSort", onFilter: "onFilter", onLazyLoad: "onLazyLoad", onRowExpand: "onRowExpand", onRowCollapse: "onRowCollapse", onContextMenuSelect: "onContextMenuSelect", onColResize: "onColResize", onColReorder: "onColReorder", onRowReorder: "onRowReorder", onEditInit: "onEditInit", onEditComplete: "onEditComplete", onEditCancel: "onEditCancel", onHeaderCheckboxToggle: "onHeaderCheckboxToggle", sortFunction: "sortFunction", firstChange: "firstChange", rowsChange: "rowsChange", onStateSave: "onStateSave", onStateRestore: "onStateRestore" }, host: { classAttribute: "p-element" }, providers: [TableService], 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: "wrapperViewChild", first: true, predicate: ["wrapper"], descendants: true }, { propertyName: "tableViewChild", first: true, predicate: ["table"], descendants: true }, { propertyName: "tableHeaderViewChild", first: true, predicate: ["tableHeader"], descendants: true }, { propertyName: "virtualScrollBody", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
---|
| 1765 | <div #container [ngStyle]="style" [class]="styleClass"
|
---|
| 1766 | [ngClass]="{'p-datatable p-component': true,
|
---|
| 1767 | 'p-datatable-hoverable-rows': (rowHover||selectionMode),
|
---|
| 1768 | 'p-datatable-auto-layout': autoLayout,
|
---|
| 1769 | 'p-datatable-resizable': resizableColumns,
|
---|
| 1770 | 'p-datatable-resizable-fit': (resizableColumns && columnResizeMode === 'fit'),
|
---|
| 1771 | 'p-datatable-scrollable': scrollable,
|
---|
| 1772 | 'p-datatable-scrollable-vertical': scrollable && scrollDirection === 'vertical',
|
---|
| 1773 | 'p-datatable-scrollable-horizontal': scrollable && scrollDirection === 'horizontal',
|
---|
| 1774 | 'p-datatable-scrollable-both': scrollable && scrollDirection === 'both',
|
---|
| 1775 | 'p-datatable-flex-scrollable': (scrollable && scrollHeight === 'flex'),
|
---|
| 1776 | 'p-datatable-responsive-stack': responsiveLayout === 'stack',
|
---|
| 1777 | 'p-datatable-responsive-scroll': responsiveLayout === 'scroll',
|
---|
| 1778 | 'p-datatable-responsive': responsive,
|
---|
| 1779 | 'p-datatable-grouped-header': headerGroupedTemplate != null,
|
---|
| 1780 | 'p-datatable-grouped-footer': footerGroupedTemplate != null}" [attr.id]="id">
|
---|
| 1781 | <div class="p-datatable-loading-overlay p-component-overlay" *ngIf="loading && showLoader">
|
---|
| 1782 | <i [class]="'p-datatable-loading-icon pi-spin ' + loadingIcon"></i>
|
---|
| 1783 | </div>
|
---|
| 1784 | <div *ngIf="captionTemplate" class="p-datatable-header">
|
---|
| 1785 | <ng-container *ngTemplateOutlet="captionTemplate"></ng-container>
|
---|
| 1786 | </div>
|
---|
| 1787 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-top" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1788 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'top' || paginatorPosition =='both')"
|
---|
| 1789 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo" [dropdownScrollHeight]="paginatorDropdownScrollHeight"
|
---|
| 1790 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showJumpToPageInput]="showJumpToPageInput" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1791 |
|
---|
| 1792 | <div #wrapper class="p-datatable-wrapper" [ngStyle]="{height: scrollHeight}">
|
---|
| 1793 | <table #table *ngIf="!virtualScroll" role="table" class="p-datatable-table" [ngClass]="tableStyleClass" [ngStyle]="tableStyle" [attr.id]="id+'-table'">
|
---|
| 1794 | <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1795 | <thead class="p-datatable-thead">
|
---|
| 1796 | <ng-container *ngTemplateOutlet="headerGroupedTemplate||headerTemplate; context: {$implicit: columns}"></ng-container>
|
---|
| 1797 | </thead>
|
---|
| 1798 | <tbody class="p-datatable-tbody p-datatable-frozen-tbody" *ngIf="frozenValue||frozenBodyTemplate" [value]="frozenValue" [frozenRows]="true" [pTableBody]="columns" [pTableBodyTemplate]="frozenBodyTemplate" [frozen]="true"></tbody>
|
---|
| 1799 | <tbody class="p-datatable-tbody" [value]="dataToRender" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate"></tbody>
|
---|
| 1800 | <tfoot *ngIf="footerGroupedTemplate||footerTemplate" class="p-datatable-tfoot">
|
---|
| 1801 | <ng-container *ngTemplateOutlet="footerGroupedTemplate||footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1802 | </tfoot>
|
---|
| 1803 | </table>
|
---|
| 1804 | <cdk-virtual-scroll-viewport *ngIf="virtualScroll" [itemSize]="virtualRowHeight" tabindex="0" [style.height]="scrollHeight !== 'flex' ? scrollHeight : undefined" [minBufferPx]="minBufferPx" [maxBufferPx]="maxBufferPx" (scrolledIndexChange)="onScrollIndexChange($event)" class="p-datatable-virtual-scrollable-body">
|
---|
| 1805 | <table #table role="table" class="p-datatable-table" [ngClass]="tableStyleClass" [ngStyle]="tableStyle" [attr.id]="id+'-table'">
|
---|
| 1806 | <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1807 | <thead #tableHeader class="p-datatable-thead">
|
---|
| 1808 | <ng-container *ngTemplateOutlet="headerGroupedTemplate||headerTemplate; context: {$implicit: columns}"></ng-container>
|
---|
| 1809 | </thead>
|
---|
| 1810 | <tbody class="p-datatable-tbody p-datatable-frozen-tbody" *ngIf="frozenValue||frozenBodyTemplate" [value]="frozenValue" [frozenRows]="true" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate" [frozen]="true"></tbody>
|
---|
| 1811 | <tbody class="p-datatable-tbody" [value]="dataToRender" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate"></tbody>
|
---|
| 1812 | <tfoot *ngIf="footerGroupedTemplate||footerTemplate" class="p-datatable-tfoot">
|
---|
| 1813 | <ng-container *ngTemplateOutlet="footerGroupedTemplate||footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1814 | </tfoot>
|
---|
| 1815 | </table>
|
---|
| 1816 | </cdk-virtual-scroll-viewport>
|
---|
| 1817 | </div>
|
---|
| 1818 |
|
---|
| 1819 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-bottom" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1820 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'bottom' || paginatorPosition =='both')"
|
---|
| 1821 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo" [dropdownScrollHeight]="paginatorDropdownScrollHeight"
|
---|
| 1822 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showJumpToPageInput]="showJumpToPageInput" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1823 |
|
---|
| 1824 | <div *ngIf="summaryTemplate" class="p-datatable-footer">
|
---|
| 1825 | <ng-container *ngTemplateOutlet="summaryTemplate"></ng-container>
|
---|
| 1826 | </div>
|
---|
| 1827 |
|
---|
| 1828 | <div #resizeHelper class="p-column-resizer-helper" style="display:none" *ngIf="resizableColumns"></div>
|
---|
| 1829 | <span #reorderIndicatorUp class="pi pi-arrow-down p-datatable-reorder-indicator-up" style="display:none" *ngIf="reorderableColumns"></span>
|
---|
| 1830 | <span #reorderIndicatorDown class="pi pi-arrow-up p-datatable-reorder-indicator-down" style="display:none" *ngIf="reorderableColumns"></span>
|
---|
| 1831 | </div>
|
---|
| 1832 | `, isInline: true, styles: [".p-datatable{position:relative}.p-datatable table{border-collapse:collapse;min-width:100%;table-layout:fixed}.p-datatable .p-sortable-column{cursor:pointer;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-datatable .p-sortable-column .p-column-title,.p-datatable .p-sortable-column .p-sortable-column-icon,.p-datatable .p-sortable-column .p-sortable-column-badge{vertical-align:middle}.p-datatable .p-sortable-column .p-sortable-column-badge{display:inline-flex;align-items:center;justify-content:center}.p-datatable-auto-layout>.p-datatable-wrapper{overflow-x:auto}.p-datatable-auto-layout>.p-datatable-wrapper>table{table-layout:auto}.p-datatable-responsive-scroll>.p-datatable-wrapper{overflow-x:auto}.p-datatable-responsive-scroll>.p-datatable-wrapper>table,.p-datatable-auto-layout>.p-datatable-wrapper>table{table-layout:auto}.p-datatable-hoverable-rows .p-selectable-row{cursor:pointer}.p-datatable-scrollable .p-datatable-wrapper{position:relative;overflow:auto}.p-datatable-scrollable .p-datatable-thead,.p-datatable-scrollable .p-datatable-tbody,.p-datatable-scrollable .p-datatable-tfoot{display:block}.p-datatable-scrollable .p-datatable-thead>tr,.p-datatable-scrollable .p-datatable-tbody>tr,.p-datatable-scrollable .p-datatable-tfoot>tr{display:flex;flex-wrap:nowrap;width:100%}.p-datatable-scrollable .p-datatable-thead>tr>th,.p-datatable-scrollable .p-datatable-tbody>tr>td,.p-datatable-scrollable .p-datatable-tfoot>tr>td{display:flex;flex:1 1 0;align-items:center}.p-datatable-scrollable .p-datatable-thead{position:sticky;top:0;z-index:1}.p-datatable-scrollable .p-datatable-frozen-tbody{position:sticky;z-index:1}.p-datatable-scrollable .p-datatable-tfoot{position:sticky;bottom:0;z-index:1}.p-datatable-scrollable .p-frozen-column{position:sticky;background:inherit}.p-datatable-scrollable th.p-frozen-column{z-index:1}.p-datatable-scrollable-both .p-datatable-thead>tr>th,.p-datatable-scrollable-both .p-datatable-tbody>tr>td,.p-datatable-scrollable-both .p-datatable-tfoot>tr>td,.p-datatable-scrollable-horizontal .p-datatable-thead>tr>th .p-datatable-scrollable-horizontal .p-datatable-tbody>tr>td,.p-datatable-scrollable-horizontal .p-datatable-tfoot>tr>td{flex:0 0 auto}.p-datatable-flex-scrollable{display:flex;flex-direction:column;height:100%}.p-datatable-flex-scrollable .p-datatable-wrapper{display:flex;flex-direction:column;flex:1;height:100%}.p-datatable-scrollable .p-rowgroup-header{position:sticky;z-index:1}.p-datatable-scrollable.p-datatable-grouped-header .p-datatable-thead,.p-datatable-scrollable.p-datatable-grouped-footer .p-datatable-tfoot{display:table;border-collapse:collapse;width:100%;table-layout:fixed}.p-datatable-scrollable.p-datatable-grouped-header .p-datatable-thead>tr,.p-datatable-scrollable.p-datatable-grouped-footer .p-datatable-tfoot>tr{display:table-row}.p-datatable-scrollable.p-datatable-grouped-header .p-datatable-thead>tr>th,.p-datatable-scrollable.p-datatable-grouped-footer .p-datatable-tfoot>tr>td{display:table-cell}.p-datatable-flex-scrollable{display:flex;flex-direction:column;flex:1;height:100%}.p-datatable-flex-scrollable .p-datatable-virtual-scrollable-body{flex:1}.p-datatable-resizable>.p-datatable-wrapper{overflow-x:auto}.p-datatable-resizable .p-datatable-thead>tr>th,.p-datatable-resizable .p-datatable-tfoot>tr>td,.p-datatable-resizable .p-datatable-tbody>tr>td{overflow:hidden;white-space:nowrap}.p-datatable-resizable .p-resizable-column{background-clip:padding-box;position:relative}.p-datatable-resizable-fit .p-resizable-column:last-child .p-column-resizer{display:none}.p-datatable .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-datatable .p-column-resizer-helper{width:1px;position:absolute;z-index:10;display:none}.p-datatable .p-row-editor-init,.p-datatable .p-row-editor-save,.p-datatable .p-row-editor-cancel,.p-datatable .p-row-toggler{display:inline-flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-datatable-reorder-indicator-up,.p-datatable-reorder-indicator-down{position:absolute;display:none}.p-datatable-reorderablerow-handle,[pReorderableColumn]{cursor:move}.p-datatable .p-datatable-loading-overlay{position:absolute;display:flex;align-items:center;justify-content:center;z-index:2}.p-column-filter-row{display:flex;align-items:center;width:100%}.p-column-filter-menu{display:inline-flex}.p-column-filter-row p-columnfilterformelement{flex:1 1 auto;width:1%}.p-column-filter-menu-button,.p-column-filter-clear-button{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;text-decoration:none;overflow:hidden;position:relative}.p-column-filter-overlay{position:absolute;top:0;left:0}.p-column-filter-row-items{margin:0;padding:0;list-style:none}.p-column-filter-row-item{cursor:pointer}.p-column-filter-add-button,.p-column-filter-remove-button{justify-content:center}.p-column-filter-add-button .p-button-label,.p-column-filter-remove-button .p-button-label{flex-grow:0}.p-column-filter-buttonbar{display:flex;align-items:center;justify-content:space-between}.p-column-filter-buttonbar .p-button{width:auto}.p-datatable .p-datatable-tbody>tr>td>.p-column-title{display:none}cdk-virtual-scroll-viewport{outline:0 none}\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 TableBody; }), selector: "[pTableBody]", inputs: ["pTableBody", "pTableBodyTemplate", "value", "frozen", "frozenRows"] }, { type: i0.forwardRef(function () { return i3.CdkVirtualScrollViewport; }), selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }], directives: [{ type: i0.forwardRef(function () { return i4.NgStyle; }), selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i0.forwardRef(function () { return i4.NgClass; }), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i0.forwardRef(function () { return i4.NgIf; }), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i0.forwardRef(function () { return i4.NgTemplateOutlet; }), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i0.forwardRef(function () { return i3.CdkFixedSizeVirtualScroll; }), selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 1833 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Table, decorators: [{
|
---|
| 1834 | type: Component,
|
---|
| 1835 | args: [{ selector: 'p-table', template: `
|
---|
| 1836 | <div #container [ngStyle]="style" [class]="styleClass"
|
---|
| 1837 | [ngClass]="{'p-datatable p-component': true,
|
---|
| 1838 | 'p-datatable-hoverable-rows': (rowHover||selectionMode),
|
---|
| 1839 | 'p-datatable-auto-layout': autoLayout,
|
---|
| 1840 | 'p-datatable-resizable': resizableColumns,
|
---|
| 1841 | 'p-datatable-resizable-fit': (resizableColumns && columnResizeMode === 'fit'),
|
---|
| 1842 | 'p-datatable-scrollable': scrollable,
|
---|
| 1843 | 'p-datatable-scrollable-vertical': scrollable && scrollDirection === 'vertical',
|
---|
| 1844 | 'p-datatable-scrollable-horizontal': scrollable && scrollDirection === 'horizontal',
|
---|
| 1845 | 'p-datatable-scrollable-both': scrollable && scrollDirection === 'both',
|
---|
| 1846 | 'p-datatable-flex-scrollable': (scrollable && scrollHeight === 'flex'),
|
---|
| 1847 | 'p-datatable-responsive-stack': responsiveLayout === 'stack',
|
---|
| 1848 | 'p-datatable-responsive-scroll': responsiveLayout === 'scroll',
|
---|
| 1849 | 'p-datatable-responsive': responsive,
|
---|
| 1850 | 'p-datatable-grouped-header': headerGroupedTemplate != null,
|
---|
| 1851 | 'p-datatable-grouped-footer': footerGroupedTemplate != null}" [attr.id]="id">
|
---|
| 1852 | <div class="p-datatable-loading-overlay p-component-overlay" *ngIf="loading && showLoader">
|
---|
| 1853 | <i [class]="'p-datatable-loading-icon pi-spin ' + loadingIcon"></i>
|
---|
| 1854 | </div>
|
---|
| 1855 | <div *ngIf="captionTemplate" class="p-datatable-header">
|
---|
| 1856 | <ng-container *ngTemplateOutlet="captionTemplate"></ng-container>
|
---|
| 1857 | </div>
|
---|
| 1858 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-top" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1859 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'top' || paginatorPosition =='both')"
|
---|
| 1860 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo" [dropdownScrollHeight]="paginatorDropdownScrollHeight"
|
---|
| 1861 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showJumpToPageInput]="showJumpToPageInput" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1862 |
|
---|
| 1863 | <div #wrapper class="p-datatable-wrapper" [ngStyle]="{height: scrollHeight}">
|
---|
| 1864 | <table #table *ngIf="!virtualScroll" role="table" class="p-datatable-table" [ngClass]="tableStyleClass" [ngStyle]="tableStyle" [attr.id]="id+'-table'">
|
---|
| 1865 | <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1866 | <thead class="p-datatable-thead">
|
---|
| 1867 | <ng-container *ngTemplateOutlet="headerGroupedTemplate||headerTemplate; context: {$implicit: columns}"></ng-container>
|
---|
| 1868 | </thead>
|
---|
| 1869 | <tbody class="p-datatable-tbody p-datatable-frozen-tbody" *ngIf="frozenValue||frozenBodyTemplate" [value]="frozenValue" [frozenRows]="true" [pTableBody]="columns" [pTableBodyTemplate]="frozenBodyTemplate" [frozen]="true"></tbody>
|
---|
| 1870 | <tbody class="p-datatable-tbody" [value]="dataToRender" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate"></tbody>
|
---|
| 1871 | <tfoot *ngIf="footerGroupedTemplate||footerTemplate" class="p-datatable-tfoot">
|
---|
| 1872 | <ng-container *ngTemplateOutlet="footerGroupedTemplate||footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1873 | </tfoot>
|
---|
| 1874 | </table>
|
---|
| 1875 | <cdk-virtual-scroll-viewport *ngIf="virtualScroll" [itemSize]="virtualRowHeight" tabindex="0" [style.height]="scrollHeight !== 'flex' ? scrollHeight : undefined" [minBufferPx]="minBufferPx" [maxBufferPx]="maxBufferPx" (scrolledIndexChange)="onScrollIndexChange($event)" class="p-datatable-virtual-scrollable-body">
|
---|
| 1876 | <table #table role="table" class="p-datatable-table" [ngClass]="tableStyleClass" [ngStyle]="tableStyle" [attr.id]="id+'-table'">
|
---|
| 1877 | <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1878 | <thead #tableHeader class="p-datatable-thead">
|
---|
| 1879 | <ng-container *ngTemplateOutlet="headerGroupedTemplate||headerTemplate; context: {$implicit: columns}"></ng-container>
|
---|
| 1880 | </thead>
|
---|
| 1881 | <tbody class="p-datatable-tbody p-datatable-frozen-tbody" *ngIf="frozenValue||frozenBodyTemplate" [value]="frozenValue" [frozenRows]="true" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate" [frozen]="true"></tbody>
|
---|
| 1882 | <tbody class="p-datatable-tbody" [value]="dataToRender" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate"></tbody>
|
---|
| 1883 | <tfoot *ngIf="footerGroupedTemplate||footerTemplate" class="p-datatable-tfoot">
|
---|
| 1884 | <ng-container *ngTemplateOutlet="footerGroupedTemplate||footerTemplate; context {$implicit: columns}"></ng-container>
|
---|
| 1885 | </tfoot>
|
---|
| 1886 | </table>
|
---|
| 1887 | </cdk-virtual-scroll-viewport>
|
---|
| 1888 | </div>
|
---|
| 1889 |
|
---|
| 1890 | <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="p-paginator-bottom" [alwaysShow]="alwaysShowPaginator"
|
---|
| 1891 | (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'bottom' || paginatorPosition =='both')"
|
---|
| 1892 | [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo" [dropdownScrollHeight]="paginatorDropdownScrollHeight"
|
---|
| 1893 | [currentPageReportTemplate]="currentPageReportTemplate" [showFirstLastIcon]="showFirstLastIcon" [dropdownItemTemplate]="paginatorDropdownItemTemplate" [showCurrentPageReport]="showCurrentPageReport" [showJumpToPageDropdown]="showJumpToPageDropdown" [showJumpToPageInput]="showJumpToPageInput" [showPageLinks]="showPageLinks"></p-paginator>
|
---|
| 1894 |
|
---|
| 1895 | <div *ngIf="summaryTemplate" class="p-datatable-footer">
|
---|
| 1896 | <ng-container *ngTemplateOutlet="summaryTemplate"></ng-container>
|
---|
| 1897 | </div>
|
---|
| 1898 |
|
---|
| 1899 | <div #resizeHelper class="p-column-resizer-helper" style="display:none" *ngIf="resizableColumns"></div>
|
---|
| 1900 | <span #reorderIndicatorUp class="pi pi-arrow-down p-datatable-reorder-indicator-up" style="display:none" *ngIf="reorderableColumns"></span>
|
---|
| 1901 | <span #reorderIndicatorDown class="pi pi-arrow-up p-datatable-reorder-indicator-down" style="display:none" *ngIf="reorderableColumns"></span>
|
---|
| 1902 | </div>
|
---|
| 1903 | `, providers: [TableService], changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.None, host: {
|
---|
| 1904 | 'class': 'p-element'
|
---|
| 1905 | }, styles: [".p-datatable{position:relative}.p-datatable table{border-collapse:collapse;min-width:100%;table-layout:fixed}.p-datatable .p-sortable-column{cursor:pointer;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-datatable .p-sortable-column .p-column-title,.p-datatable .p-sortable-column .p-sortable-column-icon,.p-datatable .p-sortable-column .p-sortable-column-badge{vertical-align:middle}.p-datatable .p-sortable-column .p-sortable-column-badge{display:inline-flex;align-items:center;justify-content:center}.p-datatable-auto-layout>.p-datatable-wrapper{overflow-x:auto}.p-datatable-auto-layout>.p-datatable-wrapper>table{table-layout:auto}.p-datatable-responsive-scroll>.p-datatable-wrapper{overflow-x:auto}.p-datatable-responsive-scroll>.p-datatable-wrapper>table,.p-datatable-auto-layout>.p-datatable-wrapper>table{table-layout:auto}.p-datatable-hoverable-rows .p-selectable-row{cursor:pointer}.p-datatable-scrollable .p-datatable-wrapper{position:relative;overflow:auto}.p-datatable-scrollable .p-datatable-thead,.p-datatable-scrollable .p-datatable-tbody,.p-datatable-scrollable .p-datatable-tfoot{display:block}.p-datatable-scrollable .p-datatable-thead>tr,.p-datatable-scrollable .p-datatable-tbody>tr,.p-datatable-scrollable .p-datatable-tfoot>tr{display:flex;flex-wrap:nowrap;width:100%}.p-datatable-scrollable .p-datatable-thead>tr>th,.p-datatable-scrollable .p-datatable-tbody>tr>td,.p-datatable-scrollable .p-datatable-tfoot>tr>td{display:flex;flex:1 1 0;align-items:center}.p-datatable-scrollable .p-datatable-thead{position:sticky;top:0;z-index:1}.p-datatable-scrollable .p-datatable-frozen-tbody{position:sticky;z-index:1}.p-datatable-scrollable .p-datatable-tfoot{position:sticky;bottom:0;z-index:1}.p-datatable-scrollable .p-frozen-column{position:sticky;background:inherit}.p-datatable-scrollable th.p-frozen-column{z-index:1}.p-datatable-scrollable-both .p-datatable-thead>tr>th,.p-datatable-scrollable-both .p-datatable-tbody>tr>td,.p-datatable-scrollable-both .p-datatable-tfoot>tr>td,.p-datatable-scrollable-horizontal .p-datatable-thead>tr>th .p-datatable-scrollable-horizontal .p-datatable-tbody>tr>td,.p-datatable-scrollable-horizontal .p-datatable-tfoot>tr>td{flex:0 0 auto}.p-datatable-flex-scrollable{display:flex;flex-direction:column;height:100%}.p-datatable-flex-scrollable .p-datatable-wrapper{display:flex;flex-direction:column;flex:1;height:100%}.p-datatable-scrollable .p-rowgroup-header{position:sticky;z-index:1}.p-datatable-scrollable.p-datatable-grouped-header .p-datatable-thead,.p-datatable-scrollable.p-datatable-grouped-footer .p-datatable-tfoot{display:table;border-collapse:collapse;width:100%;table-layout:fixed}.p-datatable-scrollable.p-datatable-grouped-header .p-datatable-thead>tr,.p-datatable-scrollable.p-datatable-grouped-footer .p-datatable-tfoot>tr{display:table-row}.p-datatable-scrollable.p-datatable-grouped-header .p-datatable-thead>tr>th,.p-datatable-scrollable.p-datatable-grouped-footer .p-datatable-tfoot>tr>td{display:table-cell}.p-datatable-flex-scrollable{display:flex;flex-direction:column;flex:1;height:100%}.p-datatable-flex-scrollable .p-datatable-virtual-scrollable-body{flex:1}.p-datatable-resizable>.p-datatable-wrapper{overflow-x:auto}.p-datatable-resizable .p-datatable-thead>tr>th,.p-datatable-resizable .p-datatable-tfoot>tr>td,.p-datatable-resizable .p-datatable-tbody>tr>td{overflow:hidden;white-space:nowrap}.p-datatable-resizable .p-resizable-column{background-clip:padding-box;position:relative}.p-datatable-resizable-fit .p-resizable-column:last-child .p-column-resizer{display:none}.p-datatable .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-datatable .p-column-resizer-helper{width:1px;position:absolute;z-index:10;display:none}.p-datatable .p-row-editor-init,.p-datatable .p-row-editor-save,.p-datatable .p-row-editor-cancel,.p-datatable .p-row-toggler{display:inline-flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-datatable-reorder-indicator-up,.p-datatable-reorder-indicator-down{position:absolute;display:none}.p-datatable-reorderablerow-handle,[pReorderableColumn]{cursor:move}.p-datatable .p-datatable-loading-overlay{position:absolute;display:flex;align-items:center;justify-content:center;z-index:2}.p-column-filter-row{display:flex;align-items:center;width:100%}.p-column-filter-menu{display:inline-flex}.p-column-filter-row p-columnfilterformelement{flex:1 1 auto;width:1%}.p-column-filter-menu-button,.p-column-filter-clear-button{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;text-decoration:none;overflow:hidden;position:relative}.p-column-filter-overlay{position:absolute;top:0;left:0}.p-column-filter-row-items{margin:0;padding:0;list-style:none}.p-column-filter-row-item{cursor:pointer}.p-column-filter-add-button,.p-column-filter-remove-button{justify-content:center}.p-column-filter-add-button .p-button-label,.p-column-filter-remove-button .p-button-label{flex-grow:0}.p-column-filter-buttonbar{display:flex;align-items:center;justify-content:space-between}.p-column-filter-buttonbar .p-button{width:auto}.p-datatable .p-datatable-tbody>tr>td>.p-column-title{display:none}cdk-virtual-scroll-viewport{outline:0 none}\n"] }]
|
---|
| 1906 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: TableService }, { type: i0.ChangeDetectorRef }, { type: i1.FilterService }, { type: i1.OverlayService }]; }, propDecorators: { frozenColumns: [{
|
---|
| 1907 | type: Input
|
---|
| 1908 | }], frozenValue: [{
|
---|
| 1909 | type: Input
|
---|
| 1910 | }], style: [{
|
---|
| 1911 | type: Input
|
---|
| 1912 | }], styleClass: [{
|
---|
| 1913 | type: Input
|
---|
| 1914 | }], tableStyle: [{
|
---|
| 1915 | type: Input
|
---|
| 1916 | }], tableStyleClass: [{
|
---|
| 1917 | type: Input
|
---|
| 1918 | }], paginator: [{
|
---|
| 1919 | type: Input
|
---|
| 1920 | }], pageLinks: [{
|
---|
| 1921 | type: Input
|
---|
| 1922 | }], rowsPerPageOptions: [{
|
---|
| 1923 | type: Input
|
---|
| 1924 | }], alwaysShowPaginator: [{
|
---|
| 1925 | type: Input
|
---|
| 1926 | }], paginatorPosition: [{
|
---|
| 1927 | type: Input
|
---|
| 1928 | }], paginatorDropdownAppendTo: [{
|
---|
| 1929 | type: Input
|
---|
| 1930 | }], paginatorDropdownScrollHeight: [{
|
---|
| 1931 | type: Input
|
---|
| 1932 | }], currentPageReportTemplate: [{
|
---|
| 1933 | type: Input
|
---|
| 1934 | }], showCurrentPageReport: [{
|
---|
| 1935 | type: Input
|
---|
| 1936 | }], showJumpToPageDropdown: [{
|
---|
| 1937 | type: Input
|
---|
| 1938 | }], showJumpToPageInput: [{
|
---|
| 1939 | type: Input
|
---|
| 1940 | }], showFirstLastIcon: [{
|
---|
| 1941 | type: Input
|
---|
| 1942 | }], showPageLinks: [{
|
---|
| 1943 | type: Input
|
---|
| 1944 | }], defaultSortOrder: [{
|
---|
| 1945 | type: Input
|
---|
| 1946 | }], sortMode: [{
|
---|
| 1947 | type: Input
|
---|
| 1948 | }], resetPageOnSort: [{
|
---|
| 1949 | type: Input
|
---|
| 1950 | }], selectionMode: [{
|
---|
| 1951 | type: Input
|
---|
| 1952 | }], selectionChange: [{
|
---|
| 1953 | type: Output
|
---|
| 1954 | }], contextMenuSelection: [{
|
---|
| 1955 | type: Input
|
---|
| 1956 | }], contextMenuSelectionChange: [{
|
---|
| 1957 | type: Output
|
---|
| 1958 | }], contextMenuSelectionMode: [{
|
---|
| 1959 | type: Input
|
---|
| 1960 | }], dataKey: [{
|
---|
| 1961 | type: Input
|
---|
| 1962 | }], metaKeySelection: [{
|
---|
| 1963 | type: Input
|
---|
| 1964 | }], rowTrackBy: [{
|
---|
| 1965 | type: Input
|
---|
| 1966 | }], lazy: [{
|
---|
| 1967 | type: Input
|
---|
| 1968 | }], lazyLoadOnInit: [{
|
---|
| 1969 | type: Input
|
---|
| 1970 | }], compareSelectionBy: [{
|
---|
| 1971 | type: Input
|
---|
| 1972 | }], csvSeparator: [{
|
---|
| 1973 | type: Input
|
---|
| 1974 | }], exportFilename: [{
|
---|
| 1975 | type: Input
|
---|
| 1976 | }], filters: [{
|
---|
| 1977 | type: Input
|
---|
| 1978 | }], globalFilterFields: [{
|
---|
| 1979 | type: Input
|
---|
| 1980 | }], filterDelay: [{
|
---|
| 1981 | type: Input
|
---|
| 1982 | }], filterLocale: [{
|
---|
| 1983 | type: Input
|
---|
| 1984 | }], expandedRowKeys: [{
|
---|
| 1985 | type: Input
|
---|
| 1986 | }], editingRowKeys: [{
|
---|
| 1987 | type: Input
|
---|
| 1988 | }], rowExpandMode: [{
|
---|
| 1989 | type: Input
|
---|
| 1990 | }], scrollable: [{
|
---|
| 1991 | type: Input
|
---|
| 1992 | }], scrollDirection: [{
|
---|
| 1993 | type: Input
|
---|
| 1994 | }], rowGroupMode: [{
|
---|
| 1995 | type: Input
|
---|
| 1996 | }], scrollHeight: [{
|
---|
| 1997 | type: Input
|
---|
| 1998 | }], virtualScroll: [{
|
---|
| 1999 | type: Input
|
---|
| 2000 | }], virtualScrollDelay: [{
|
---|
| 2001 | type: Input
|
---|
| 2002 | }], virtualRowHeight: [{
|
---|
| 2003 | type: Input
|
---|
| 2004 | }], frozenWidth: [{
|
---|
| 2005 | type: Input
|
---|
| 2006 | }], responsive: [{
|
---|
| 2007 | type: Input
|
---|
| 2008 | }], contextMenu: [{
|
---|
| 2009 | type: Input
|
---|
| 2010 | }], resizableColumns: [{
|
---|
| 2011 | type: Input
|
---|
| 2012 | }], columnResizeMode: [{
|
---|
| 2013 | type: Input
|
---|
| 2014 | }], reorderableColumns: [{
|
---|
| 2015 | type: Input
|
---|
| 2016 | }], loading: [{
|
---|
| 2017 | type: Input
|
---|
| 2018 | }], loadingIcon: [{
|
---|
| 2019 | type: Input
|
---|
| 2020 | }], showLoader: [{
|
---|
| 2021 | type: Input
|
---|
| 2022 | }], rowHover: [{
|
---|
| 2023 | type: Input
|
---|
| 2024 | }], customSort: [{
|
---|
| 2025 | type: Input
|
---|
| 2026 | }], showInitialSortBadge: [{
|
---|
| 2027 | type: Input
|
---|
| 2028 | }], autoLayout: [{
|
---|
| 2029 | type: Input
|
---|
| 2030 | }], exportFunction: [{
|
---|
| 2031 | type: Input
|
---|
| 2032 | }], stateKey: [{
|
---|
| 2033 | type: Input
|
---|
| 2034 | }], stateStorage: [{
|
---|
| 2035 | type: Input
|
---|
| 2036 | }], editMode: [{
|
---|
| 2037 | type: Input
|
---|
| 2038 | }], groupRowsBy: [{
|
---|
| 2039 | type: Input
|
---|
| 2040 | }], groupRowsByOrder: [{
|
---|
| 2041 | type: Input
|
---|
| 2042 | }], minBufferPx: [{
|
---|
| 2043 | type: Input
|
---|
| 2044 | }], maxBufferPx: [{
|
---|
| 2045 | type: Input
|
---|
| 2046 | }], responsiveLayout: [{
|
---|
| 2047 | type: Input
|
---|
| 2048 | }], breakpoint: [{
|
---|
| 2049 | type: Input
|
---|
| 2050 | }], onRowSelect: [{
|
---|
| 2051 | type: Output
|
---|
| 2052 | }], onRowUnselect: [{
|
---|
| 2053 | type: Output
|
---|
| 2054 | }], onPage: [{
|
---|
| 2055 | type: Output
|
---|
| 2056 | }], onSort: [{
|
---|
| 2057 | type: Output
|
---|
| 2058 | }], onFilter: [{
|
---|
| 2059 | type: Output
|
---|
| 2060 | }], onLazyLoad: [{
|
---|
| 2061 | type: Output
|
---|
| 2062 | }], onRowExpand: [{
|
---|
| 2063 | type: Output
|
---|
| 2064 | }], onRowCollapse: [{
|
---|
| 2065 | type: Output
|
---|
| 2066 | }], onContextMenuSelect: [{
|
---|
| 2067 | type: Output
|
---|
| 2068 | }], onColResize: [{
|
---|
| 2069 | type: Output
|
---|
| 2070 | }], onColReorder: [{
|
---|
| 2071 | type: Output
|
---|
| 2072 | }], onRowReorder: [{
|
---|
| 2073 | type: Output
|
---|
| 2074 | }], onEditInit: [{
|
---|
| 2075 | type: Output
|
---|
| 2076 | }], onEditComplete: [{
|
---|
| 2077 | type: Output
|
---|
| 2078 | }], onEditCancel: [{
|
---|
| 2079 | type: Output
|
---|
| 2080 | }], onHeaderCheckboxToggle: [{
|
---|
| 2081 | type: Output
|
---|
| 2082 | }], sortFunction: [{
|
---|
| 2083 | type: Output
|
---|
| 2084 | }], firstChange: [{
|
---|
| 2085 | type: Output
|
---|
| 2086 | }], rowsChange: [{
|
---|
| 2087 | type: Output
|
---|
| 2088 | }], onStateSave: [{
|
---|
| 2089 | type: Output
|
---|
| 2090 | }], onStateRestore: [{
|
---|
| 2091 | type: Output
|
---|
| 2092 | }], containerViewChild: [{
|
---|
| 2093 | type: ViewChild,
|
---|
| 2094 | args: ['container']
|
---|
| 2095 | }], resizeHelperViewChild: [{
|
---|
| 2096 | type: ViewChild,
|
---|
| 2097 | args: ['resizeHelper']
|
---|
| 2098 | }], reorderIndicatorUpViewChild: [{
|
---|
| 2099 | type: ViewChild,
|
---|
| 2100 | args: ['reorderIndicatorUp']
|
---|
| 2101 | }], reorderIndicatorDownViewChild: [{
|
---|
| 2102 | type: ViewChild,
|
---|
| 2103 | args: ['reorderIndicatorDown']
|
---|
| 2104 | }], wrapperViewChild: [{
|
---|
| 2105 | type: ViewChild,
|
---|
| 2106 | args: ['wrapper']
|
---|
| 2107 | }], tableViewChild: [{
|
---|
| 2108 | type: ViewChild,
|
---|
| 2109 | args: ['table']
|
---|
| 2110 | }], tableHeaderViewChild: [{
|
---|
| 2111 | type: ViewChild,
|
---|
| 2112 | args: ['tableHeader']
|
---|
| 2113 | }], virtualScrollBody: [{
|
---|
| 2114 | type: ViewChild,
|
---|
| 2115 | args: [CdkVirtualScrollViewport]
|
---|
| 2116 | }], templates: [{
|
---|
| 2117 | type: ContentChildren,
|
---|
| 2118 | args: [PrimeTemplate]
|
---|
| 2119 | }], value: [{
|
---|
| 2120 | type: Input
|
---|
| 2121 | }], columns: [{
|
---|
| 2122 | type: Input
|
---|
| 2123 | }], first: [{
|
---|
| 2124 | type: Input
|
---|
| 2125 | }], rows: [{
|
---|
| 2126 | type: Input
|
---|
| 2127 | }], totalRecords: [{
|
---|
| 2128 | type: Input
|
---|
| 2129 | }], sortField: [{
|
---|
| 2130 | type: Input
|
---|
| 2131 | }], sortOrder: [{
|
---|
| 2132 | type: Input
|
---|
| 2133 | }], multiSortMeta: [{
|
---|
| 2134 | type: Input
|
---|
| 2135 | }], selection: [{
|
---|
| 2136 | type: Input
|
---|
| 2137 | }] } });
|
---|
| 2138 | class TableBody {
|
---|
| 2139 | constructor(dt, tableService, cd, el) {
|
---|
| 2140 | this.dt = dt;
|
---|
| 2141 | this.tableService = tableService;
|
---|
| 2142 | this.cd = cd;
|
---|
| 2143 | this.el = el;
|
---|
| 2144 | this.subscription = this.dt.tableService.valueSource$.subscribe(() => {
|
---|
| 2145 | if (this.dt.virtualScroll) {
|
---|
| 2146 | this.cd.detectChanges();
|
---|
| 2147 | }
|
---|
| 2148 | });
|
---|
| 2149 | }
|
---|
| 2150 | get value() {
|
---|
| 2151 | return this._value;
|
---|
| 2152 | }
|
---|
| 2153 | set value(val) {
|
---|
| 2154 | this._value = val;
|
---|
| 2155 | if (this.frozenRows) {
|
---|
| 2156 | this.updateFrozenRowStickyPosition();
|
---|
| 2157 | }
|
---|
| 2158 | if (this.dt.scrollable && this.dt.rowGroupMode === 'subheader') {
|
---|
| 2159 | this.updateFrozenRowGroupHeaderStickyPosition();
|
---|
| 2160 | }
|
---|
| 2161 | }
|
---|
| 2162 | ngAfterViewInit() {
|
---|
| 2163 | if (this.frozenRows) {
|
---|
| 2164 | this.updateFrozenRowStickyPosition();
|
---|
| 2165 | }
|
---|
| 2166 | if (this.dt.scrollable && this.dt.rowGroupMode === 'subheader') {
|
---|
| 2167 | this.updateFrozenRowGroupHeaderStickyPosition();
|
---|
| 2168 | }
|
---|
| 2169 | }
|
---|
| 2170 | shouldRenderRowGroupHeader(value, rowData, i) {
|
---|
| 2171 | let currentRowFieldData = ObjectUtils.resolveFieldData(rowData, this.dt.groupRowsBy);
|
---|
| 2172 | let prevRowData = value[i - 1];
|
---|
| 2173 | if (prevRowData) {
|
---|
| 2174 | let previousRowFieldData = ObjectUtils.resolveFieldData(prevRowData, this.dt.groupRowsBy);
|
---|
| 2175 | return currentRowFieldData !== previousRowFieldData;
|
---|
| 2176 | }
|
---|
| 2177 | else {
|
---|
| 2178 | return true;
|
---|
| 2179 | }
|
---|
| 2180 | }
|
---|
| 2181 | shouldRenderRowGroupFooter(value, rowData, i) {
|
---|
| 2182 | let currentRowFieldData = ObjectUtils.resolveFieldData(rowData, this.dt.groupRowsBy);
|
---|
| 2183 | let nextRowData = value[i + 1];
|
---|
| 2184 | if (nextRowData) {
|
---|
| 2185 | let nextRowFieldData = ObjectUtils.resolveFieldData(nextRowData, this.dt.groupRowsBy);
|
---|
| 2186 | return currentRowFieldData !== nextRowFieldData;
|
---|
| 2187 | }
|
---|
| 2188 | else {
|
---|
| 2189 | return true;
|
---|
| 2190 | }
|
---|
| 2191 | }
|
---|
| 2192 | shouldRenderRowspan(value, rowData, i) {
|
---|
| 2193 | let currentRowFieldData = ObjectUtils.resolveFieldData(rowData, this.dt.groupRowsBy);
|
---|
| 2194 | let prevRowData = value[i - 1];
|
---|
| 2195 | if (prevRowData) {
|
---|
| 2196 | let previousRowFieldData = ObjectUtils.resolveFieldData(prevRowData, this.dt.groupRowsBy);
|
---|
| 2197 | return currentRowFieldData !== previousRowFieldData;
|
---|
| 2198 | }
|
---|
| 2199 | else {
|
---|
| 2200 | return true;
|
---|
| 2201 | }
|
---|
| 2202 | }
|
---|
| 2203 | calculateRowGroupSize(value, rowData, index) {
|
---|
| 2204 | let currentRowFieldData = ObjectUtils.resolveFieldData(rowData, this.dt.groupRowsBy);
|
---|
| 2205 | let nextRowFieldData = currentRowFieldData;
|
---|
| 2206 | let groupRowSpan = 0;
|
---|
| 2207 | while (currentRowFieldData === nextRowFieldData) {
|
---|
| 2208 | groupRowSpan++;
|
---|
| 2209 | let nextRowData = value[++index];
|
---|
| 2210 | if (nextRowData) {
|
---|
| 2211 | nextRowFieldData = ObjectUtils.resolveFieldData(nextRowData, this.dt.groupRowsBy);
|
---|
| 2212 | }
|
---|
| 2213 | else {
|
---|
| 2214 | break;
|
---|
| 2215 | }
|
---|
| 2216 | }
|
---|
| 2217 | return groupRowSpan === 1 ? null : groupRowSpan;
|
---|
| 2218 | }
|
---|
| 2219 | ngOnDestroy() {
|
---|
| 2220 | if (this.subscription) {
|
---|
| 2221 | this.subscription.unsubscribe();
|
---|
| 2222 | }
|
---|
| 2223 | }
|
---|
| 2224 | updateFrozenRowStickyPosition() {
|
---|
| 2225 | this.el.nativeElement.style.top = DomHandler.getOuterHeight(this.el.nativeElement.previousElementSibling) + 'px';
|
---|
| 2226 | }
|
---|
| 2227 | updateFrozenRowGroupHeaderStickyPosition() {
|
---|
| 2228 | if (this.el.nativeElement.previousElementSibling) {
|
---|
| 2229 | let tableHeaderHeight = DomHandler.getOuterHeight(this.el.nativeElement.previousElementSibling);
|
---|
| 2230 | this.dt.rowGroupHeaderStyleObject.top = tableHeaderHeight + 'px';
|
---|
| 2231 | }
|
---|
| 2232 | }
|
---|
| 2233 | }
|
---|
| 2234 | TableBody.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableBody, deps: [{ token: Table }, { token: TableService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 2235 | TableBody.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TableBody, selector: "[pTableBody]", inputs: { columns: ["pTableBody", "columns"], template: ["pTableBodyTemplate", "template"], value: "value", frozen: "frozen", frozenRows: "frozenRows" }, host: { classAttribute: "p-element" }, ngImport: i0, template: `
|
---|
| 2236 | <ng-container *ngIf="!dt.expandedRowTemplate && !dt.virtualScroll">
|
---|
| 2237 | <ng-template ngFor let-rowData let-rowIndex="index" [ngForOf]="value" [ngForTrackBy]="dt.rowTrackBy">
|
---|
| 2238 | <ng-container *ngIf="dt.groupHeaderTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupHeader(value, rowData, rowIndex)" role="row">
|
---|
| 2239 | <ng-container *ngTemplateOutlet="dt.groupHeaderTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2240 | </ng-container>
|
---|
| 2241 | <ng-container *ngIf="dt.rowGroupMode !== 'rowspan'">
|
---|
| 2242 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2243 | </ng-container>
|
---|
| 2244 | <ng-container *ngIf="dt.rowGroupMode === 'rowspan'">
|
---|
| 2245 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen, rowgroup: shouldRenderRowspan(value, rowData, rowIndex), rowspan: calculateRowGroupSize(value, rowData, rowIndex)}"></ng-container>
|
---|
| 2246 | </ng-container>
|
---|
| 2247 | <ng-container *ngIf="dt.groupFooterTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupFooter(value, rowData, rowIndex)" role="row">
|
---|
| 2248 | <ng-container *ngTemplateOutlet="dt.groupFooterTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2249 | </ng-container>
|
---|
| 2250 | </ng-template>
|
---|
| 2251 | </ng-container>
|
---|
| 2252 | <ng-container *ngIf="!dt.expandedRowTemplate && dt.virtualScroll">
|
---|
| 2253 | <ng-template cdkVirtualFor let-rowData let-rowIndex="index" [cdkVirtualForOf]="value" [cdkVirtualForTrackBy]="dt.rowTrackBy" [cdkVirtualForTemplateCacheSize]="0">
|
---|
| 2254 | <ng-container *ngTemplateOutlet="rowData ? template: dt.loadingBodyTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2255 | </ng-template>
|
---|
| 2256 | </ng-container>
|
---|
| 2257 | <ng-container *ngIf="dt.expandedRowTemplate && !(frozen && dt.frozenExpandedRowTemplate)">
|
---|
| 2258 | <ng-template ngFor let-rowData let-rowIndex="index" [ngForOf]="value" [ngForTrackBy]="dt.rowTrackBy">
|
---|
| 2259 | <ng-container *ngIf="!dt.groupHeaderTemplate">
|
---|
| 2260 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2261 | </ng-container>
|
---|
| 2262 | <ng-container *ngIf="dt.groupHeaderTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupHeader(value, rowData, rowIndex)" role="row">
|
---|
| 2263 | <ng-container *ngTemplateOutlet="dt.groupHeaderTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2264 | </ng-container>
|
---|
| 2265 | <ng-container *ngIf="dt.isRowExpanded(rowData)">
|
---|
| 2266 | <ng-container *ngTemplateOutlet="dt.expandedRowTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, frozen: frozen}"></ng-container>
|
---|
| 2267 | <ng-container *ngIf="dt.groupFooterTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupFooter(value, rowData, rowIndex)" role="row">
|
---|
| 2268 | <ng-container *ngTemplateOutlet="dt.groupFooterTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2269 | </ng-container>
|
---|
| 2270 | </ng-container>
|
---|
| 2271 | </ng-template>
|
---|
| 2272 | </ng-container>
|
---|
| 2273 | <ng-container *ngIf="dt.frozenExpandedRowTemplate && frozen">
|
---|
| 2274 | <ng-template ngFor let-rowData let-rowIndex="index" [ngForOf]="value" [ngForTrackBy]="dt.rowTrackBy">
|
---|
| 2275 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2276 | <ng-container *ngIf="dt.isRowExpanded(rowData)">
|
---|
| 2277 | <ng-container *ngTemplateOutlet="dt.frozenExpandedRowTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, frozen: frozen}"></ng-container>
|
---|
| 2278 | </ng-container>
|
---|
| 2279 | </ng-template>
|
---|
| 2280 | </ng-container>
|
---|
| 2281 | <ng-container *ngIf="dt.loading">
|
---|
| 2282 | <ng-container *ngTemplateOutlet="dt.loadingBodyTemplate; context: {$implicit: columns, frozen: frozen}"></ng-container>
|
---|
| 2283 | </ng-container>
|
---|
| 2284 | <ng-container *ngIf="dt.isEmpty() && !dt.loading">
|
---|
| 2285 | <ng-container *ngTemplateOutlet="dt.emptyMessageTemplate; context: {$implicit: columns, frozen: frozen}"></ng-container>
|
---|
| 2286 | </ng-container>
|
---|
| 2287 | `, isInline: true, directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 2288 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableBody, decorators: [{
|
---|
| 2289 | type: Component,
|
---|
| 2290 | args: [{
|
---|
| 2291 | selector: '[pTableBody]',
|
---|
| 2292 | template: `
|
---|
| 2293 | <ng-container *ngIf="!dt.expandedRowTemplate && !dt.virtualScroll">
|
---|
| 2294 | <ng-template ngFor let-rowData let-rowIndex="index" [ngForOf]="value" [ngForTrackBy]="dt.rowTrackBy">
|
---|
| 2295 | <ng-container *ngIf="dt.groupHeaderTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupHeader(value, rowData, rowIndex)" role="row">
|
---|
| 2296 | <ng-container *ngTemplateOutlet="dt.groupHeaderTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2297 | </ng-container>
|
---|
| 2298 | <ng-container *ngIf="dt.rowGroupMode !== 'rowspan'">
|
---|
| 2299 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2300 | </ng-container>
|
---|
| 2301 | <ng-container *ngIf="dt.rowGroupMode === 'rowspan'">
|
---|
| 2302 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen, rowgroup: shouldRenderRowspan(value, rowData, rowIndex), rowspan: calculateRowGroupSize(value, rowData, rowIndex)}"></ng-container>
|
---|
| 2303 | </ng-container>
|
---|
| 2304 | <ng-container *ngIf="dt.groupFooterTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupFooter(value, rowData, rowIndex)" role="row">
|
---|
| 2305 | <ng-container *ngTemplateOutlet="dt.groupFooterTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2306 | </ng-container>
|
---|
| 2307 | </ng-template>
|
---|
| 2308 | </ng-container>
|
---|
| 2309 | <ng-container *ngIf="!dt.expandedRowTemplate && dt.virtualScroll">
|
---|
| 2310 | <ng-template cdkVirtualFor let-rowData let-rowIndex="index" [cdkVirtualForOf]="value" [cdkVirtualForTrackBy]="dt.rowTrackBy" [cdkVirtualForTemplateCacheSize]="0">
|
---|
| 2311 | <ng-container *ngTemplateOutlet="rowData ? template: dt.loadingBodyTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2312 | </ng-template>
|
---|
| 2313 | </ng-container>
|
---|
| 2314 | <ng-container *ngIf="dt.expandedRowTemplate && !(frozen && dt.frozenExpandedRowTemplate)">
|
---|
| 2315 | <ng-template ngFor let-rowData let-rowIndex="index" [ngForOf]="value" [ngForTrackBy]="dt.rowTrackBy">
|
---|
| 2316 | <ng-container *ngIf="!dt.groupHeaderTemplate">
|
---|
| 2317 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2318 | </ng-container>
|
---|
| 2319 | <ng-container *ngIf="dt.groupHeaderTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupHeader(value, rowData, rowIndex)" role="row">
|
---|
| 2320 | <ng-container *ngTemplateOutlet="dt.groupHeaderTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2321 | </ng-container>
|
---|
| 2322 | <ng-container *ngIf="dt.isRowExpanded(rowData)">
|
---|
| 2323 | <ng-container *ngTemplateOutlet="dt.expandedRowTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, frozen: frozen}"></ng-container>
|
---|
| 2324 | <ng-container *ngIf="dt.groupFooterTemplate && dt.rowGroupMode === 'subheader' && shouldRenderRowGroupFooter(value, rowData, rowIndex)" role="row">
|
---|
| 2325 | <ng-container *ngTemplateOutlet="dt.groupFooterTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2326 | </ng-container>
|
---|
| 2327 | </ng-container>
|
---|
| 2328 | </ng-template>
|
---|
| 2329 | </ng-container>
|
---|
| 2330 | <ng-container *ngIf="dt.frozenExpandedRowTemplate && frozen">
|
---|
| 2331 | <ng-template ngFor let-rowData let-rowIndex="index" [ngForOf]="value" [ngForTrackBy]="dt.rowTrackBy">
|
---|
| 2332 | <ng-container *ngTemplateOutlet="template; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, expanded: dt.isRowExpanded(rowData), editing: (dt.editMode === 'row' && dt.isRowEditing(rowData)), frozen: frozen}"></ng-container>
|
---|
| 2333 | <ng-container *ngIf="dt.isRowExpanded(rowData)">
|
---|
| 2334 | <ng-container *ngTemplateOutlet="dt.frozenExpandedRowTemplate; context: {$implicit: rowData, rowIndex: dt.paginator ? (dt.first + rowIndex) : rowIndex, columns: columns, frozen: frozen}"></ng-container>
|
---|
| 2335 | </ng-container>
|
---|
| 2336 | </ng-template>
|
---|
| 2337 | </ng-container>
|
---|
| 2338 | <ng-container *ngIf="dt.loading">
|
---|
| 2339 | <ng-container *ngTemplateOutlet="dt.loadingBodyTemplate; context: {$implicit: columns, frozen: frozen}"></ng-container>
|
---|
| 2340 | </ng-container>
|
---|
| 2341 | <ng-container *ngIf="dt.isEmpty() && !dt.loading">
|
---|
| 2342 | <ng-container *ngTemplateOutlet="dt.emptyMessageTemplate; context: {$implicit: columns, frozen: frozen}"></ng-container>
|
---|
| 2343 | </ng-container>
|
---|
| 2344 | `,
|
---|
| 2345 | changeDetection: ChangeDetectionStrategy.Default,
|
---|
| 2346 | encapsulation: ViewEncapsulation.None,
|
---|
| 2347 | host: {
|
---|
| 2348 | 'class': 'p-element'
|
---|
| 2349 | }
|
---|
| 2350 | }]
|
---|
| 2351 | }], ctorParameters: function () { return [{ type: Table }, { type: TableService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { columns: [{
|
---|
| 2352 | type: Input,
|
---|
| 2353 | args: ["pTableBody"]
|
---|
| 2354 | }], template: [{
|
---|
| 2355 | type: Input,
|
---|
| 2356 | args: ["pTableBodyTemplate"]
|
---|
| 2357 | }], value: [{
|
---|
| 2358 | type: Input
|
---|
| 2359 | }], frozen: [{
|
---|
| 2360 | type: Input
|
---|
| 2361 | }], frozenRows: [{
|
---|
| 2362 | type: Input
|
---|
| 2363 | }] } });
|
---|
| 2364 | class RowGroupHeader {
|
---|
| 2365 | constructor(dt) {
|
---|
| 2366 | this.dt = dt;
|
---|
| 2367 | }
|
---|
| 2368 | get getFrozenRowGroupHeaderStickyPosition() {
|
---|
| 2369 | return this.dt.rowGroupHeaderStyleObject ? this.dt.rowGroupHeaderStyleObject.top : '';
|
---|
| 2370 | }
|
---|
| 2371 | }
|
---|
| 2372 | RowGroupHeader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RowGroupHeader, deps: [{ token: Table }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2373 | RowGroupHeader.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: RowGroupHeader, selector: "[pRowGroupHeader]", host: { properties: { "style.top": "getFrozenRowGroupHeaderStickyPosition" }, classAttribute: "p-rowgroup-header p-element" }, ngImport: i0 });
|
---|
| 2374 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RowGroupHeader, decorators: [{
|
---|
| 2375 | type: Directive,
|
---|
| 2376 | args: [{
|
---|
| 2377 | selector: '[pRowGroupHeader]',
|
---|
| 2378 | host: {
|
---|
| 2379 | 'class': 'p-rowgroup-header p-element',
|
---|
| 2380 | '[style.top]': "getFrozenRowGroupHeaderStickyPosition"
|
---|
| 2381 | }
|
---|
| 2382 | }]
|
---|
| 2383 | }], ctorParameters: function () { return [{ type: Table }]; } });
|
---|
| 2384 | class FrozenColumn {
|
---|
| 2385 | constructor(el) {
|
---|
| 2386 | this.el = el;
|
---|
| 2387 | this.alignFrozen = "left";
|
---|
| 2388 | this._frozen = true;
|
---|
| 2389 | }
|
---|
| 2390 | get frozen() {
|
---|
| 2391 | return this._frozen;
|
---|
| 2392 | }
|
---|
| 2393 | set frozen(val) {
|
---|
| 2394 | this._frozen = val;
|
---|
| 2395 | this.updateStickyPosition();
|
---|
| 2396 | }
|
---|
| 2397 | ngAfterViewInit() {
|
---|
| 2398 | this.updateStickyPosition();
|
---|
| 2399 | }
|
---|
| 2400 | updateStickyPosition() {
|
---|
| 2401 | if (this._frozen) {
|
---|
| 2402 | if (this.alignFrozen === 'right') {
|
---|
| 2403 | let right = 0;
|
---|
| 2404 | let next = this.el.nativeElement.nextElementSibling;
|
---|
| 2405 | if (next) {
|
---|
| 2406 | right = DomHandler.getOuterWidth(next) + parseFloat(next.style.right);
|
---|
| 2407 | }
|
---|
| 2408 | this.el.nativeElement.style.right = right + 'px';
|
---|
| 2409 | }
|
---|
| 2410 | else {
|
---|
| 2411 | let left = 0;
|
---|
| 2412 | let prev = this.el.nativeElement.previousElementSibling;
|
---|
| 2413 | if (prev) {
|
---|
| 2414 | left = DomHandler.getOuterWidth(prev) + parseFloat(prev.style.left);
|
---|
| 2415 | }
|
---|
| 2416 | this.el.nativeElement.style.left = left + 'px';
|
---|
| 2417 | }
|
---|
| 2418 | let filterRow = this.el.nativeElement.parentElement.nextElementSibling;
|
---|
| 2419 | if (filterRow) {
|
---|
| 2420 | let index = DomHandler.index(this.el.nativeElement);
|
---|
| 2421 | if (filterRow.children && filterRow.children[index]) {
|
---|
| 2422 | filterRow.children[index].style.left = this.el.nativeElement.style.left;
|
---|
| 2423 | filterRow.children[index].style.right = this.el.nativeElement.style.right;
|
---|
| 2424 | }
|
---|
| 2425 | }
|
---|
| 2426 | }
|
---|
| 2427 | }
|
---|
| 2428 | }
|
---|
| 2429 | FrozenColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: FrozenColumn, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2430 | FrozenColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: FrozenColumn, selector: "[pFrozenColumn]", inputs: { frozen: "frozen", alignFrozen: "alignFrozen" }, host: { properties: { "class.p-frozen-column": "frozen" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 2431 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: FrozenColumn, decorators: [{
|
---|
| 2432 | type: Directive,
|
---|
| 2433 | args: [{
|
---|
| 2434 | selector: '[pFrozenColumn]',
|
---|
| 2435 | host: {
|
---|
| 2436 | 'class': 'p-element',
|
---|
| 2437 | '[class.p-frozen-column]': 'frozen'
|
---|
| 2438 | }
|
---|
| 2439 | }]
|
---|
| 2440 | }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { frozen: [{
|
---|
| 2441 | type: Input
|
---|
| 2442 | }], alignFrozen: [{
|
---|
| 2443 | type: Input
|
---|
| 2444 | }] } });
|
---|
| 2445 | class SortableColumn {
|
---|
| 2446 | constructor(dt) {
|
---|
| 2447 | this.dt = dt;
|
---|
| 2448 | if (this.isEnabled()) {
|
---|
| 2449 | this.subscription = this.dt.tableService.sortSource$.subscribe(sortMeta => {
|
---|
| 2450 | this.updateSortState();
|
---|
| 2451 | });
|
---|
| 2452 | }
|
---|
| 2453 | }
|
---|
| 2454 | ngOnInit() {
|
---|
| 2455 | if (this.isEnabled()) {
|
---|
| 2456 | this.updateSortState();
|
---|
| 2457 | }
|
---|
| 2458 | }
|
---|
| 2459 | updateSortState() {
|
---|
| 2460 | this.sorted = this.dt.isSorted(this.field);
|
---|
| 2461 | this.sortOrder = this.sorted ? (this.dt.sortOrder === 1 ? 'ascending' : 'descending') : 'none';
|
---|
| 2462 | }
|
---|
| 2463 | onClick(event) {
|
---|
| 2464 | if (this.isEnabled() && !this.isFilterElement(event.target)) {
|
---|
| 2465 | this.updateSortState();
|
---|
| 2466 | this.dt.sort({
|
---|
| 2467 | originalEvent: event,
|
---|
| 2468 | field: this.field
|
---|
| 2469 | });
|
---|
| 2470 | DomHandler.clearSelection();
|
---|
| 2471 | }
|
---|
| 2472 | }
|
---|
| 2473 | onEnterKey(event) {
|
---|
| 2474 | this.onClick(event);
|
---|
| 2475 | }
|
---|
| 2476 | isEnabled() {
|
---|
| 2477 | return this.pSortableColumnDisabled !== true;
|
---|
| 2478 | }
|
---|
| 2479 | isFilterElement(element) {
|
---|
| 2480 | return DomHandler.hasClass(element, 'pi-filter-icon') || DomHandler.hasClass(element, 'p-column-filter-menu-button');
|
---|
| 2481 | }
|
---|
| 2482 | ngOnDestroy() {
|
---|
| 2483 | if (this.subscription) {
|
---|
| 2484 | this.subscription.unsubscribe();
|
---|
| 2485 | }
|
---|
| 2486 | }
|
---|
| 2487 | }
|
---|
| 2488 | SortableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SortableColumn, deps: [{ token: Table }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2489 | SortableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: SortableColumn, selector: "[pSortableColumn]", inputs: { field: ["pSortableColumn", "field"], pSortableColumnDisabled: "pSortableColumnDisabled" }, 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\"", "attr.aria-sort": "sortOrder" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 2490 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SortableColumn, decorators: [{
|
---|
| 2491 | type: Directive,
|
---|
| 2492 | args: [{
|
---|
| 2493 | selector: '[pSortableColumn]',
|
---|
| 2494 | host: {
|
---|
| 2495 | 'class': 'p-element',
|
---|
| 2496 | '[class.p-sortable-column]': 'isEnabled()',
|
---|
| 2497 | '[class.p-highlight]': 'sorted',
|
---|
| 2498 | '[attr.tabindex]': 'isEnabled() ? "0" : null',
|
---|
| 2499 | '[attr.role]': '"columnheader"',
|
---|
| 2500 | '[attr.aria-sort]': 'sortOrder'
|
---|
| 2501 | }
|
---|
| 2502 | }]
|
---|
| 2503 | }], ctorParameters: function () { return [{ type: Table }]; }, propDecorators: { field: [{
|
---|
| 2504 | type: Input,
|
---|
| 2505 | args: ["pSortableColumn"]
|
---|
| 2506 | }], pSortableColumnDisabled: [{
|
---|
| 2507 | type: Input
|
---|
| 2508 | }], onClick: [{
|
---|
| 2509 | type: HostListener,
|
---|
| 2510 | args: ['click', ['$event']]
|
---|
| 2511 | }], onEnterKey: [{
|
---|
| 2512 | type: HostListener,
|
---|
| 2513 | args: ['keydown.enter', ['$event']]
|
---|
| 2514 | }] } });
|
---|
| 2515 | class SortIcon {
|
---|
| 2516 | constructor(dt, cd) {
|
---|
| 2517 | this.dt = dt;
|
---|
| 2518 | this.cd = cd;
|
---|
| 2519 | this.subscription = this.dt.tableService.sortSource$.subscribe(sortMeta => {
|
---|
| 2520 | this.updateSortState();
|
---|
| 2521 | });
|
---|
| 2522 | }
|
---|
| 2523 | ngOnInit() {
|
---|
| 2524 | this.updateSortState();
|
---|
| 2525 | }
|
---|
| 2526 | onClick(event) {
|
---|
| 2527 | event.preventDefault();
|
---|
| 2528 | }
|
---|
| 2529 | updateSortState() {
|
---|
| 2530 | if (this.dt.sortMode === 'single') {
|
---|
| 2531 | this.sortOrder = this.dt.isSorted(this.field) ? this.dt.sortOrder : 0;
|
---|
| 2532 | }
|
---|
| 2533 | else if (this.dt.sortMode === 'multiple') {
|
---|
| 2534 | let sortMeta = this.dt.getSortMeta(this.field);
|
---|
| 2535 | this.sortOrder = sortMeta ? sortMeta.order : 0;
|
---|
| 2536 | }
|
---|
| 2537 | this.cd.markForCheck();
|
---|
| 2538 | }
|
---|
| 2539 | getMultiSortMetaIndex() {
|
---|
| 2540 | let multiSortMeta = this.dt._multiSortMeta;
|
---|
| 2541 | let index = -1;
|
---|
| 2542 | if (multiSortMeta && this.dt.sortMode === 'multiple' && (this.dt.showInitialSortBadge || multiSortMeta.length > 1)) {
|
---|
| 2543 | for (let i = 0; i < multiSortMeta.length; i++) {
|
---|
| 2544 | let meta = multiSortMeta[i];
|
---|
| 2545 | if (meta.field === this.field || meta.field === this.field) {
|
---|
| 2546 | index = i;
|
---|
| 2547 | break;
|
---|
| 2548 | }
|
---|
| 2549 | }
|
---|
| 2550 | }
|
---|
| 2551 | return index;
|
---|
| 2552 | }
|
---|
| 2553 | getBadgeValue() {
|
---|
| 2554 | let index = this.getMultiSortMetaIndex();
|
---|
| 2555 | return this.dt.groupRowsBy && index > -1 ? index : index + 1;
|
---|
| 2556 | }
|
---|
| 2557 | isMultiSorted() {
|
---|
| 2558 | return this.dt.sortMode === 'multiple' && this.getMultiSortMetaIndex() > -1;
|
---|
| 2559 | }
|
---|
| 2560 | ngOnDestroy() {
|
---|
| 2561 | if (this.subscription) {
|
---|
| 2562 | this.subscription.unsubscribe();
|
---|
| 2563 | }
|
---|
| 2564 | }
|
---|
| 2565 | }
|
---|
| 2566 | SortIcon.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SortIcon, deps: [{ token: Table }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 2567 | SortIcon.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: SortIcon, selector: "p-sortIcon", inputs: { field: "field" }, host: { classAttribute: "p-element" }, ngImport: i0, template: `
|
---|
| 2568 | <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>
|
---|
| 2569 | <span *ngIf="isMultiSorted()" class="p-sortable-column-badge">{{getBadgeValue()}}</span>
|
---|
| 2570 | `, isInline: true, directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 2571 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SortIcon, decorators: [{
|
---|
| 2572 | type: Component,
|
---|
| 2573 | args: [{
|
---|
| 2574 | selector: 'p-sortIcon',
|
---|
| 2575 | template: `
|
---|
| 2576 | <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>
|
---|
| 2577 | <span *ngIf="isMultiSorted()" class="p-sortable-column-badge">{{getBadgeValue()}}</span>
|
---|
| 2578 | `,
|
---|
| 2579 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 2580 | encapsulation: ViewEncapsulation.None,
|
---|
| 2581 | host: {
|
---|
| 2582 | 'class': 'p-element'
|
---|
| 2583 | }
|
---|
| 2584 | }]
|
---|
| 2585 | }], ctorParameters: function () { return [{ type: Table }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { field: [{
|
---|
| 2586 | type: Input
|
---|
| 2587 | }] } });
|
---|
| 2588 | class SelectableRow {
|
---|
| 2589 | constructor(dt, tableService) {
|
---|
| 2590 | this.dt = dt;
|
---|
| 2591 | this.tableService = tableService;
|
---|
| 2592 | if (this.isEnabled()) {
|
---|
| 2593 | this.subscription = this.dt.tableService.selectionSource$.subscribe(() => {
|
---|
| 2594 | this.selected = this.dt.isSelected(this.data);
|
---|
| 2595 | });
|
---|
| 2596 | }
|
---|
| 2597 | }
|
---|
| 2598 | ngOnInit() {
|
---|
| 2599 | if (this.isEnabled()) {
|
---|
| 2600 | this.selected = this.dt.isSelected(this.data);
|
---|
| 2601 | }
|
---|
| 2602 | }
|
---|
| 2603 | onClick(event) {
|
---|
| 2604 | if (this.isEnabled()) {
|
---|
| 2605 | this.dt.handleRowClick({
|
---|
| 2606 | originalEvent: event,
|
---|
| 2607 | rowData: this.data,
|
---|
| 2608 | rowIndex: this.index
|
---|
| 2609 | });
|
---|
| 2610 | }
|
---|
| 2611 | }
|
---|
| 2612 | onTouchEnd(event) {
|
---|
| 2613 | if (this.isEnabled()) {
|
---|
| 2614 | this.dt.handleRowTouchEnd(event);
|
---|
| 2615 | }
|
---|
| 2616 | }
|
---|
| 2617 | onArrowDownKeyDown(event) {
|
---|
| 2618 | if (!this.isEnabled()) {
|
---|
| 2619 | return;
|
---|
| 2620 | }
|
---|
| 2621 | const row = event.currentTarget;
|
---|
| 2622 | const nextRow = this.findNextSelectableRow(row);
|
---|
| 2623 | if (nextRow) {
|
---|
| 2624 | nextRow.focus();
|
---|
| 2625 | }
|
---|
| 2626 | event.preventDefault();
|
---|
| 2627 | }
|
---|
| 2628 | onArrowUpKeyDown(event) {
|
---|
| 2629 | if (!this.isEnabled()) {
|
---|
| 2630 | return;
|
---|
| 2631 | }
|
---|
| 2632 | const row = event.currentTarget;
|
---|
| 2633 | const prevRow = this.findPrevSelectableRow(row);
|
---|
| 2634 | if (prevRow) {
|
---|
| 2635 | prevRow.focus();
|
---|
| 2636 | }
|
---|
| 2637 | event.preventDefault();
|
---|
| 2638 | }
|
---|
| 2639 | onEnterKeyDown(event) {
|
---|
| 2640 | if (!this.isEnabled()) {
|
---|
| 2641 | return;
|
---|
| 2642 | }
|
---|
| 2643 | this.dt.handleRowClick({
|
---|
| 2644 | originalEvent: event,
|
---|
| 2645 | rowData: this.data,
|
---|
| 2646 | rowIndex: this.index
|
---|
| 2647 | });
|
---|
| 2648 | }
|
---|
| 2649 | onPageDownKeyDown() {
|
---|
| 2650 | if (this.dt.virtualScroll) {
|
---|
| 2651 | this.dt.virtualScrollBody.elementRef.nativeElement.focus();
|
---|
| 2652 | }
|
---|
| 2653 | }
|
---|
| 2654 | onSpaceKeydown() {
|
---|
| 2655 | if (this.dt.virtualScroll && !this.dt.editingCell) {
|
---|
| 2656 | this.dt.virtualScrollBody.elementRef.nativeElement.focus();
|
---|
| 2657 | }
|
---|
| 2658 | }
|
---|
| 2659 | findNextSelectableRow(row) {
|
---|
| 2660 | let nextRow = row.nextElementSibling;
|
---|
| 2661 | if (nextRow) {
|
---|
| 2662 | if (DomHandler.hasClass(nextRow, 'p-selectable-row'))
|
---|
| 2663 | return nextRow;
|
---|
| 2664 | else
|
---|
| 2665 | return this.findNextSelectableRow(nextRow);
|
---|
| 2666 | }
|
---|
| 2667 | else {
|
---|
| 2668 | return null;
|
---|
| 2669 | }
|
---|
| 2670 | }
|
---|
| 2671 | findPrevSelectableRow(row) {
|
---|
| 2672 | let prevRow = row.previousElementSibling;
|
---|
| 2673 | if (prevRow) {
|
---|
| 2674 | if (DomHandler.hasClass(prevRow, 'p-selectable-row'))
|
---|
| 2675 | return prevRow;
|
---|
| 2676 | else
|
---|
| 2677 | return this.findPrevSelectableRow(prevRow);
|
---|
| 2678 | }
|
---|
| 2679 | else {
|
---|
| 2680 | return null;
|
---|
| 2681 | }
|
---|
| 2682 | }
|
---|
| 2683 | isEnabled() {
|
---|
| 2684 | return this.pSelectableRowDisabled !== true;
|
---|
| 2685 | }
|
---|
| 2686 | ngOnDestroy() {
|
---|
| 2687 | if (this.subscription) {
|
---|
| 2688 | this.subscription.unsubscribe();
|
---|
| 2689 | }
|
---|
| 2690 | }
|
---|
| 2691 | }
|
---|
| 2692 | SelectableRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SelectableRow, deps: [{ token: Table }, { token: TableService }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2693 | SelectableRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: SelectableRow, selector: "[pSelectableRow]", inputs: { data: ["pSelectableRow", "data"], index: ["pSelectableRowIndex", "index"], pSelectableRowDisabled: "pSelectableRowDisabled" }, host: { listeners: { "click": "onClick($event)", "touchend": "onTouchEnd($event)", "keydown.arrowdown": "onArrowDownKeyDown($event)", "keydown.arrowup": "onArrowUpKeyDown($event)", "keydown.enter": "onEnterKeyDown($event)", "keydown.shift.enter": "onEnterKeyDown($event)", "keydown.meta.enter": "onEnterKeyDown($event)", "keydown.pagedown": "onPageDownKeyDown()", "keydown.pageup": "onPageDownKeyDown()", "keydown.home": "onPageDownKeyDown()", "keydown.end": "onPageDownKeyDown()", "keydown.space": "onSpaceKeydown()" }, properties: { "class.p-selectable-row": "isEnabled()", "class.p-highlight": "selected", "attr.tabindex": "isEnabled() ? 0 : undefined" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 2694 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SelectableRow, decorators: [{
|
---|
| 2695 | type: Directive,
|
---|
| 2696 | args: [{
|
---|
| 2697 | selector: '[pSelectableRow]',
|
---|
| 2698 | host: {
|
---|
| 2699 | 'class': 'p-element',
|
---|
| 2700 | '[class.p-selectable-row]': 'isEnabled()',
|
---|
| 2701 | '[class.p-highlight]': 'selected',
|
---|
| 2702 | '[attr.tabindex]': 'isEnabled() ? 0 : undefined'
|
---|
| 2703 | }
|
---|
| 2704 | }]
|
---|
| 2705 | }], ctorParameters: function () { return [{ type: Table }, { type: TableService }]; }, propDecorators: { data: [{
|
---|
| 2706 | type: Input,
|
---|
| 2707 | args: ["pSelectableRow"]
|
---|
| 2708 | }], index: [{
|
---|
| 2709 | type: Input,
|
---|
| 2710 | args: ["pSelectableRowIndex"]
|
---|
| 2711 | }], pSelectableRowDisabled: [{
|
---|
| 2712 | type: Input
|
---|
| 2713 | }], onClick: [{
|
---|
| 2714 | type: HostListener,
|
---|
| 2715 | args: ['click', ['$event']]
|
---|
| 2716 | }], onTouchEnd: [{
|
---|
| 2717 | type: HostListener,
|
---|
| 2718 | args: ['touchend', ['$event']]
|
---|
| 2719 | }], onArrowDownKeyDown: [{
|
---|
| 2720 | type: HostListener,
|
---|
| 2721 | args: ['keydown.arrowdown', ['$event']]
|
---|
| 2722 | }], onArrowUpKeyDown: [{
|
---|
| 2723 | type: HostListener,
|
---|
| 2724 | args: ['keydown.arrowup', ['$event']]
|
---|
| 2725 | }], onEnterKeyDown: [{
|
---|
| 2726 | type: HostListener,
|
---|
| 2727 | args: ['keydown.enter', ['$event']]
|
---|
| 2728 | }, {
|
---|
| 2729 | type: HostListener,
|
---|
| 2730 | args: ['keydown.shift.enter', ['$event']]
|
---|
| 2731 | }, {
|
---|
| 2732 | type: HostListener,
|
---|
| 2733 | args: ['keydown.meta.enter', ['$event']]
|
---|
| 2734 | }], onPageDownKeyDown: [{
|
---|
| 2735 | type: HostListener,
|
---|
| 2736 | args: ['keydown.pagedown']
|
---|
| 2737 | }, {
|
---|
| 2738 | type: HostListener,
|
---|
| 2739 | args: ['keydown.pageup']
|
---|
| 2740 | }, {
|
---|
| 2741 | type: HostListener,
|
---|
| 2742 | args: ['keydown.home']
|
---|
| 2743 | }, {
|
---|
| 2744 | type: HostListener,
|
---|
| 2745 | args: ['keydown.end']
|
---|
| 2746 | }], onSpaceKeydown: [{
|
---|
| 2747 | type: HostListener,
|
---|
| 2748 | args: ['keydown.space']
|
---|
| 2749 | }] } });
|
---|
| 2750 | class SelectableRowDblClick {
|
---|
| 2751 | constructor(dt, tableService) {
|
---|
| 2752 | this.dt = dt;
|
---|
| 2753 | this.tableService = tableService;
|
---|
| 2754 | if (this.isEnabled()) {
|
---|
| 2755 | this.subscription = this.dt.tableService.selectionSource$.subscribe(() => {
|
---|
| 2756 | this.selected = this.dt.isSelected(this.data);
|
---|
| 2757 | });
|
---|
| 2758 | }
|
---|
| 2759 | }
|
---|
| 2760 | ngOnInit() {
|
---|
| 2761 | if (this.isEnabled()) {
|
---|
| 2762 | this.selected = this.dt.isSelected(this.data);
|
---|
| 2763 | }
|
---|
| 2764 | }
|
---|
| 2765 | onClick(event) {
|
---|
| 2766 | if (this.isEnabled()) {
|
---|
| 2767 | this.dt.handleRowClick({
|
---|
| 2768 | originalEvent: event,
|
---|
| 2769 | rowData: this.data,
|
---|
| 2770 | rowIndex: this.index
|
---|
| 2771 | });
|
---|
| 2772 | }
|
---|
| 2773 | }
|
---|
| 2774 | isEnabled() {
|
---|
| 2775 | return this.pSelectableRowDisabled !== true;
|
---|
| 2776 | }
|
---|
| 2777 | ngOnDestroy() {
|
---|
| 2778 | if (this.subscription) {
|
---|
| 2779 | this.subscription.unsubscribe();
|
---|
| 2780 | }
|
---|
| 2781 | }
|
---|
| 2782 | }
|
---|
| 2783 | SelectableRowDblClick.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SelectableRowDblClick, deps: [{ token: Table }, { token: TableService }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2784 | SelectableRowDblClick.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: SelectableRowDblClick, selector: "[pSelectableRowDblClick]", inputs: { data: ["pSelectableRowDblClick", "data"], index: ["pSelectableRowIndex", "index"], pSelectableRowDisabled: "pSelectableRowDisabled" }, host: { listeners: { "dblclick": "onClick($event)" }, properties: { "class.p-selectable-row": "isEnabled()", "class.p-highlight": "selected" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 2785 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SelectableRowDblClick, decorators: [{
|
---|
| 2786 | type: Directive,
|
---|
| 2787 | args: [{
|
---|
| 2788 | selector: '[pSelectableRowDblClick]',
|
---|
| 2789 | host: {
|
---|
| 2790 | 'class': 'p-element',
|
---|
| 2791 | '[class.p-selectable-row]': 'isEnabled()',
|
---|
| 2792 | '[class.p-highlight]': 'selected'
|
---|
| 2793 | }
|
---|
| 2794 | }]
|
---|
| 2795 | }], ctorParameters: function () { return [{ type: Table }, { type: TableService }]; }, propDecorators: { data: [{
|
---|
| 2796 | type: Input,
|
---|
| 2797 | args: ["pSelectableRowDblClick"]
|
---|
| 2798 | }], index: [{
|
---|
| 2799 | type: Input,
|
---|
| 2800 | args: ["pSelectableRowIndex"]
|
---|
| 2801 | }], pSelectableRowDisabled: [{
|
---|
| 2802 | type: Input
|
---|
| 2803 | }], onClick: [{
|
---|
| 2804 | type: HostListener,
|
---|
| 2805 | args: ['dblclick', ['$event']]
|
---|
| 2806 | }] } });
|
---|
| 2807 | class ContextMenuRow {
|
---|
| 2808 | constructor(dt, tableService, el) {
|
---|
| 2809 | this.dt = dt;
|
---|
| 2810 | this.tableService = tableService;
|
---|
| 2811 | this.el = el;
|
---|
| 2812 | if (this.isEnabled()) {
|
---|
| 2813 | this.subscription = this.dt.tableService.contextMenuSource$.subscribe((data) => {
|
---|
| 2814 | this.selected = this.dt.equals(this.data, data);
|
---|
| 2815 | });
|
---|
| 2816 | }
|
---|
| 2817 | }
|
---|
| 2818 | onContextMenu(event) {
|
---|
| 2819 | if (this.isEnabled()) {
|
---|
| 2820 | this.dt.handleRowRightClick({
|
---|
| 2821 | originalEvent: event,
|
---|
| 2822 | rowData: this.data,
|
---|
| 2823 | rowIndex: this.index
|
---|
| 2824 | });
|
---|
| 2825 | this.el.nativeElement.focus();
|
---|
| 2826 | event.preventDefault();
|
---|
| 2827 | }
|
---|
| 2828 | }
|
---|
| 2829 | isEnabled() {
|
---|
| 2830 | return this.pContextMenuRowDisabled !== true;
|
---|
| 2831 | }
|
---|
| 2832 | ngOnDestroy() {
|
---|
| 2833 | if (this.subscription) {
|
---|
| 2834 | this.subscription.unsubscribe();
|
---|
| 2835 | }
|
---|
| 2836 | }
|
---|
| 2837 | }
|
---|
| 2838 | ContextMenuRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ContextMenuRow, deps: [{ token: Table }, { token: TableService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2839 | ContextMenuRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: ContextMenuRow, selector: "[pContextMenuRow]", inputs: { data: ["pContextMenuRow", "data"], index: ["pContextMenuRowIndex", "index"], pContextMenuRowDisabled: "pContextMenuRowDisabled" }, host: { listeners: { "contextmenu": "onContextMenu($event)" }, properties: { "class.p-highlight-contextmenu": "selected", "attr.tabindex": "isEnabled() ? 0 : undefined" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 2840 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ContextMenuRow, decorators: [{
|
---|
| 2841 | type: Directive,
|
---|
| 2842 | args: [{
|
---|
| 2843 | selector: '[pContextMenuRow]',
|
---|
| 2844 | host: {
|
---|
| 2845 | 'class': 'p-element',
|
---|
| 2846 | '[class.p-highlight-contextmenu]': 'selected',
|
---|
| 2847 | '[attr.tabindex]': 'isEnabled() ? 0 : undefined'
|
---|
| 2848 | }
|
---|
| 2849 | }]
|
---|
| 2850 | }], ctorParameters: function () { return [{ type: Table }, { type: TableService }, { type: i0.ElementRef }]; }, propDecorators: { data: [{
|
---|
| 2851 | type: Input,
|
---|
| 2852 | args: ["pContextMenuRow"]
|
---|
| 2853 | }], index: [{
|
---|
| 2854 | type: Input,
|
---|
| 2855 | args: ["pContextMenuRowIndex"]
|
---|
| 2856 | }], pContextMenuRowDisabled: [{
|
---|
| 2857 | type: Input
|
---|
| 2858 | }], onContextMenu: [{
|
---|
| 2859 | type: HostListener,
|
---|
| 2860 | args: ['contextmenu', ['$event']]
|
---|
| 2861 | }] } });
|
---|
| 2862 | class RowToggler {
|
---|
| 2863 | constructor(dt) {
|
---|
| 2864 | this.dt = dt;
|
---|
| 2865 | }
|
---|
| 2866 | onClick(event) {
|
---|
| 2867 | if (this.isEnabled()) {
|
---|
| 2868 | this.dt.toggleRow(this.data, event);
|
---|
| 2869 | event.preventDefault();
|
---|
| 2870 | }
|
---|
| 2871 | }
|
---|
| 2872 | isEnabled() {
|
---|
| 2873 | return this.pRowTogglerDisabled !== true;
|
---|
| 2874 | }
|
---|
| 2875 | }
|
---|
| 2876 | RowToggler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RowToggler, deps: [{ token: Table }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2877 | RowToggler.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: RowToggler, selector: "[pRowToggler]", inputs: { data: ["pRowToggler", "data"], pRowTogglerDisabled: "pRowTogglerDisabled" }, host: { listeners: { "click": "onClick($event)" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 2878 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RowToggler, decorators: [{
|
---|
| 2879 | type: Directive,
|
---|
| 2880 | args: [{
|
---|
| 2881 | selector: '[pRowToggler]',
|
---|
| 2882 | host: {
|
---|
| 2883 | 'class': 'p-element'
|
---|
| 2884 | }
|
---|
| 2885 | }]
|
---|
| 2886 | }], ctorParameters: function () { return [{ type: Table }]; }, propDecorators: { data: [{
|
---|
| 2887 | type: Input,
|
---|
| 2888 | args: ['pRowToggler']
|
---|
| 2889 | }], pRowTogglerDisabled: [{
|
---|
| 2890 | type: Input
|
---|
| 2891 | }], onClick: [{
|
---|
| 2892 | type: HostListener,
|
---|
| 2893 | args: ['click', ['$event']]
|
---|
| 2894 | }] } });
|
---|
| 2895 | class ResizableColumn {
|
---|
| 2896 | constructor(dt, el, zone) {
|
---|
| 2897 | this.dt = dt;
|
---|
| 2898 | this.el = el;
|
---|
| 2899 | this.zone = zone;
|
---|
| 2900 | }
|
---|
| 2901 | ngAfterViewInit() {
|
---|
| 2902 | if (this.isEnabled()) {
|
---|
| 2903 | DomHandler.addClass(this.el.nativeElement, 'p-resizable-column');
|
---|
| 2904 | this.resizer = document.createElement('span');
|
---|
| 2905 | this.resizer.className = 'p-column-resizer';
|
---|
| 2906 | this.el.nativeElement.appendChild(this.resizer);
|
---|
| 2907 | this.zone.runOutsideAngular(() => {
|
---|
| 2908 | this.resizerMouseDownListener = this.onMouseDown.bind(this);
|
---|
| 2909 | this.resizer.addEventListener('mousedown', this.resizerMouseDownListener);
|
---|
| 2910 | });
|
---|
| 2911 | }
|
---|
| 2912 | }
|
---|
| 2913 | bindDocumentEvents() {
|
---|
| 2914 | this.zone.runOutsideAngular(() => {
|
---|
| 2915 | this.documentMouseMoveListener = this.onDocumentMouseMove.bind(this);
|
---|
| 2916 | document.addEventListener('mousemove', this.documentMouseMoveListener);
|
---|
| 2917 | this.documentMouseUpListener = this.onDocumentMouseUp.bind(this);
|
---|
| 2918 | document.addEventListener('mouseup', this.documentMouseUpListener);
|
---|
| 2919 | });
|
---|
| 2920 | }
|
---|
| 2921 | unbindDocumentEvents() {
|
---|
| 2922 | if (this.documentMouseMoveListener) {
|
---|
| 2923 | document.removeEventListener('mousemove', this.documentMouseMoveListener);
|
---|
| 2924 | this.documentMouseMoveListener = null;
|
---|
| 2925 | }
|
---|
| 2926 | if (this.documentMouseUpListener) {
|
---|
| 2927 | document.removeEventListener('mouseup', this.documentMouseUpListener);
|
---|
| 2928 | this.documentMouseUpListener = null;
|
---|
| 2929 | }
|
---|
| 2930 | }
|
---|
| 2931 | onMouseDown(event) {
|
---|
| 2932 | if (event.which === 1) {
|
---|
| 2933 | this.dt.onColumnResizeBegin(event);
|
---|
| 2934 | this.bindDocumentEvents();
|
---|
| 2935 | }
|
---|
| 2936 | }
|
---|
| 2937 | onDocumentMouseMove(event) {
|
---|
| 2938 | this.dt.onColumnResize(event);
|
---|
| 2939 | }
|
---|
| 2940 | onDocumentMouseUp(event) {
|
---|
| 2941 | this.dt.onColumnResizeEnd();
|
---|
| 2942 | this.unbindDocumentEvents();
|
---|
| 2943 | }
|
---|
| 2944 | isEnabled() {
|
---|
| 2945 | return this.pResizableColumnDisabled !== true;
|
---|
| 2946 | }
|
---|
| 2947 | ngOnDestroy() {
|
---|
| 2948 | if (this.resizerMouseDownListener) {
|
---|
| 2949 | this.resizer.removeEventListener('mousedown', this.resizerMouseDownListener);
|
---|
| 2950 | }
|
---|
| 2951 | this.unbindDocumentEvents();
|
---|
| 2952 | }
|
---|
| 2953 | }
|
---|
| 2954 | ResizableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ResizableColumn, deps: [{ token: Table }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 2955 | ResizableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: ResizableColumn, selector: "[pResizableColumn]", inputs: { pResizableColumnDisabled: "pResizableColumnDisabled" }, host: { classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 2956 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ResizableColumn, decorators: [{
|
---|
| 2957 | type: Directive,
|
---|
| 2958 | args: [{
|
---|
| 2959 | selector: '[pResizableColumn]',
|
---|
| 2960 | host: {
|
---|
| 2961 | 'class': 'p-element'
|
---|
| 2962 | }
|
---|
| 2963 | }]
|
---|
| 2964 | }], ctorParameters: function () { return [{ type: Table }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { pResizableColumnDisabled: [{
|
---|
| 2965 | type: Input
|
---|
| 2966 | }] } });
|
---|
| 2967 | class ReorderableColumn {
|
---|
| 2968 | constructor(dt, el, zone) {
|
---|
| 2969 | this.dt = dt;
|
---|
| 2970 | this.el = el;
|
---|
| 2971 | this.zone = zone;
|
---|
| 2972 | }
|
---|
| 2973 | ngAfterViewInit() {
|
---|
| 2974 | if (this.isEnabled()) {
|
---|
| 2975 | this.bindEvents();
|
---|
| 2976 | }
|
---|
| 2977 | }
|
---|
| 2978 | bindEvents() {
|
---|
| 2979 | this.zone.runOutsideAngular(() => {
|
---|
| 2980 | this.mouseDownListener = this.onMouseDown.bind(this);
|
---|
| 2981 | this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);
|
---|
| 2982 | this.dragStartListener = this.onDragStart.bind(this);
|
---|
| 2983 | this.el.nativeElement.addEventListener('dragstart', this.dragStartListener);
|
---|
| 2984 | this.dragOverListener = this.onDragEnter.bind(this);
|
---|
| 2985 | this.el.nativeElement.addEventListener('dragover', this.dragOverListener);
|
---|
| 2986 | this.dragEnterListener = this.onDragEnter.bind(this);
|
---|
| 2987 | this.el.nativeElement.addEventListener('dragenter', this.dragEnterListener);
|
---|
| 2988 | this.dragLeaveListener = this.onDragLeave.bind(this);
|
---|
| 2989 | this.el.nativeElement.addEventListener('dragleave', this.dragLeaveListener);
|
---|
| 2990 | });
|
---|
| 2991 | }
|
---|
| 2992 | unbindEvents() {
|
---|
| 2993 | if (this.mouseDownListener) {
|
---|
| 2994 | document.removeEventListener('mousedown', this.mouseDownListener);
|
---|
| 2995 | this.mouseDownListener = null;
|
---|
| 2996 | }
|
---|
| 2997 | if (this.dragOverListener) {
|
---|
| 2998 | document.removeEventListener('dragover', this.dragOverListener);
|
---|
| 2999 | this.dragOverListener = null;
|
---|
| 3000 | }
|
---|
| 3001 | if (this.dragEnterListener) {
|
---|
| 3002 | document.removeEventListener('dragenter', this.dragEnterListener);
|
---|
| 3003 | this.dragEnterListener = null;
|
---|
| 3004 | }
|
---|
| 3005 | if (this.dragEnterListener) {
|
---|
| 3006 | document.removeEventListener('dragenter', this.dragEnterListener);
|
---|
| 3007 | this.dragEnterListener = null;
|
---|
| 3008 | }
|
---|
| 3009 | if (this.dragLeaveListener) {
|
---|
| 3010 | document.removeEventListener('dragleave', this.dragLeaveListener);
|
---|
| 3011 | this.dragLeaveListener = null;
|
---|
| 3012 | }
|
---|
| 3013 | }
|
---|
| 3014 | onMouseDown(event) {
|
---|
| 3015 | if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' || DomHandler.hasClass(event.target, 'p-column-resizer'))
|
---|
| 3016 | this.el.nativeElement.draggable = false;
|
---|
| 3017 | else
|
---|
| 3018 | this.el.nativeElement.draggable = true;
|
---|
| 3019 | }
|
---|
| 3020 | onDragStart(event) {
|
---|
| 3021 | this.dt.onColumnDragStart(event, this.el.nativeElement);
|
---|
| 3022 | }
|
---|
| 3023 | onDragOver(event) {
|
---|
| 3024 | event.preventDefault();
|
---|
| 3025 | }
|
---|
| 3026 | onDragEnter(event) {
|
---|
| 3027 | this.dt.onColumnDragEnter(event, this.el.nativeElement);
|
---|
| 3028 | }
|
---|
| 3029 | onDragLeave(event) {
|
---|
| 3030 | this.dt.onColumnDragLeave(event);
|
---|
| 3031 | }
|
---|
| 3032 | onDrop(event) {
|
---|
| 3033 | if (this.isEnabled()) {
|
---|
| 3034 | this.dt.onColumnDrop(event, this.el.nativeElement);
|
---|
| 3035 | }
|
---|
| 3036 | }
|
---|
| 3037 | isEnabled() {
|
---|
| 3038 | return this.pReorderableColumnDisabled !== true;
|
---|
| 3039 | }
|
---|
| 3040 | ngOnDestroy() {
|
---|
| 3041 | this.unbindEvents();
|
---|
| 3042 | }
|
---|
| 3043 | }
|
---|
| 3044 | ReorderableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ReorderableColumn, deps: [{ token: Table }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3045 | ReorderableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: ReorderableColumn, selector: "[pReorderableColumn]", inputs: { pReorderableColumnDisabled: "pReorderableColumnDisabled" }, host: { listeners: { "drop": "onDrop($event)" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3046 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ReorderableColumn, decorators: [{
|
---|
| 3047 | type: Directive,
|
---|
| 3048 | args: [{
|
---|
| 3049 | selector: '[pReorderableColumn]',
|
---|
| 3050 | host: {
|
---|
| 3051 | 'class': 'p-element'
|
---|
| 3052 | }
|
---|
| 3053 | }]
|
---|
| 3054 | }], ctorParameters: function () { return [{ type: Table }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { pReorderableColumnDisabled: [{
|
---|
| 3055 | type: Input
|
---|
| 3056 | }], onDrop: [{
|
---|
| 3057 | type: HostListener,
|
---|
| 3058 | args: ['drop', ['$event']]
|
---|
| 3059 | }] } });
|
---|
| 3060 | class EditableColumn {
|
---|
| 3061 | constructor(dt, el, zone) {
|
---|
| 3062 | this.dt = dt;
|
---|
| 3063 | this.el = el;
|
---|
| 3064 | this.zone = zone;
|
---|
| 3065 | }
|
---|
| 3066 | ngAfterViewInit() {
|
---|
| 3067 | if (this.isEnabled()) {
|
---|
| 3068 | DomHandler.addClass(this.el.nativeElement, 'p-editable-column');
|
---|
| 3069 | }
|
---|
| 3070 | }
|
---|
| 3071 | onClick(event) {
|
---|
| 3072 | if (this.isEnabled()) {
|
---|
| 3073 | this.dt.selfClick = true;
|
---|
| 3074 | if (this.dt.editingCell) {
|
---|
| 3075 | if (this.dt.editingCell !== this.el.nativeElement) {
|
---|
| 3076 | if (!this.dt.isEditingCellValid()) {
|
---|
| 3077 | return;
|
---|
| 3078 | }
|
---|
| 3079 | this.closeEditingCell(true, event);
|
---|
| 3080 | this.openCell();
|
---|
| 3081 | }
|
---|
| 3082 | }
|
---|
| 3083 | else {
|
---|
| 3084 | this.openCell();
|
---|
| 3085 | }
|
---|
| 3086 | }
|
---|
| 3087 | }
|
---|
| 3088 | openCell() {
|
---|
| 3089 | this.dt.updateEditingCell(this.el.nativeElement, this.data, this.field, this.rowIndex);
|
---|
| 3090 | DomHandler.addClass(this.el.nativeElement, 'p-cell-editing');
|
---|
| 3091 | this.dt.onEditInit.emit({ field: this.field, data: this.data, index: this.rowIndex });
|
---|
| 3092 | this.zone.runOutsideAngular(() => {
|
---|
| 3093 | setTimeout(() => {
|
---|
| 3094 | let focusCellSelector = this.pFocusCellSelector || 'input, textarea, select';
|
---|
| 3095 | let focusableElement = DomHandler.findSingle(this.el.nativeElement, focusCellSelector);
|
---|
| 3096 | if (focusableElement) {
|
---|
| 3097 | focusableElement.focus();
|
---|
| 3098 | }
|
---|
| 3099 | }, 50);
|
---|
| 3100 | });
|
---|
| 3101 | this.overlayEventListener = (e) => {
|
---|
| 3102 | if (this.el && this.el.nativeElement.contains(e.target)) {
|
---|
| 3103 | this.dt.selfClick = true;
|
---|
| 3104 | }
|
---|
| 3105 | };
|
---|
| 3106 | this.dt.overlaySubscription = this.dt.overlayService.clickObservable.subscribe(this.overlayEventListener);
|
---|
| 3107 | }
|
---|
| 3108 | closeEditingCell(completed, event) {
|
---|
| 3109 | if (completed)
|
---|
| 3110 | this.dt.onEditComplete.emit({ field: this.dt.editingCellField, data: this.dt.editingCellData, originalEvent: event, index: this.dt.editingCellRowIndex });
|
---|
| 3111 | else
|
---|
| 3112 | this.dt.onEditCancel.emit({ field: this.dt.editingCellField, data: this.dt.editingCellData, originalEvent: event, index: this.dt.editingCellRowIndex });
|
---|
| 3113 | DomHandler.removeClass(this.dt.editingCell, 'p-cell-editing');
|
---|
| 3114 | this.dt.editingCell = null;
|
---|
| 3115 | this.dt.editingCellData = null;
|
---|
| 3116 | this.dt.editingCellField = null;
|
---|
| 3117 | this.dt.unbindDocumentEditListener();
|
---|
| 3118 | if (this.dt.overlaySubscription) {
|
---|
| 3119 | this.dt.overlaySubscription.unsubscribe();
|
---|
| 3120 | }
|
---|
| 3121 | }
|
---|
| 3122 | onEnterKeyDown(event) {
|
---|
| 3123 | if (this.isEnabled()) {
|
---|
| 3124 | if (this.dt.isEditingCellValid()) {
|
---|
| 3125 | this.closeEditingCell(true, event);
|
---|
| 3126 | }
|
---|
| 3127 | event.preventDefault();
|
---|
| 3128 | }
|
---|
| 3129 | }
|
---|
| 3130 | onEscapeKeyDown(event) {
|
---|
| 3131 | if (this.isEnabled()) {
|
---|
| 3132 | if (this.dt.isEditingCellValid()) {
|
---|
| 3133 | this.closeEditingCell(false, event);
|
---|
| 3134 | }
|
---|
| 3135 | event.preventDefault();
|
---|
| 3136 | }
|
---|
| 3137 | }
|
---|
| 3138 | onShiftKeyDown(event) {
|
---|
| 3139 | if (this.isEnabled()) {
|
---|
| 3140 | if (event.shiftKey)
|
---|
| 3141 | this.moveToPreviousCell(event);
|
---|
| 3142 | else {
|
---|
| 3143 | this.moveToNextCell(event);
|
---|
| 3144 | }
|
---|
| 3145 | }
|
---|
| 3146 | }
|
---|
| 3147 | onArrowDown(event) {
|
---|
| 3148 | if (this.isEnabled()) {
|
---|
| 3149 | let currentCell = this.findCell(event.target);
|
---|
| 3150 | if (currentCell) {
|
---|
| 3151 | let cellIndex = DomHandler.index(currentCell);
|
---|
| 3152 | let targetCell = this.findNextEditableColumnByIndex(currentCell, cellIndex);
|
---|
| 3153 | if (targetCell) {
|
---|
| 3154 | if (this.dt.isEditingCellValid()) {
|
---|
| 3155 | this.closeEditingCell(true, event);
|
---|
| 3156 | }
|
---|
| 3157 | DomHandler.invokeElementMethod(event.target, 'blur');
|
---|
| 3158 | DomHandler.invokeElementMethod(targetCell, 'click');
|
---|
| 3159 | }
|
---|
| 3160 | event.preventDefault();
|
---|
| 3161 | }
|
---|
| 3162 | }
|
---|
| 3163 | }
|
---|
| 3164 | onArrowUp(event) {
|
---|
| 3165 | if (this.isEnabled()) {
|
---|
| 3166 | let currentCell = this.findCell(event.target);
|
---|
| 3167 | if (currentCell) {
|
---|
| 3168 | let cellIndex = DomHandler.index(currentCell);
|
---|
| 3169 | let targetCell = this.findPrevEditableColumnByIndex(currentCell, cellIndex);
|
---|
| 3170 | if (targetCell) {
|
---|
| 3171 | if (this.dt.isEditingCellValid()) {
|
---|
| 3172 | this.closeEditingCell(true, event);
|
---|
| 3173 | }
|
---|
| 3174 | DomHandler.invokeElementMethod(event.target, 'blur');
|
---|
| 3175 | DomHandler.invokeElementMethod(targetCell, 'click');
|
---|
| 3176 | }
|
---|
| 3177 | event.preventDefault();
|
---|
| 3178 | }
|
---|
| 3179 | }
|
---|
| 3180 | }
|
---|
| 3181 | onArrowLeft(event) {
|
---|
| 3182 | if (this.isEnabled()) {
|
---|
| 3183 | this.moveToPreviousCell(event);
|
---|
| 3184 | }
|
---|
| 3185 | }
|
---|
| 3186 | onArrowRight(event) {
|
---|
| 3187 | if (this.isEnabled()) {
|
---|
| 3188 | this.moveToNextCell(event);
|
---|
| 3189 | }
|
---|
| 3190 | }
|
---|
| 3191 | findCell(element) {
|
---|
| 3192 | if (element) {
|
---|
| 3193 | let cell = element;
|
---|
| 3194 | while (cell && !DomHandler.hasClass(cell, 'p-cell-editing')) {
|
---|
| 3195 | cell = cell.parentElement;
|
---|
| 3196 | }
|
---|
| 3197 | return cell;
|
---|
| 3198 | }
|
---|
| 3199 | else {
|
---|
| 3200 | return null;
|
---|
| 3201 | }
|
---|
| 3202 | }
|
---|
| 3203 | moveToPreviousCell(event) {
|
---|
| 3204 | let currentCell = this.findCell(event.target);
|
---|
| 3205 | if (currentCell) {
|
---|
| 3206 | let targetCell = this.findPreviousEditableColumn(currentCell);
|
---|
| 3207 | if (targetCell) {
|
---|
| 3208 | if (this.dt.isEditingCellValid()) {
|
---|
| 3209 | this.closeEditingCell(true, event);
|
---|
| 3210 | }
|
---|
| 3211 | DomHandler.invokeElementMethod(event.target, 'blur');
|
---|
| 3212 | DomHandler.invokeElementMethod(targetCell, 'click');
|
---|
| 3213 | event.preventDefault();
|
---|
| 3214 | }
|
---|
| 3215 | }
|
---|
| 3216 | }
|
---|
| 3217 | moveToNextCell(event) {
|
---|
| 3218 | let currentCell = this.findCell(event.target);
|
---|
| 3219 | if (currentCell) {
|
---|
| 3220 | let targetCell = this.findNextEditableColumn(currentCell);
|
---|
| 3221 | if (targetCell) {
|
---|
| 3222 | if (this.dt.isEditingCellValid()) {
|
---|
| 3223 | this.closeEditingCell(true, event);
|
---|
| 3224 | }
|
---|
| 3225 | DomHandler.invokeElementMethod(event.target, 'blur');
|
---|
| 3226 | DomHandler.invokeElementMethod(targetCell, 'click');
|
---|
| 3227 | event.preventDefault();
|
---|
| 3228 | }
|
---|
| 3229 | }
|
---|
| 3230 | }
|
---|
| 3231 | findPreviousEditableColumn(cell) {
|
---|
| 3232 | let prevCell = cell.previousElementSibling;
|
---|
| 3233 | if (!prevCell) {
|
---|
| 3234 | let previousRow = cell.parentElement.previousElementSibling;
|
---|
| 3235 | if (previousRow) {
|
---|
| 3236 | prevCell = previousRow.lastElementChild;
|
---|
| 3237 | }
|
---|
| 3238 | }
|
---|
| 3239 | if (prevCell) {
|
---|
| 3240 | if (DomHandler.hasClass(prevCell, 'p-editable-column'))
|
---|
| 3241 | return prevCell;
|
---|
| 3242 | else
|
---|
| 3243 | return this.findPreviousEditableColumn(prevCell);
|
---|
| 3244 | }
|
---|
| 3245 | else {
|
---|
| 3246 | return null;
|
---|
| 3247 | }
|
---|
| 3248 | }
|
---|
| 3249 | findNextEditableColumn(cell) {
|
---|
| 3250 | let nextCell = cell.nextElementSibling;
|
---|
| 3251 | if (!nextCell) {
|
---|
| 3252 | let nextRow = cell.parentElement.nextElementSibling;
|
---|
| 3253 | if (nextRow) {
|
---|
| 3254 | nextCell = nextRow.firstElementChild;
|
---|
| 3255 | }
|
---|
| 3256 | }
|
---|
| 3257 | if (nextCell) {
|
---|
| 3258 | if (DomHandler.hasClass(nextCell, 'p-editable-column'))
|
---|
| 3259 | return nextCell;
|
---|
| 3260 | else
|
---|
| 3261 | return this.findNextEditableColumn(nextCell);
|
---|
| 3262 | }
|
---|
| 3263 | else {
|
---|
| 3264 | return null;
|
---|
| 3265 | }
|
---|
| 3266 | }
|
---|
| 3267 | findNextEditableColumnByIndex(cell, index) {
|
---|
| 3268 | let nextRow = cell.parentElement.nextElementSibling;
|
---|
| 3269 | if (nextRow) {
|
---|
| 3270 | let nextCell = nextRow.children[index];
|
---|
| 3271 | if (nextCell && DomHandler.hasClass(nextCell, 'p-editable-column')) {
|
---|
| 3272 | return nextCell;
|
---|
| 3273 | }
|
---|
| 3274 | return null;
|
---|
| 3275 | }
|
---|
| 3276 | else {
|
---|
| 3277 | return null;
|
---|
| 3278 | }
|
---|
| 3279 | }
|
---|
| 3280 | findPrevEditableColumnByIndex(cell, index) {
|
---|
| 3281 | let prevRow = cell.parentElement.previousElementSibling;
|
---|
| 3282 | if (prevRow) {
|
---|
| 3283 | let prevCell = prevRow.children[index];
|
---|
| 3284 | if (prevCell && DomHandler.hasClass(prevCell, 'p-editable-column')) {
|
---|
| 3285 | return prevCell;
|
---|
| 3286 | }
|
---|
| 3287 | return null;
|
---|
| 3288 | }
|
---|
| 3289 | else {
|
---|
| 3290 | return null;
|
---|
| 3291 | }
|
---|
| 3292 | }
|
---|
| 3293 | isEnabled() {
|
---|
| 3294 | return this.pEditableColumnDisabled !== true;
|
---|
| 3295 | }
|
---|
| 3296 | ngOnDestroy() {
|
---|
| 3297 | if (this.dt.overlaySubscription) {
|
---|
| 3298 | this.dt.overlaySubscription.unsubscribe();
|
---|
| 3299 | }
|
---|
| 3300 | }
|
---|
| 3301 | }
|
---|
| 3302 | EditableColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableColumn, deps: [{ token: Table }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3303 | EditableColumn.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: EditableColumn, selector: "[pEditableColumn]", inputs: { data: ["pEditableColumn", "data"], field: ["pEditableColumnField", "field"], rowIndex: ["pEditableColumnRowIndex", "rowIndex"], pEditableColumnDisabled: "pEditableColumnDisabled", pFocusCellSelector: "pFocusCellSelector" }, host: { listeners: { "click": "onClick($event)", "keydown.enter": "onEnterKeyDown($event)", "keydown.escape": "onEscapeKeyDown($event)", "keydown.tab": "onShiftKeyDown($event)", "keydown.shift.tab": "onShiftKeyDown($event)", "keydown.meta.tab": "onShiftKeyDown($event)", "keydown.arrowdown": "onArrowDown($event)", "keydown.arrowup": "onArrowUp($event)", "keydown.arrowleft": "onArrowLeft($event)", "keydown.arrowright": "onArrowRight($event)" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3304 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableColumn, decorators: [{
|
---|
| 3305 | type: Directive,
|
---|
| 3306 | args: [{
|
---|
| 3307 | selector: '[pEditableColumn]',
|
---|
| 3308 | host: {
|
---|
| 3309 | 'class': 'p-element'
|
---|
| 3310 | }
|
---|
| 3311 | }]
|
---|
| 3312 | }], ctorParameters: function () { return [{ type: Table }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { data: [{
|
---|
| 3313 | type: Input,
|
---|
| 3314 | args: ["pEditableColumn"]
|
---|
| 3315 | }], field: [{
|
---|
| 3316 | type: Input,
|
---|
| 3317 | args: ["pEditableColumnField"]
|
---|
| 3318 | }], rowIndex: [{
|
---|
| 3319 | type: Input,
|
---|
| 3320 | args: ["pEditableColumnRowIndex"]
|
---|
| 3321 | }], pEditableColumnDisabled: [{
|
---|
| 3322 | type: Input
|
---|
| 3323 | }], pFocusCellSelector: [{
|
---|
| 3324 | type: Input
|
---|
| 3325 | }], onClick: [{
|
---|
| 3326 | type: HostListener,
|
---|
| 3327 | args: ['click', ['$event']]
|
---|
| 3328 | }], onEnterKeyDown: [{
|
---|
| 3329 | type: HostListener,
|
---|
| 3330 | args: ['keydown.enter', ['$event']]
|
---|
| 3331 | }], onEscapeKeyDown: [{
|
---|
| 3332 | type: HostListener,
|
---|
| 3333 | args: ['keydown.escape', ['$event']]
|
---|
| 3334 | }], onShiftKeyDown: [{
|
---|
| 3335 | type: HostListener,
|
---|
| 3336 | args: ['keydown.tab', ['$event']]
|
---|
| 3337 | }, {
|
---|
| 3338 | type: HostListener,
|
---|
| 3339 | args: ['keydown.shift.tab', ['$event']]
|
---|
| 3340 | }, {
|
---|
| 3341 | type: HostListener,
|
---|
| 3342 | args: ['keydown.meta.tab', ['$event']]
|
---|
| 3343 | }], onArrowDown: [{
|
---|
| 3344 | type: HostListener,
|
---|
| 3345 | args: ['keydown.arrowdown', ['$event']]
|
---|
| 3346 | }], onArrowUp: [{
|
---|
| 3347 | type: HostListener,
|
---|
| 3348 | args: ['keydown.arrowup', ['$event']]
|
---|
| 3349 | }], onArrowLeft: [{
|
---|
| 3350 | type: HostListener,
|
---|
| 3351 | args: ['keydown.arrowleft', ['$event']]
|
---|
| 3352 | }], onArrowRight: [{
|
---|
| 3353 | type: HostListener,
|
---|
| 3354 | args: ['keydown.arrowright', ['$event']]
|
---|
| 3355 | }] } });
|
---|
| 3356 | class EditableRow {
|
---|
| 3357 | constructor(el) {
|
---|
| 3358 | this.el = el;
|
---|
| 3359 | }
|
---|
| 3360 | isEnabled() {
|
---|
| 3361 | return this.pEditableRowDisabled !== true;
|
---|
| 3362 | }
|
---|
| 3363 | }
|
---|
| 3364 | EditableRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableRow, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3365 | EditableRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: EditableRow, selector: "[pEditableRow]", inputs: { data: ["pEditableRow", "data"], pEditableRowDisabled: "pEditableRowDisabled" }, host: { classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3366 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableRow, decorators: [{
|
---|
| 3367 | type: Directive,
|
---|
| 3368 | args: [{
|
---|
| 3369 | selector: '[pEditableRow]',
|
---|
| 3370 | host: {
|
---|
| 3371 | 'class': 'p-element'
|
---|
| 3372 | }
|
---|
| 3373 | }]
|
---|
| 3374 | }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { data: [{
|
---|
| 3375 | type: Input,
|
---|
| 3376 | args: ["pEditableRow"]
|
---|
| 3377 | }], pEditableRowDisabled: [{
|
---|
| 3378 | type: Input
|
---|
| 3379 | }] } });
|
---|
| 3380 | class InitEditableRow {
|
---|
| 3381 | constructor(dt, editableRow) {
|
---|
| 3382 | this.dt = dt;
|
---|
| 3383 | this.editableRow = editableRow;
|
---|
| 3384 | }
|
---|
| 3385 | onClick(event) {
|
---|
| 3386 | this.dt.initRowEdit(this.editableRow.data);
|
---|
| 3387 | event.preventDefault();
|
---|
| 3388 | }
|
---|
| 3389 | }
|
---|
| 3390 | InitEditableRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InitEditableRow, deps: [{ token: Table }, { token: EditableRow }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3391 | InitEditableRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: InitEditableRow, selector: "[pInitEditableRow]", host: { listeners: { "click": "onClick($event)" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3392 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InitEditableRow, decorators: [{
|
---|
| 3393 | type: Directive,
|
---|
| 3394 | args: [{
|
---|
| 3395 | selector: '[pInitEditableRow]',
|
---|
| 3396 | host: {
|
---|
| 3397 | 'class': 'p-element'
|
---|
| 3398 | }
|
---|
| 3399 | }]
|
---|
| 3400 | }], ctorParameters: function () { return [{ type: Table }, { type: EditableRow }]; }, propDecorators: { onClick: [{
|
---|
| 3401 | type: HostListener,
|
---|
| 3402 | args: ['click', ['$event']]
|
---|
| 3403 | }] } });
|
---|
| 3404 | class SaveEditableRow {
|
---|
| 3405 | constructor(dt, editableRow) {
|
---|
| 3406 | this.dt = dt;
|
---|
| 3407 | this.editableRow = editableRow;
|
---|
| 3408 | }
|
---|
| 3409 | onClick(event) {
|
---|
| 3410 | this.dt.saveRowEdit(this.editableRow.data, this.editableRow.el.nativeElement);
|
---|
| 3411 | event.preventDefault();
|
---|
| 3412 | }
|
---|
| 3413 | }
|
---|
| 3414 | SaveEditableRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaveEditableRow, deps: [{ token: Table }, { token: EditableRow }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3415 | SaveEditableRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: SaveEditableRow, selector: "[pSaveEditableRow]", host: { listeners: { "click": "onClick($event)" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3416 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaveEditableRow, decorators: [{
|
---|
| 3417 | type: Directive,
|
---|
| 3418 | args: [{
|
---|
| 3419 | selector: '[pSaveEditableRow]',
|
---|
| 3420 | host: {
|
---|
| 3421 | 'class': 'p-element'
|
---|
| 3422 | }
|
---|
| 3423 | }]
|
---|
| 3424 | }], ctorParameters: function () { return [{ type: Table }, { type: EditableRow }]; }, propDecorators: { onClick: [{
|
---|
| 3425 | type: HostListener,
|
---|
| 3426 | args: ['click', ['$event']]
|
---|
| 3427 | }] } });
|
---|
| 3428 | class CancelEditableRow {
|
---|
| 3429 | constructor(dt, editableRow) {
|
---|
| 3430 | this.dt = dt;
|
---|
| 3431 | this.editableRow = editableRow;
|
---|
| 3432 | }
|
---|
| 3433 | onClick(event) {
|
---|
| 3434 | this.dt.cancelRowEdit(this.editableRow.data);
|
---|
| 3435 | event.preventDefault();
|
---|
| 3436 | }
|
---|
| 3437 | }
|
---|
| 3438 | CancelEditableRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CancelEditableRow, deps: [{ token: Table }, { token: EditableRow }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3439 | CancelEditableRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: CancelEditableRow, selector: "[pCancelEditableRow]", host: { listeners: { "click": "onClick($event)" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3440 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CancelEditableRow, decorators: [{
|
---|
| 3441 | type: Directive,
|
---|
| 3442 | args: [{
|
---|
| 3443 | selector: '[pCancelEditableRow]',
|
---|
| 3444 | host: {
|
---|
| 3445 | 'class': 'p-element'
|
---|
| 3446 | }
|
---|
| 3447 | }]
|
---|
| 3448 | }], ctorParameters: function () { return [{ type: Table }, { type: EditableRow }]; }, propDecorators: { onClick: [{
|
---|
| 3449 | type: HostListener,
|
---|
| 3450 | args: ['click', ['$event']]
|
---|
| 3451 | }] } });
|
---|
| 3452 | class CellEditor {
|
---|
| 3453 | constructor(dt, editableColumn, editableRow) {
|
---|
| 3454 | this.dt = dt;
|
---|
| 3455 | this.editableColumn = editableColumn;
|
---|
| 3456 | this.editableRow = editableRow;
|
---|
| 3457 | }
|
---|
| 3458 | ngAfterContentInit() {
|
---|
| 3459 | this.templates.forEach((item) => {
|
---|
| 3460 | switch (item.getType()) {
|
---|
| 3461 | case 'input':
|
---|
| 3462 | this.inputTemplate = item.template;
|
---|
| 3463 | break;
|
---|
| 3464 | case 'output':
|
---|
| 3465 | this.outputTemplate = item.template;
|
---|
| 3466 | break;
|
---|
| 3467 | }
|
---|
| 3468 | });
|
---|
| 3469 | }
|
---|
| 3470 | get editing() {
|
---|
| 3471 | return (this.dt.editingCell && this.editableColumn && this.dt.editingCell === this.editableColumn.el.nativeElement) ||
|
---|
| 3472 | (this.editableRow && this.dt.editMode === 'row' && this.dt.isRowEditing(this.editableRow.data));
|
---|
| 3473 | }
|
---|
| 3474 | }
|
---|
| 3475 | CellEditor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CellEditor, deps: [{ token: Table }, { token: EditableColumn, optional: true }, { token: EditableRow, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 3476 | CellEditor.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: CellEditor, selector: "p-cellEditor", host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `
|
---|
| 3477 | <ng-container *ngIf="editing">
|
---|
| 3478 | <ng-container *ngTemplateOutlet="inputTemplate"></ng-container>
|
---|
| 3479 | </ng-container>
|
---|
| 3480 | <ng-container *ngIf="!editing">
|
---|
| 3481 | <ng-container *ngTemplateOutlet="outputTemplate"></ng-container>
|
---|
| 3482 | </ng-container>
|
---|
| 3483 | `, isInline: true, directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], encapsulation: i0.ViewEncapsulation.None });
|
---|
| 3484 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CellEditor, decorators: [{
|
---|
| 3485 | type: Component,
|
---|
| 3486 | args: [{
|
---|
| 3487 | selector: 'p-cellEditor',
|
---|
| 3488 | template: `
|
---|
| 3489 | <ng-container *ngIf="editing">
|
---|
| 3490 | <ng-container *ngTemplateOutlet="inputTemplate"></ng-container>
|
---|
| 3491 | </ng-container>
|
---|
| 3492 | <ng-container *ngIf="!editing">
|
---|
| 3493 | <ng-container *ngTemplateOutlet="outputTemplate"></ng-container>
|
---|
| 3494 | </ng-container>
|
---|
| 3495 | `,
|
---|
| 3496 | encapsulation: ViewEncapsulation.None,
|
---|
| 3497 | host: {
|
---|
| 3498 | 'class': 'p-element'
|
---|
| 3499 | }
|
---|
| 3500 | }]
|
---|
| 3501 | }], ctorParameters: function () {
|
---|
| 3502 | return [{ type: Table }, { type: EditableColumn, decorators: [{
|
---|
| 3503 | type: Optional
|
---|
| 3504 | }] }, { type: EditableRow, decorators: [{
|
---|
| 3505 | type: Optional
|
---|
| 3506 | }] }];
|
---|
| 3507 | }, propDecorators: { templates: [{
|
---|
| 3508 | type: ContentChildren,
|
---|
| 3509 | args: [PrimeTemplate]
|
---|
| 3510 | }] } });
|
---|
| 3511 | class TableRadioButton {
|
---|
| 3512 | constructor(dt, tableService, cd) {
|
---|
| 3513 | this.dt = dt;
|
---|
| 3514 | this.tableService = tableService;
|
---|
| 3515 | this.cd = cd;
|
---|
| 3516 | this.subscription = this.dt.tableService.selectionSource$.subscribe(() => {
|
---|
| 3517 | this.checked = this.dt.isSelected(this.value);
|
---|
| 3518 | this.cd.markForCheck();
|
---|
| 3519 | });
|
---|
| 3520 | }
|
---|
| 3521 | ngOnInit() {
|
---|
| 3522 | this.checked = this.dt.isSelected(this.value);
|
---|
| 3523 | }
|
---|
| 3524 | onClick(event) {
|
---|
| 3525 | if (!this.disabled) {
|
---|
| 3526 | this.dt.toggleRowWithRadio({
|
---|
| 3527 | originalEvent: event,
|
---|
| 3528 | rowIndex: this.index
|
---|
| 3529 | }, this.value);
|
---|
| 3530 | }
|
---|
| 3531 | DomHandler.clearSelection();
|
---|
| 3532 | }
|
---|
| 3533 | onFocus() {
|
---|
| 3534 | DomHandler.addClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 3535 | }
|
---|
| 3536 | onBlur() {
|
---|
| 3537 | DomHandler.removeClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 3538 | }
|
---|
| 3539 | ngOnDestroy() {
|
---|
| 3540 | if (this.subscription) {
|
---|
| 3541 | this.subscription.unsubscribe();
|
---|
| 3542 | }
|
---|
| 3543 | }
|
---|
| 3544 | }
|
---|
| 3545 | TableRadioButton.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableRadioButton, deps: [{ token: Table }, { token: TableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 3546 | TableRadioButton.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TableRadioButton, selector: "p-tableRadioButton", inputs: { disabled: "disabled", value: "value", index: "index", inputId: "inputId", name: "name", ariaLabel: "ariaLabel" }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "boxViewChild", first: true, predicate: ["box"], descendants: true }], ngImport: i0, template: `
|
---|
| 3547 | <div class="p-radiobutton p-component" (click)="onClick($event)">
|
---|
| 3548 | <div class="p-hidden-accessible">
|
---|
| 3549 | <input type="radio" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()"
|
---|
| 3550 | [disabled]="disabled" [attr.aria-label]="ariaLabel">
|
---|
| 3551 | </div>
|
---|
| 3552 | <div #box [ngClass]="{'p-radiobutton-box p-component':true, 'p-highlight':checked, 'p-disabled':disabled}" role="radio" [attr.aria-checked]="checked">
|
---|
| 3553 | <div class="p-radiobutton-icon"></div>
|
---|
| 3554 | </div>
|
---|
| 3555 | </div>
|
---|
| 3556 | `, isInline: true, directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 3557 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableRadioButton, decorators: [{
|
---|
| 3558 | type: Component,
|
---|
| 3559 | args: [{
|
---|
| 3560 | selector: 'p-tableRadioButton',
|
---|
| 3561 | template: `
|
---|
| 3562 | <div class="p-radiobutton p-component" (click)="onClick($event)">
|
---|
| 3563 | <div class="p-hidden-accessible">
|
---|
| 3564 | <input type="radio" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()"
|
---|
| 3565 | [disabled]="disabled" [attr.aria-label]="ariaLabel">
|
---|
| 3566 | </div>
|
---|
| 3567 | <div #box [ngClass]="{'p-radiobutton-box p-component':true, 'p-highlight':checked, 'p-disabled':disabled}" role="radio" [attr.aria-checked]="checked">
|
---|
| 3568 | <div class="p-radiobutton-icon"></div>
|
---|
| 3569 | </div>
|
---|
| 3570 | </div>
|
---|
| 3571 | `,
|
---|
| 3572 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 3573 | encapsulation: ViewEncapsulation.None,
|
---|
| 3574 | host: {
|
---|
| 3575 | 'class': 'p-element'
|
---|
| 3576 | }
|
---|
| 3577 | }]
|
---|
| 3578 | }], ctorParameters: function () { return [{ type: Table }, { type: TableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { disabled: [{
|
---|
| 3579 | type: Input
|
---|
| 3580 | }], value: [{
|
---|
| 3581 | type: Input
|
---|
| 3582 | }], index: [{
|
---|
| 3583 | type: Input
|
---|
| 3584 | }], inputId: [{
|
---|
| 3585 | type: Input
|
---|
| 3586 | }], name: [{
|
---|
| 3587 | type: Input
|
---|
| 3588 | }], ariaLabel: [{
|
---|
| 3589 | type: Input
|
---|
| 3590 | }], boxViewChild: [{
|
---|
| 3591 | type: ViewChild,
|
---|
| 3592 | args: ['box']
|
---|
| 3593 | }] } });
|
---|
| 3594 | class TableCheckbox {
|
---|
| 3595 | constructor(dt, tableService, cd) {
|
---|
| 3596 | this.dt = dt;
|
---|
| 3597 | this.tableService = tableService;
|
---|
| 3598 | this.cd = cd;
|
---|
| 3599 | this.subscription = this.dt.tableService.selectionSource$.subscribe(() => {
|
---|
| 3600 | this.checked = this.dt.isSelected(this.value);
|
---|
| 3601 | this.cd.markForCheck();
|
---|
| 3602 | });
|
---|
| 3603 | }
|
---|
| 3604 | ngOnInit() {
|
---|
| 3605 | this.checked = this.dt.isSelected(this.value);
|
---|
| 3606 | }
|
---|
| 3607 | onClick(event) {
|
---|
| 3608 | if (!this.disabled) {
|
---|
| 3609 | this.dt.toggleRowWithCheckbox({
|
---|
| 3610 | originalEvent: event,
|
---|
| 3611 | rowIndex: this.index
|
---|
| 3612 | }, this.value);
|
---|
| 3613 | }
|
---|
| 3614 | DomHandler.clearSelection();
|
---|
| 3615 | }
|
---|
| 3616 | onFocus() {
|
---|
| 3617 | DomHandler.addClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 3618 | }
|
---|
| 3619 | onBlur() {
|
---|
| 3620 | DomHandler.removeClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 3621 | }
|
---|
| 3622 | ngOnDestroy() {
|
---|
| 3623 | if (this.subscription) {
|
---|
| 3624 | this.subscription.unsubscribe();
|
---|
| 3625 | }
|
---|
| 3626 | }
|
---|
| 3627 | }
|
---|
| 3628 | TableCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableCheckbox, deps: [{ token: Table }, { token: TableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 3629 | TableCheckbox.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TableCheckbox, selector: "p-tableCheckbox", inputs: { disabled: "disabled", value: "value", index: "index", inputId: "inputId", name: "name", required: "required", ariaLabel: "ariaLabel" }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "boxViewChild", first: true, predicate: ["box"], descendants: true }], ngImport: i0, template: `
|
---|
| 3630 | <div class="p-checkbox p-component" (click)="onClick($event)">
|
---|
| 3631 | <div class="p-hidden-accessible">
|
---|
| 3632 | <input type="checkbox" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="disabled"
|
---|
| 3633 | [attr.required]="required" [attr.aria-label]="ariaLabel">
|
---|
| 3634 | </div>
|
---|
| 3635 | <div #box [ngClass]="{'p-checkbox-box p-component':true,
|
---|
| 3636 | 'p-highlight':checked, 'p-disabled':disabled}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 3637 | <span class="p-checkbox-icon" [ngClass]="{'pi pi-check':checked}"></span>
|
---|
| 3638 | </div>
|
---|
| 3639 | </div>
|
---|
| 3640 | `, isInline: true, directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 3641 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableCheckbox, decorators: [{
|
---|
| 3642 | type: Component,
|
---|
| 3643 | args: [{
|
---|
| 3644 | selector: 'p-tableCheckbox',
|
---|
| 3645 | template: `
|
---|
| 3646 | <div class="p-checkbox p-component" (click)="onClick($event)">
|
---|
| 3647 | <div class="p-hidden-accessible">
|
---|
| 3648 | <input type="checkbox" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="disabled"
|
---|
| 3649 | [attr.required]="required" [attr.aria-label]="ariaLabel">
|
---|
| 3650 | </div>
|
---|
| 3651 | <div #box [ngClass]="{'p-checkbox-box p-component':true,
|
---|
| 3652 | 'p-highlight':checked, 'p-disabled':disabled}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 3653 | <span class="p-checkbox-icon" [ngClass]="{'pi pi-check':checked}"></span>
|
---|
| 3654 | </div>
|
---|
| 3655 | </div>
|
---|
| 3656 | `,
|
---|
| 3657 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 3658 | encapsulation: ViewEncapsulation.None,
|
---|
| 3659 | host: {
|
---|
| 3660 | 'class': 'p-element'
|
---|
| 3661 | }
|
---|
| 3662 | }]
|
---|
| 3663 | }], ctorParameters: function () { return [{ type: Table }, { type: TableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { disabled: [{
|
---|
| 3664 | type: Input
|
---|
| 3665 | }], value: [{
|
---|
| 3666 | type: Input
|
---|
| 3667 | }], index: [{
|
---|
| 3668 | type: Input
|
---|
| 3669 | }], inputId: [{
|
---|
| 3670 | type: Input
|
---|
| 3671 | }], name: [{
|
---|
| 3672 | type: Input
|
---|
| 3673 | }], required: [{
|
---|
| 3674 | type: Input
|
---|
| 3675 | }], ariaLabel: [{
|
---|
| 3676 | type: Input
|
---|
| 3677 | }], boxViewChild: [{
|
---|
| 3678 | type: ViewChild,
|
---|
| 3679 | args: ['box']
|
---|
| 3680 | }] } });
|
---|
| 3681 | class TableHeaderCheckbox {
|
---|
| 3682 | constructor(dt, tableService, cd) {
|
---|
| 3683 | this.dt = dt;
|
---|
| 3684 | this.tableService = tableService;
|
---|
| 3685 | this.cd = cd;
|
---|
| 3686 | this.valueChangeSubscription = this.dt.tableService.valueSource$.subscribe(() => {
|
---|
| 3687 | this.checked = this.updateCheckedState();
|
---|
| 3688 | });
|
---|
| 3689 | this.selectionChangeSubscription = this.dt.tableService.selectionSource$.subscribe(() => {
|
---|
| 3690 | this.checked = this.updateCheckedState();
|
---|
| 3691 | });
|
---|
| 3692 | }
|
---|
| 3693 | ngOnInit() {
|
---|
| 3694 | this.checked = this.updateCheckedState();
|
---|
| 3695 | }
|
---|
| 3696 | onClick(event) {
|
---|
| 3697 | if (!this.disabled) {
|
---|
| 3698 | if (this.dt.value && this.dt.value.length > 0) {
|
---|
| 3699 | this.dt.toggleRowsWithCheckbox(event, !this.checked);
|
---|
| 3700 | }
|
---|
| 3701 | }
|
---|
| 3702 | DomHandler.clearSelection();
|
---|
| 3703 | }
|
---|
| 3704 | onFocus() {
|
---|
| 3705 | DomHandler.addClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 3706 | }
|
---|
| 3707 | onBlur() {
|
---|
| 3708 | DomHandler.removeClass(this.boxViewChild.nativeElement, 'p-focus');
|
---|
| 3709 | }
|
---|
| 3710 | isDisabled() {
|
---|
| 3711 | return this.disabled || !this.dt.value || !this.dt.value.length;
|
---|
| 3712 | }
|
---|
| 3713 | ngOnDestroy() {
|
---|
| 3714 | if (this.selectionChangeSubscription) {
|
---|
| 3715 | this.selectionChangeSubscription.unsubscribe();
|
---|
| 3716 | }
|
---|
| 3717 | if (this.valueChangeSubscription) {
|
---|
| 3718 | this.valueChangeSubscription.unsubscribe();
|
---|
| 3719 | }
|
---|
| 3720 | }
|
---|
| 3721 | updateCheckedState() {
|
---|
| 3722 | this.cd.markForCheck();
|
---|
| 3723 | if (this.dt.filteredValue && !this.dt.lazy) {
|
---|
| 3724 | const val = this.dt.filteredValue;
|
---|
| 3725 | return (val && val.length > 0 && this.dt.selection && this.dt.selection.length > 0 && this.isAllFilteredValuesChecked());
|
---|
| 3726 | }
|
---|
| 3727 | else {
|
---|
| 3728 | const val = this.dt.value;
|
---|
| 3729 | const length = this.dt.lazy ? this.dt._totalRecords : val ? val.length : 0;
|
---|
| 3730 | return (val && length > 0 && this.dt.selection && this.dt.selection.length > 0 && this.dt.selection.length === length);
|
---|
| 3731 | }
|
---|
| 3732 | }
|
---|
| 3733 | isAllFilteredValuesChecked() {
|
---|
| 3734 | if (!this.dt.filteredValue) {
|
---|
| 3735 | return false;
|
---|
| 3736 | }
|
---|
| 3737 | else {
|
---|
| 3738 | for (let rowData of this.dt.filteredValue) {
|
---|
| 3739 | if (!this.dt.isSelected(rowData)) {
|
---|
| 3740 | return false;
|
---|
| 3741 | }
|
---|
| 3742 | }
|
---|
| 3743 | return true;
|
---|
| 3744 | }
|
---|
| 3745 | }
|
---|
| 3746 | }
|
---|
| 3747 | TableHeaderCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableHeaderCheckbox, deps: [{ token: Table }, { token: TableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 3748 | TableHeaderCheckbox.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: TableHeaderCheckbox, selector: "p-tableHeaderCheckbox", inputs: { disabled: "disabled", inputId: "inputId", name: "name", ariaLabel: "ariaLabel" }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "boxViewChild", first: true, predicate: ["box"], descendants: true }], ngImport: i0, template: `
|
---|
| 3749 | <div class="p-checkbox p-component" (click)="onClick($event)">
|
---|
| 3750 | <div class="p-hidden-accessible">
|
---|
| 3751 | <input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()"
|
---|
| 3752 | [disabled]="isDisabled()" [attr.aria-label]="ariaLabel">
|
---|
| 3753 | </div>
|
---|
| 3754 | <div #box [ngClass]="{'p-checkbox-box':true,
|
---|
| 3755 | 'p-highlight':checked, 'p-disabled': isDisabled()}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 3756 | <span class="p-checkbox-icon" [ngClass]="{'pi pi-check':checked}"></span>
|
---|
| 3757 | </div>
|
---|
| 3758 | </div>
|
---|
| 3759 | `, isInline: true, directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
| 3760 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableHeaderCheckbox, decorators: [{
|
---|
| 3761 | type: Component,
|
---|
| 3762 | args: [{
|
---|
| 3763 | selector: 'p-tableHeaderCheckbox',
|
---|
| 3764 | template: `
|
---|
| 3765 | <div class="p-checkbox p-component" (click)="onClick($event)">
|
---|
| 3766 | <div class="p-hidden-accessible">
|
---|
| 3767 | <input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()"
|
---|
| 3768 | [disabled]="isDisabled()" [attr.aria-label]="ariaLabel">
|
---|
| 3769 | </div>
|
---|
| 3770 | <div #box [ngClass]="{'p-checkbox-box':true,
|
---|
| 3771 | 'p-highlight':checked, 'p-disabled': isDisabled()}" role="checkbox" [attr.aria-checked]="checked">
|
---|
| 3772 | <span class="p-checkbox-icon" [ngClass]="{'pi pi-check':checked}"></span>
|
---|
| 3773 | </div>
|
---|
| 3774 | </div>
|
---|
| 3775 | `,
|
---|
| 3776 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 3777 | encapsulation: ViewEncapsulation.None,
|
---|
| 3778 | host: {
|
---|
| 3779 | 'class': 'p-element'
|
---|
| 3780 | }
|
---|
| 3781 | }]
|
---|
| 3782 | }], ctorParameters: function () { return [{ type: Table }, { type: TableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { boxViewChild: [{
|
---|
| 3783 | type: ViewChild,
|
---|
| 3784 | args: ['box']
|
---|
| 3785 | }], disabled: [{
|
---|
| 3786 | type: Input
|
---|
| 3787 | }], inputId: [{
|
---|
| 3788 | type: Input
|
---|
| 3789 | }], name: [{
|
---|
| 3790 | type: Input
|
---|
| 3791 | }], ariaLabel: [{
|
---|
| 3792 | type: Input
|
---|
| 3793 | }] } });
|
---|
| 3794 | class ReorderableRowHandle {
|
---|
| 3795 | constructor(el) {
|
---|
| 3796 | this.el = el;
|
---|
| 3797 | }
|
---|
| 3798 | ngAfterViewInit() {
|
---|
| 3799 | DomHandler.addClass(this.el.nativeElement, 'p-datatable-reorderablerow-handle');
|
---|
| 3800 | }
|
---|
| 3801 | }
|
---|
| 3802 | ReorderableRowHandle.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ReorderableRowHandle, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3803 | ReorderableRowHandle.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: ReorderableRowHandle, selector: "[pReorderableRowHandle]", inputs: { index: ["pReorderableRowHandle", "index"] }, host: { classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3804 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ReorderableRowHandle, decorators: [{
|
---|
| 3805 | type: Directive,
|
---|
| 3806 | args: [{
|
---|
| 3807 | selector: '[pReorderableRowHandle]',
|
---|
| 3808 | host: {
|
---|
| 3809 | 'class': 'p-element'
|
---|
| 3810 | }
|
---|
| 3811 | }]
|
---|
| 3812 | }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { index: [{
|
---|
| 3813 | type: Input,
|
---|
| 3814 | args: ["pReorderableRowHandle"]
|
---|
| 3815 | }] } });
|
---|
| 3816 | class ReorderableRow {
|
---|
| 3817 | constructor(dt, el, zone) {
|
---|
| 3818 | this.dt = dt;
|
---|
| 3819 | this.el = el;
|
---|
| 3820 | this.zone = zone;
|
---|
| 3821 | }
|
---|
| 3822 | ngAfterViewInit() {
|
---|
| 3823 | if (this.isEnabled()) {
|
---|
| 3824 | this.el.nativeElement.droppable = true;
|
---|
| 3825 | this.bindEvents();
|
---|
| 3826 | }
|
---|
| 3827 | }
|
---|
| 3828 | bindEvents() {
|
---|
| 3829 | this.zone.runOutsideAngular(() => {
|
---|
| 3830 | this.mouseDownListener = this.onMouseDown.bind(this);
|
---|
| 3831 | this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);
|
---|
| 3832 | this.dragStartListener = this.onDragStart.bind(this);
|
---|
| 3833 | this.el.nativeElement.addEventListener('dragstart', this.dragStartListener);
|
---|
| 3834 | this.dragEndListener = this.onDragEnd.bind(this);
|
---|
| 3835 | this.el.nativeElement.addEventListener('dragend', this.dragEndListener);
|
---|
| 3836 | this.dragOverListener = this.onDragOver.bind(this);
|
---|
| 3837 | this.el.nativeElement.addEventListener('dragover', this.dragOverListener);
|
---|
| 3838 | this.dragLeaveListener = this.onDragLeave.bind(this);
|
---|
| 3839 | this.el.nativeElement.addEventListener('dragleave', this.dragLeaveListener);
|
---|
| 3840 | });
|
---|
| 3841 | }
|
---|
| 3842 | unbindEvents() {
|
---|
| 3843 | if (this.mouseDownListener) {
|
---|
| 3844 | document.removeEventListener('mousedown', this.mouseDownListener);
|
---|
| 3845 | this.mouseDownListener = null;
|
---|
| 3846 | }
|
---|
| 3847 | if (this.dragStartListener) {
|
---|
| 3848 | document.removeEventListener('dragstart', this.dragStartListener);
|
---|
| 3849 | this.dragStartListener = null;
|
---|
| 3850 | }
|
---|
| 3851 | if (this.dragEndListener) {
|
---|
| 3852 | document.removeEventListener('dragend', this.dragEndListener);
|
---|
| 3853 | this.dragEndListener = null;
|
---|
| 3854 | }
|
---|
| 3855 | if (this.dragOverListener) {
|
---|
| 3856 | document.removeEventListener('dragover', this.dragOverListener);
|
---|
| 3857 | this.dragOverListener = null;
|
---|
| 3858 | }
|
---|
| 3859 | if (this.dragLeaveListener) {
|
---|
| 3860 | document.removeEventListener('dragleave', this.dragLeaveListener);
|
---|
| 3861 | this.dragLeaveListener = null;
|
---|
| 3862 | }
|
---|
| 3863 | }
|
---|
| 3864 | onMouseDown(event) {
|
---|
| 3865 | if (DomHandler.hasClass(event.target, 'p-datatable-reorderablerow-handle'))
|
---|
| 3866 | this.el.nativeElement.draggable = true;
|
---|
| 3867 | else
|
---|
| 3868 | this.el.nativeElement.draggable = false;
|
---|
| 3869 | }
|
---|
| 3870 | onDragStart(event) {
|
---|
| 3871 | this.dt.onRowDragStart(event, this.index);
|
---|
| 3872 | }
|
---|
| 3873 | onDragEnd(event) {
|
---|
| 3874 | this.dt.onRowDragEnd(event);
|
---|
| 3875 | this.el.nativeElement.draggable = false;
|
---|
| 3876 | }
|
---|
| 3877 | onDragOver(event) {
|
---|
| 3878 | this.dt.onRowDragOver(event, this.index, this.el.nativeElement);
|
---|
| 3879 | event.preventDefault();
|
---|
| 3880 | }
|
---|
| 3881 | onDragLeave(event) {
|
---|
| 3882 | this.dt.onRowDragLeave(event, this.el.nativeElement);
|
---|
| 3883 | }
|
---|
| 3884 | isEnabled() {
|
---|
| 3885 | return this.pReorderableRowDisabled !== true;
|
---|
| 3886 | }
|
---|
| 3887 | onDrop(event) {
|
---|
| 3888 | if (this.isEnabled() && this.dt.rowDragging) {
|
---|
| 3889 | this.dt.onRowDrop(event, this.el.nativeElement);
|
---|
| 3890 | }
|
---|
| 3891 | event.preventDefault();
|
---|
| 3892 | }
|
---|
| 3893 | }
|
---|
| 3894 | ReorderableRow.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ReorderableRow, deps: [{ token: Table }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
---|
| 3895 | ReorderableRow.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: ReorderableRow, selector: "[pReorderableRow]", inputs: { index: ["pReorderableRow", "index"], pReorderableRowDisabled: "pReorderableRowDisabled" }, host: { listeners: { "drop": "onDrop($event)" }, classAttribute: "p-element" }, ngImport: i0 });
|
---|
| 3896 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ReorderableRow, decorators: [{
|
---|
| 3897 | type: Directive,
|
---|
| 3898 | args: [{
|
---|
| 3899 | selector: '[pReorderableRow]',
|
---|
| 3900 | host: {
|
---|
| 3901 | 'class': 'p-element'
|
---|
| 3902 | }
|
---|
| 3903 | }]
|
---|
| 3904 | }], ctorParameters: function () { return [{ type: Table }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { index: [{
|
---|
| 3905 | type: Input,
|
---|
| 3906 | args: ["pReorderableRow"]
|
---|
| 3907 | }], pReorderableRowDisabled: [{
|
---|
| 3908 | type: Input
|
---|
| 3909 | }], onDrop: [{
|
---|
| 3910 | type: HostListener,
|
---|
| 3911 | args: ['drop', ['$event']]
|
---|
| 3912 | }] } });
|
---|
| 3913 | class ColumnFilterFormElement {
|
---|
| 3914 | constructor(dt) {
|
---|
| 3915 | this.dt = dt;
|
---|
| 3916 | this.useGrouping = true;
|
---|
| 3917 | }
|
---|
| 3918 | ngOnInit() {
|
---|
| 3919 | this.filterCallback = value => {
|
---|
| 3920 | this.filterConstraint.value = value;
|
---|
| 3921 | this.dt._filter();
|
---|
| 3922 | };
|
---|
| 3923 | }
|
---|
| 3924 | onModelChange(value) {
|
---|
| 3925 | this.filterConstraint.value = value;
|
---|
| 3926 | if (this.type === 'boolean' || value === '') {
|
---|
| 3927 | this.dt._filter();
|
---|
| 3928 | }
|
---|
| 3929 | }
|
---|
| 3930 | onTextInputEnterKeyDown(event) {
|
---|
| 3931 | this.dt._filter();
|
---|
| 3932 | event.preventDefault();
|
---|
| 3933 | }
|
---|
| 3934 | onNumericInputKeyDown(event) {
|
---|
| 3935 | if (event.key === 'Enter') {
|
---|
| 3936 | this.dt._filter();
|
---|
| 3937 | event.preventDefault();
|
---|
| 3938 | }
|
---|
| 3939 | }
|
---|
| 3940 | }
|
---|
| 3941 | ColumnFilterFormElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColumnFilterFormElement, deps: [{ token: Table }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 3942 | ColumnFilterFormElement.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: ColumnFilterFormElement, selector: "p-columnFilterFormElement", inputs: { field: "field", type: "type", filterConstraint: "filterConstraint", filterTemplate: "filterTemplate", placeholder: "placeholder", minFractionDigits: "minFractionDigits", maxFractionDigits: "maxFractionDigits", prefix: "prefix", suffix: "suffix", locale: "locale", localeMatcher: "localeMatcher", currency: "currency", currencyDisplay: "currencyDisplay", useGrouping: "useGrouping" }, host: { classAttribute: "p-element" }, ngImport: i0, template: `
|
---|
| 3943 | <ng-container *ngIf="filterTemplate; else builtInElement">
|
---|
| 3944 | <ng-container *ngTemplateOutlet="filterTemplate; context: {$implicit: filterConstraint.value, filterCallback: filterCallback}"></ng-container>
|
---|
| 3945 | </ng-container>
|
---|
| 3946 | <ng-template #builtInElement>
|
---|
| 3947 | <ng-container [ngSwitch]="type">
|
---|
| 3948 | <input *ngSwitchCase="'text'" type="text" pInputText [value]="filterConstraint?.value" (input)="onModelChange($event.target.value)"
|
---|
| 3949 | (keydown.enter)="onTextInputEnterKeyDown($event)" [attr.placeholder]="placeholder">
|
---|
| 3950 | <p-inputNumber *ngSwitchCase="'numeric'" [ngModel]="filterConstraint?.value" (ngModelChange)="onModelChange($event)" (onKeyDown)="onNumericInputKeyDown($event)" [showButtons]="true" [attr.placeholder]="placeholder"
|
---|
| 3951 | [minFractionDigits]="minFractionDigits" [maxFractionDigits]="maxFractionDigits" [prefix]="prefix" [suffix]="suffix" [placeholder]="placeholder"
|
---|
| 3952 | [mode]="currency ? 'currency' : 'decimal'" [locale]="locale" [localeMatcher]="localeMatcher" [currency]="currency" [currencyDisplay]="currencyDisplay" [useGrouping]="useGrouping"></p-inputNumber>
|
---|
| 3953 | <p-triStateCheckbox *ngSwitchCase="'boolean'" [ngModel]="filterConstraint?.value" (ngModelChange)="onModelChange($event)"></p-triStateCheckbox>
|
---|
| 3954 | <p-calendar *ngSwitchCase="'date'" [ngModel]="filterConstraint?.value" (ngModelChange)="onModelChange($event)"></p-calendar>
|
---|
| 3955 | </ng-container>
|
---|
| 3956 | </ng-template>
|
---|
| 3957 | `, isInline: true, components: [{ type: i5.InputNumber, selector: "p-inputNumber", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "style", "placeholder", "size", "maxlength", "tabindex", "title", "ariaLabel", "ariaRequired", "name", "required", "autocomplete", "min", "max", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "readonly", "step", "allowEmpty", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "inputStyle", "inputStyleClass", "disabled"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown"] }, { type: i6.TriStateCheckbox, selector: "p-triStateCheckbox", inputs: ["disabled", "name", "ariaLabelledBy", "tabindex", "inputId", "style", "styleClass", "label", "readonly", "checkboxTrueIcon", "checkboxFalseIcon"], outputs: ["onChange"] }, { type: i7.Calendar, selector: "p-calendar", inputs: ["style", "styleClass", "inputStyle", "inputId", "name", "inputStyleClass", "placeholder", "ariaLabelledBy", "iconAriaLabel", "disabled", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "icon", "appendTo", "readonlyInput", "shortYearCutoff", "monthNavigator", "yearNavigator", "hourFormat", "timeOnly", "stepHour", "stepMinute", "stepSecond", "showSeconds", "required", "showOnFocus", "showWeek", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "numberOfMonths", "view", "touchUI", "timeSeparator", "focusTrap", "firstDayOfWeek", "showTransitionOptions", "hideTransitionOptions", "tabindex", "defaultDate", "minDate", "maxDate", "disabledDates", "disabledDays", "yearRange", "showTime", "locale"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i4.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i4.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i8.InputText, selector: "[pInputText]" }, { type: i9.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i9.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], encapsulation: i0.ViewEncapsulation.None });
|
---|
| 3958 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColumnFilterFormElement, decorators: [{
|
---|
| 3959 | type: Component,
|
---|
| 3960 | args: [{
|
---|
| 3961 | selector: 'p-columnFilterFormElement',
|
---|
| 3962 | template: `
|
---|
| 3963 | <ng-container *ngIf="filterTemplate; else builtInElement">
|
---|
| 3964 | <ng-container *ngTemplateOutlet="filterTemplate; context: {$implicit: filterConstraint.value, filterCallback: filterCallback}"></ng-container>
|
---|
| 3965 | </ng-container>
|
---|
| 3966 | <ng-template #builtInElement>
|
---|
| 3967 | <ng-container [ngSwitch]="type">
|
---|
| 3968 | <input *ngSwitchCase="'text'" type="text" pInputText [value]="filterConstraint?.value" (input)="onModelChange($event.target.value)"
|
---|
| 3969 | (keydown.enter)="onTextInputEnterKeyDown($event)" [attr.placeholder]="placeholder">
|
---|
| 3970 | <p-inputNumber *ngSwitchCase="'numeric'" [ngModel]="filterConstraint?.value" (ngModelChange)="onModelChange($event)" (onKeyDown)="onNumericInputKeyDown($event)" [showButtons]="true" [attr.placeholder]="placeholder"
|
---|
| 3971 | [minFractionDigits]="minFractionDigits" [maxFractionDigits]="maxFractionDigits" [prefix]="prefix" [suffix]="suffix" [placeholder]="placeholder"
|
---|
| 3972 | [mode]="currency ? 'currency' : 'decimal'" [locale]="locale" [localeMatcher]="localeMatcher" [currency]="currency" [currencyDisplay]="currencyDisplay" [useGrouping]="useGrouping"></p-inputNumber>
|
---|
| 3973 | <p-triStateCheckbox *ngSwitchCase="'boolean'" [ngModel]="filterConstraint?.value" (ngModelChange)="onModelChange($event)"></p-triStateCheckbox>
|
---|
| 3974 | <p-calendar *ngSwitchCase="'date'" [ngModel]="filterConstraint?.value" (ngModelChange)="onModelChange($event)"></p-calendar>
|
---|
| 3975 | </ng-container>
|
---|
| 3976 | </ng-template>
|
---|
| 3977 | `,
|
---|
| 3978 | encapsulation: ViewEncapsulation.None,
|
---|
| 3979 | host: {
|
---|
| 3980 | 'class': 'p-element'
|
---|
| 3981 | }
|
---|
| 3982 | }]
|
---|
| 3983 | }], ctorParameters: function () { return [{ type: Table }]; }, propDecorators: { field: [{
|
---|
| 3984 | type: Input
|
---|
| 3985 | }], type: [{
|
---|
| 3986 | type: Input
|
---|
| 3987 | }], filterConstraint: [{
|
---|
| 3988 | type: Input
|
---|
| 3989 | }], filterTemplate: [{
|
---|
| 3990 | type: Input
|
---|
| 3991 | }], placeholder: [{
|
---|
| 3992 | type: Input
|
---|
| 3993 | }], minFractionDigits: [{
|
---|
| 3994 | type: Input
|
---|
| 3995 | }], maxFractionDigits: [{
|
---|
| 3996 | type: Input
|
---|
| 3997 | }], prefix: [{
|
---|
| 3998 | type: Input
|
---|
| 3999 | }], suffix: [{
|
---|
| 4000 | type: Input
|
---|
| 4001 | }], locale: [{
|
---|
| 4002 | type: Input
|
---|
| 4003 | }], localeMatcher: [{
|
---|
| 4004 | type: Input
|
---|
| 4005 | }], currency: [{
|
---|
| 4006 | type: Input
|
---|
| 4007 | }], currencyDisplay: [{
|
---|
| 4008 | type: Input
|
---|
| 4009 | }], useGrouping: [{
|
---|
| 4010 | type: Input
|
---|
| 4011 | }] } });
|
---|
| 4012 | class ColumnFilter {
|
---|
| 4013 | constructor(el, dt, renderer, config, overlayService) {
|
---|
| 4014 | this.el = el;
|
---|
| 4015 | this.dt = dt;
|
---|
| 4016 | this.renderer = renderer;
|
---|
| 4017 | this.config = config;
|
---|
| 4018 | this.overlayService = overlayService;
|
---|
| 4019 | this.type = 'text';
|
---|
| 4020 | this.display = 'row';
|
---|
| 4021 | this.showMenu = true;
|
---|
| 4022 | this.operator = FilterOperator.AND;
|
---|
| 4023 | this.showOperator = true;
|
---|
| 4024 | this.showClearButton = true;
|
---|
| 4025 | this.showApplyButton = true;
|
---|
| 4026 | this.showMatchModes = true;
|
---|
| 4027 | this.showAddButton = true;
|
---|
| 4028 | this.hideOnClear = false;
|
---|
| 4029 | this.maxConstraints = 2;
|
---|
| 4030 | this.useGrouping = true;
|
---|
| 4031 | }
|
---|
| 4032 | ngOnInit() {
|
---|
| 4033 | if (!this.dt.filters[this.field]) {
|
---|
| 4034 | this.initFieldFilterConstraint();
|
---|
| 4035 | }
|
---|
| 4036 | this.translationSubscription = this.config.translationObserver.subscribe(() => {
|
---|
| 4037 | this.generateMatchModeOptions();
|
---|
| 4038 | this.generateOperatorOptions();
|
---|
| 4039 | });
|
---|
| 4040 | this.resetSubscription = this.dt.tableService.resetSource$.subscribe(() => {
|
---|
| 4041 | this.clearFilter();
|
---|
| 4042 | });
|
---|
| 4043 | this.generateMatchModeOptions();
|
---|
| 4044 | this.generateOperatorOptions();
|
---|
| 4045 | }
|
---|
| 4046 | generateMatchModeOptions() {
|
---|
| 4047 | var _a;
|
---|
| 4048 | this.matchModes = this.matchModeOptions ||
|
---|
| 4049 | ((_a = this.config.filterMatchModeOptions[this.type]) === null || _a === void 0 ? void 0 : _a.map(key => {
|
---|
| 4050 | return { label: this.config.getTranslation(key), value: key };
|
---|
| 4051 | }));
|
---|
| 4052 | }
|
---|
| 4053 | generateOperatorOptions() {
|
---|
| 4054 | this.operatorOptions = [
|
---|
| 4055 | { label: this.config.getTranslation(TranslationKeys.MATCH_ALL), value: FilterOperator.AND },
|
---|
| 4056 | { label: this.config.getTranslation(TranslationKeys.MATCH_ANY), value: FilterOperator.OR }
|
---|
| 4057 | ];
|
---|
| 4058 | }
|
---|
| 4059 | ngAfterContentInit() {
|
---|
| 4060 | this.templates.forEach((item) => {
|
---|
| 4061 | switch (item.getType()) {
|
---|
| 4062 | case 'header':
|
---|
| 4063 | this.headerTemplate = item.template;
|
---|
| 4064 | break;
|
---|
| 4065 | case 'filter':
|
---|
| 4066 | this.filterTemplate = item.template;
|
---|
| 4067 | break;
|
---|
| 4068 | case 'footer':
|
---|
| 4069 | this.footerTemplate = item.template;
|
---|
| 4070 | break;
|
---|
| 4071 | default:
|
---|
| 4072 | this.filterTemplate = item.template;
|
---|
| 4073 | break;
|
---|
| 4074 | }
|
---|
| 4075 | });
|
---|
| 4076 | }
|
---|
| 4077 | initFieldFilterConstraint() {
|
---|
| 4078 | let defaultMatchMode = this.getDefaultMatchMode();
|
---|
| 4079 | this.dt.filters[this.field] = this.display == 'row' ? { value: null, matchMode: defaultMatchMode } : [{ value: null, matchMode: defaultMatchMode, operator: this.operator }];
|
---|
| 4080 | }
|
---|
| 4081 | onMenuMatchModeChange(value, filterMeta) {
|
---|
| 4082 | filterMeta.matchMode = value;
|
---|
| 4083 | if (!this.showApplyButton) {
|
---|
| 4084 | this.dt._filter();
|
---|
| 4085 | }
|
---|
| 4086 | }
|
---|
| 4087 | onRowMatchModeChange(matchMode) {
|
---|
| 4088 | this.dt.filters[this.field].matchMode = matchMode;
|
---|
| 4089 | this.dt._filter();
|
---|
| 4090 | this.hide();
|
---|
| 4091 | }
|
---|
| 4092 | onRowMatchModeKeyDown(event) {
|
---|
| 4093 | let item = event.target;
|
---|
| 4094 | switch (event.key) {
|
---|
| 4095 | case 'ArrowDown':
|
---|
| 4096 | var nextItem = this.findNextItem(item);
|
---|
| 4097 | if (nextItem) {
|
---|
| 4098 | item.removeAttribute('tabindex');
|
---|
| 4099 | nextItem.tabIndex = '0';
|
---|
| 4100 | nextItem.focus();
|
---|
| 4101 | }
|
---|
| 4102 | event.preventDefault();
|
---|
| 4103 | break;
|
---|
| 4104 | case 'ArrowUp':
|
---|
| 4105 | var prevItem = this.findPrevItem(item);
|
---|
| 4106 | if (prevItem) {
|
---|
| 4107 | item.removeAttribute('tabindex');
|
---|
| 4108 | prevItem.tabIndex = '0';
|
---|
| 4109 | prevItem.focus();
|
---|
| 4110 | }
|
---|
| 4111 | event.preventDefault();
|
---|
| 4112 | break;
|
---|
| 4113 | }
|
---|
| 4114 | }
|
---|
| 4115 | onRowClearItemClick() {
|
---|
| 4116 | this.clearFilter();
|
---|
| 4117 | this.hide();
|
---|
| 4118 | }
|
---|
| 4119 | isRowMatchModeSelected(matchMode) {
|
---|
| 4120 | return this.dt.filters[this.field].matchMode === matchMode;
|
---|
| 4121 | }
|
---|
| 4122 | addConstraint() {
|
---|
| 4123 | this.dt.filters[this.field].push({ value: null, matchMode: this.getDefaultMatchMode(), operator: this.getDefaultOperator() });
|
---|
| 4124 | this.dt._filter();
|
---|
| 4125 | }
|
---|
| 4126 | removeConstraint(filterMeta) {
|
---|
| 4127 | this.dt.filters[this.field] = this.dt.filters[this.field].filter(meta => meta !== filterMeta);
|
---|
| 4128 | this.dt._filter();
|
---|
| 4129 | }
|
---|
| 4130 | onOperatorChange(value) {
|
---|
| 4131 | this.dt.filters[this.field].forEach(filterMeta => {
|
---|
| 4132 | filterMeta.operator = value;
|
---|
| 4133 | this.operator = value;
|
---|
| 4134 | });
|
---|
| 4135 | if (!this.showApplyButton) {
|
---|
| 4136 | this.dt._filter();
|
---|
| 4137 | }
|
---|
| 4138 | }
|
---|
| 4139 | toggleMenu() {
|
---|
| 4140 | this.overlayVisible = !this.overlayVisible;
|
---|
| 4141 | }
|
---|
| 4142 | onToggleButtonKeyDown(event) {
|
---|
| 4143 | switch (event.key) {
|
---|
| 4144 | case 'Escape':
|
---|
| 4145 | case 'Tab':
|
---|
| 4146 | this.overlayVisible = false;
|
---|
| 4147 | break;
|
---|
| 4148 | case 'ArrowDown':
|
---|
| 4149 | if (this.overlayVisible) {
|
---|
| 4150 | let focusable = DomHandler.getFocusableElements(this.overlay);
|
---|
| 4151 | if (focusable) {
|
---|
| 4152 | focusable[0].focus();
|
---|
| 4153 | }
|
---|
| 4154 | event.preventDefault();
|
---|
| 4155 | }
|
---|
| 4156 | else if (event.altKey) {
|
---|
| 4157 | this.overlayVisible = true;
|
---|
| 4158 | event.preventDefault();
|
---|
| 4159 | }
|
---|
| 4160 | break;
|
---|
| 4161 | }
|
---|
| 4162 | }
|
---|
| 4163 | onEscape() {
|
---|
| 4164 | this.overlayVisible = false;
|
---|
| 4165 | this.icon.nativeElement.focus();
|
---|
| 4166 | }
|
---|
| 4167 | findNextItem(item) {
|
---|
| 4168 | let nextItem = item.nextElementSibling;
|
---|
| 4169 | if (nextItem)
|
---|
| 4170 | return DomHandler.hasClass(nextItem, 'p-column-filter-separator') ? this.findNextItem(nextItem) : nextItem;
|
---|
| 4171 | else
|
---|
| 4172 | return item.parentElement.firstElementChild;
|
---|
| 4173 | }
|
---|
| 4174 | findPrevItem(item) {
|
---|
| 4175 | let prevItem = item.previousElementSibling;
|
---|
| 4176 | if (prevItem)
|
---|
| 4177 | return DomHandler.hasClass(prevItem, 'p-column-filter-separator') ? this.findPrevItem(prevItem) : prevItem;
|
---|
| 4178 | else
|
---|
| 4179 | return item.parentElement.lastElementChild;
|
---|
| 4180 | }
|
---|
| 4181 | onContentClick() {
|
---|
| 4182 | this.selfClick = true;
|
---|
| 4183 | }
|
---|
| 4184 | onOverlayAnimationStart(event) {
|
---|
| 4185 | switch (event.toState) {
|
---|
| 4186 | case 'visible':
|
---|
| 4187 | this.overlay = event.element;
|
---|
| 4188 | document.body.appendChild(this.overlay);
|
---|
| 4189 | ZIndexUtils.set('overlay', this.overlay, this.config.zIndex.overlay);
|
---|
| 4190 | DomHandler.absolutePosition(this.overlay, this.icon.nativeElement);
|
---|
| 4191 | this.bindDocumentClickListener();
|
---|
| 4192 | this.bindDocumentResizeListener();
|
---|
| 4193 | this.bindScrollListener();
|
---|
| 4194 | this.overlayEventListener = (e) => {
|
---|
| 4195 | if (this.overlay && this.overlay.contains(e.target)) {
|
---|
| 4196 | this.selfClick = true;
|
---|
| 4197 | }
|
---|
| 4198 | };
|
---|
| 4199 | this.overlaySubscription = this.overlayService.clickObservable.subscribe(this.overlayEventListener);
|
---|
| 4200 | break;
|
---|
| 4201 | case 'void':
|
---|
| 4202 | this.onOverlayHide();
|
---|
| 4203 | if (this.overlaySubscription) {
|
---|
| 4204 | this.overlaySubscription.unsubscribe();
|
---|
| 4205 | }
|
---|
| 4206 | break;
|
---|
| 4207 | }
|
---|
| 4208 | }
|
---|
| 4209 | onOverlayAnimationEnd(event) {
|
---|
| 4210 | switch (event.toState) {
|
---|
| 4211 | case 'void':
|
---|
| 4212 | ZIndexUtils.clear(event.element);
|
---|
| 4213 | break;
|
---|
| 4214 | }
|
---|
| 4215 | }
|
---|
| 4216 | getDefaultMatchMode() {
|
---|
| 4217 | if (this.matchMode) {
|
---|
| 4218 | return this.matchMode;
|
---|
| 4219 | }
|
---|
| 4220 | else {
|
---|
| 4221 | if (this.type === 'text')
|
---|
| 4222 | return FilterMatchMode.STARTS_WITH;
|
---|
| 4223 | else if (this.type === 'numeric')
|
---|
| 4224 | return FilterMatchMode.EQUALS;
|
---|
| 4225 | else if (this.type === 'date')
|
---|
| 4226 | return FilterMatchMode.DATE_IS;
|
---|
| 4227 | else
|
---|
| 4228 | return FilterMatchMode.CONTAINS;
|
---|
| 4229 | }
|
---|
| 4230 | }
|
---|
| 4231 | getDefaultOperator() {
|
---|
| 4232 | return this.dt.filters ? this.dt.filters[this.field][0].operator : this.operator;
|
---|
| 4233 | }
|
---|
| 4234 | hasRowFilter() {
|
---|
| 4235 | return this.dt.filters[this.field] && !this.dt.isFilterBlank(this.dt.filters[this.field].value);
|
---|
| 4236 | }
|
---|
| 4237 | get fieldConstraints() {
|
---|
| 4238 | return this.dt.filters ? this.dt.filters[this.field] : null;
|
---|
| 4239 | }
|
---|
| 4240 | get showRemoveIcon() {
|
---|
| 4241 | return this.fieldConstraints ? this.fieldConstraints.length > 1 : false;
|
---|
| 4242 | }
|
---|
| 4243 | get showMenuButton() {
|
---|
| 4244 | return this.showMenu && (this.display === 'row' ? this.type !== 'boolean' : true);
|
---|
| 4245 | }
|
---|
| 4246 | get isShowOperator() {
|
---|
| 4247 | return this.showOperator && this.type !== 'boolean';
|
---|
| 4248 | }
|
---|
| 4249 | get isShowAddConstraint() {
|
---|
| 4250 | return this.showAddButton && this.type !== 'boolean' && (this.fieldConstraints && this.fieldConstraints.length < this.maxConstraints);
|
---|
| 4251 | }
|
---|
| 4252 | get applyButtonLabel() {
|
---|
| 4253 | return this.config.getTranslation(TranslationKeys.APPLY);
|
---|
| 4254 | }
|
---|
| 4255 | get clearButtonLabel() {
|
---|
| 4256 | return this.config.getTranslation(TranslationKeys.CLEAR);
|
---|
| 4257 | }
|
---|
| 4258 | get addRuleButtonLabel() {
|
---|
| 4259 | return this.config.getTranslation(TranslationKeys.ADD_RULE);
|
---|
| 4260 | }
|
---|
| 4261 | get removeRuleButtonLabel() {
|
---|
| 4262 | return this.config.getTranslation(TranslationKeys.REMOVE_RULE);
|
---|
| 4263 | }
|
---|
| 4264 | get noFilterLabel() {
|
---|
| 4265 | return this.config.getTranslation(TranslationKeys.NO_FILTER);
|
---|
| 4266 | }
|
---|
| 4267 | hasFilter() {
|
---|
| 4268 | let fieldFilter = this.dt.filters[this.field];
|
---|
| 4269 | if (fieldFilter) {
|
---|
| 4270 | if (Array.isArray(fieldFilter))
|
---|
| 4271 | return !this.dt.isFilterBlank(fieldFilter[0].value);
|
---|
| 4272 | else
|
---|
| 4273 | return !this.dt.isFilterBlank(fieldFilter.value);
|
---|
| 4274 | }
|
---|
| 4275 | return false;
|
---|
| 4276 | }
|
---|
| 4277 | isOutsideClicked(event) {
|
---|
| 4278 | return !(this.overlay.isSameNode(event.target) || this.overlay.contains(event.target)
|
---|
| 4279 | || this.icon.nativeElement.isSameNode(event.target) || this.icon.nativeElement.contains(event.target)
|
---|
| 4280 | || DomHandler.hasClass(event.target, 'p-column-filter-add-button') || DomHandler.hasClass(event.target.parentElement, 'p-column-filter-add-button')
|
---|
| 4281 | || DomHandler.hasClass(event.target, 'p-column-filter-remove-button') || DomHandler.hasClass(event.target.parentElement, 'p-column-filter-remove-button'));
|
---|
| 4282 | }
|
---|
| 4283 | bindDocumentClickListener() {
|
---|
| 4284 | if (!this.documentClickListener) {
|
---|
| 4285 | const documentTarget = this.el ? this.el.nativeElement.ownerDocument : 'document';
|
---|
| 4286 | this.documentClickListener = this.renderer.listen(documentTarget, 'mousedown', event => {
|
---|
| 4287 | if (this.overlayVisible && !this.selfClick && this.isOutsideClicked(event)) {
|
---|
| 4288 | this.hide();
|
---|
| 4289 | }
|
---|
| 4290 | this.selfClick = false;
|
---|
| 4291 | });
|
---|
| 4292 | }
|
---|
| 4293 | }
|
---|
| 4294 | unbindDocumentClickListener() {
|
---|
| 4295 | if (this.documentClickListener) {
|
---|
| 4296 | this.documentClickListener();
|
---|
| 4297 | this.documentClickListener = null;
|
---|
| 4298 | this.selfClick = false;
|
---|
| 4299 | }
|
---|
| 4300 | }
|
---|
| 4301 | bindDocumentResizeListener() {
|
---|
| 4302 | this.documentResizeListener = () => this.hide();
|
---|
| 4303 | window.addEventListener('resize', this.documentResizeListener);
|
---|
| 4304 | }
|
---|
| 4305 | unbindDocumentResizeListener() {
|
---|
| 4306 | if (this.documentResizeListener) {
|
---|
| 4307 | window.removeEventListener('resize', this.documentResizeListener);
|
---|
| 4308 | this.documentResizeListener = null;
|
---|
| 4309 | }
|
---|
| 4310 | }
|
---|
| 4311 | bindScrollListener() {
|
---|
| 4312 | if (!this.scrollHandler) {
|
---|
| 4313 | this.scrollHandler = new ConnectedOverlayScrollHandler(this.icon.nativeElement, () => {
|
---|
| 4314 | if (this.overlayVisible) {
|
---|
| 4315 | this.hide();
|
---|
| 4316 | }
|
---|
| 4317 | });
|
---|
| 4318 | }
|
---|
| 4319 | this.scrollHandler.bindScrollListener();
|
---|
| 4320 | }
|
---|
| 4321 | unbindScrollListener() {
|
---|
| 4322 | if (this.scrollHandler) {
|
---|
| 4323 | this.scrollHandler.unbindScrollListener();
|
---|
| 4324 | }
|
---|
| 4325 | }
|
---|
| 4326 | hide() {
|
---|
| 4327 | this.overlayVisible = false;
|
---|
| 4328 | }
|
---|
| 4329 | onOverlayHide() {
|
---|
| 4330 | this.unbindDocumentClickListener();
|
---|
| 4331 | this.unbindDocumentResizeListener();
|
---|
| 4332 | this.unbindScrollListener();
|
---|
| 4333 | this.overlay = null;
|
---|
| 4334 | }
|
---|
| 4335 | clearFilter() {
|
---|
| 4336 | this.initFieldFilterConstraint();
|
---|
| 4337 | this.dt._filter();
|
---|
| 4338 | if (this.hideOnClear)
|
---|
| 4339 | this.hide();
|
---|
| 4340 | }
|
---|
| 4341 | applyFilter() {
|
---|
| 4342 | this.dt._filter();
|
---|
| 4343 | this.hide();
|
---|
| 4344 | }
|
---|
| 4345 | ngOnDestroy() {
|
---|
| 4346 | if (this.overlay) {
|
---|
| 4347 | this.el.nativeElement.appendChild(this.overlay);
|
---|
| 4348 | ZIndexUtils.clear(this.overlay);
|
---|
| 4349 | this.onOverlayHide();
|
---|
| 4350 | }
|
---|
| 4351 | if (this.translationSubscription) {
|
---|
| 4352 | this.translationSubscription.unsubscribe();
|
---|
| 4353 | }
|
---|
| 4354 | if (this.resetSubscription) {
|
---|
| 4355 | this.resetSubscription.unsubscribe();
|
---|
| 4356 | }
|
---|
| 4357 | if (this.overlaySubscription) {
|
---|
| 4358 | this.overlaySubscription.unsubscribe();
|
---|
| 4359 | }
|
---|
| 4360 | }
|
---|
| 4361 | }
|
---|
| 4362 | ColumnFilter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColumnFilter, deps: [{ token: i0.ElementRef }, { token: Table }, { token: i0.Renderer2 }, { token: i1.PrimeNGConfig }, { token: i1.OverlayService }], target: i0.ɵɵFactoryTarget.Component });
|
---|
| 4363 | ColumnFilter.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: ColumnFilter, selector: "p-columnFilter", inputs: { field: "field", type: "type", display: "display", showMenu: "showMenu", matchMode: "matchMode", operator: "operator", showOperator: "showOperator", showClearButton: "showClearButton", showApplyButton: "showApplyButton", showMatchModes: "showMatchModes", showAddButton: "showAddButton", hideOnClear: "hideOnClear", placeholder: "placeholder", matchModeOptions: "matchModeOptions", maxConstraints: "maxConstraints", minFractionDigits: "minFractionDigits", maxFractionDigits: "maxFractionDigits", prefix: "prefix", suffix: "suffix", locale: "locale", localeMatcher: "localeMatcher", currency: "currency", currencyDisplay: "currencyDisplay", useGrouping: "useGrouping" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "icon", first: true, predicate: ["icon"], descendants: true }], ngImport: i0, template: `
|
---|
| 4364 | <div class="p-column-filter" [ngClass]="{'p-column-filter-row': display === 'row', 'p-column-filter-menu': display === 'menu'}">
|
---|
| 4365 | <p-columnFilterFormElement *ngIf="display === 'row'" class="p-fluid" [type]="type" [field]="field" [filterConstraint]="dt.filters[field]" [filterTemplate]="filterTemplate" [placeholder]="placeholder" [minFractionDigits]="minFractionDigits" [maxFractionDigits]="maxFractionDigits" [prefix]="prefix" [suffix]="suffix"
|
---|
| 4366 | [locale]="locale" [localeMatcher]="localeMatcher" [currency]="currency" [currencyDisplay]="currencyDisplay" [useGrouping]="useGrouping"></p-columnFilterFormElement>
|
---|
| 4367 | <button #icon *ngIf="showMenuButton" type="button" class="p-column-filter-menu-button p-link" aria-haspopup="true" [attr.aria-expanded]="overlayVisible"
|
---|
| 4368 | [ngClass]="{'p-column-filter-menu-button-open': overlayVisible, 'p-column-filter-menu-button-active': hasFilter()}"
|
---|
| 4369 | (click)="toggleMenu()" (keydown)="onToggleButtonKeyDown($event)"><span class="pi pi-filter-icon pi-filter"></span></button>
|
---|
| 4370 | <button #icon *ngIf="showClearButton && display === 'row'" [ngClass]="{'p-hidden-space': !hasRowFilter()}" type="button" class="p-column-filter-clear-button p-link" (click)="clearFilter()"><span class="pi pi-filter-slash"></span></button>
|
---|
| 4371 | <div *ngIf="showMenu && overlayVisible" [ngClass]="{'p-column-filter-overlay p-component p-fluid': true, 'p-column-filter-overlay-menu': display === 'menu'}" (click)="onContentClick()"
|
---|
| 4372 | [@overlayAnimation]="'visible'" (@overlayAnimation.start)="onOverlayAnimationStart($event)" (@overlayAnimation.done)="onOverlayAnimationEnd($event)" (keydown.escape)="onEscape()">
|
---|
| 4373 | <ng-container *ngTemplateOutlet="headerTemplate; context: {$implicit: field}"></ng-container>
|
---|
| 4374 | <ul *ngIf="display === 'row'; else menu" class="p-column-filter-row-items">
|
---|
| 4375 | <li class="p-column-filter-row-item" *ngFor="let matchMode of matchModes; let i = index;" (click)="onRowMatchModeChange(matchMode.value)" (keydown)="onRowMatchModeKeyDown($event)" (keydown.enter)="this.onRowMatchModeChange(matchMode.value)"
|
---|
| 4376 | [ngClass]="{'p-highlight': isRowMatchModeSelected(matchMode.value)}" [attr.tabindex]="i === 0 ? '0' : null">{{matchMode.label}}</li>
|
---|
| 4377 | <li class="p-column-filter-separator"></li>
|
---|
| 4378 | <li class="p-column-filter-row-item" (click)="onRowClearItemClick()" (keydown)="onRowMatchModeKeyDown($event)" (keydown.enter)="onRowClearItemClick()">{{noFilterLabel}}</li>
|
---|
| 4379 | </ul>
|
---|
| 4380 | <ng-template #menu>
|
---|
| 4381 | <div class="p-column-filter-operator" *ngIf="isShowOperator">
|
---|
| 4382 | <p-dropdown [options]="operatorOptions" [ngModel]="operator" (ngModelChange)="onOperatorChange($event)" styleClass="p-column-filter-operator-dropdown"></p-dropdown>
|
---|
| 4383 | </div>
|
---|
| 4384 | <div class="p-column-filter-constraints">
|
---|
| 4385 | <div *ngFor="let fieldConstraint of fieldConstraints; let i = index" class="p-column-filter-constraint">
|
---|
| 4386 | <p-dropdown *ngIf="showMatchModes && matchModes" [options]="matchModes" [ngModel]="fieldConstraint.matchMode" (ngModelChange)="onMenuMatchModeChange($event, fieldConstraint)" styleClass="p-column-filter-matchmode-dropdown"></p-dropdown>
|
---|
| 4387 | <p-columnFilterFormElement [type]="type" [field]="field" [filterConstraint]="fieldConstraint" [filterTemplate]="filterTemplate" [placeholder]="placeholder"
|
---|
| 4388 | [minFractionDigits]="minFractionDigits" [maxFractionDigits]="maxFractionDigits" [prefix]="prefix" [suffix]="suffix"
|
---|
| 4389 | [locale]="locale" [localeMatcher]="localeMatcher" [currency]="currency" [currencyDisplay]="currencyDisplay" [useGrouping]="useGrouping"></p-columnFilterFormElement>
|
---|
| 4390 | <div>
|
---|
| 4391 | <button *ngIf="showRemoveIcon" type="button" pButton icon="pi pi-trash" class="p-column-filter-remove-button p-button-text p-button-danger p-button-sm" (click)="removeConstraint(fieldConstraint)" pRipple [label]="removeRuleButtonLabel"></button>
|
---|
| 4392 | </div>
|
---|
| 4393 | </div>
|
---|
| 4394 | </div>
|
---|
| 4395 | <div class="p-column-filter-add-rule" *ngIf="isShowAddConstraint">
|
---|
| 4396 | <button type="button" pButton [label]="addRuleButtonLabel" icon="pi pi-plus" class="p-column-filter-add-button p-button-text p-button-sm" (click)="addConstraint()" pRipple></button>
|
---|
| 4397 | </div>
|
---|
| 4398 | <div class="p-column-filter-buttonbar">
|
---|
| 4399 | <button *ngIf="showClearButton" type="button" pButton class="p-button-outlined" (click)="clearFilter()" [label]="clearButtonLabel" pRipple></button>
|
---|
| 4400 | <button *ngIf="showApplyButton" type="button" pButton (click)="applyFilter()" [label]="applyButtonLabel" pRipple></button>
|
---|
| 4401 | </div>
|
---|
| 4402 | </ng-template>
|
---|
| 4403 | <ng-container *ngTemplateOutlet="footerTemplate; context: {$implicit: field}"></ng-container>
|
---|
| 4404 | </div>
|
---|
| 4405 | </div>
|
---|
| 4406 | `, isInline: true, components: [{ type: ColumnFilterFormElement, selector: "p-columnFilterFormElement", inputs: ["field", "type", "filterConstraint", "filterTemplate", "placeholder", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "locale", "localeMatcher", "currency", "currencyDisplay", "useGrouping"] }, { type: i10.Dropdown, selector: "p-dropdown", inputs: ["scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "filterPlaceholder", "filterLocale", "inputId", "selectId", "dataKey", "filterBy", "autofocus", "resetFilterOnHide", "dropdownIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "virtualScroll", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "ariaFilterLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "disabled", "options", "filterValue"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear"] }], directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i9.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i9.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i11.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }], animations: [
|
---|
| 4407 | trigger('overlayAnimation', [
|
---|
| 4408 | transition(':enter', [
|
---|
| 4409 | style({ opacity: 0, transform: 'scaleY(0.8)' }),
|
---|
| 4410 | animate('.12s cubic-bezier(0, 0, 0.2, 1)')
|
---|
| 4411 | ]),
|
---|
| 4412 | transition(':leave', [
|
---|
| 4413 | animate('.1s linear', style({ opacity: 0 }))
|
---|
| 4414 | ])
|
---|
| 4415 | ])
|
---|
| 4416 | ], encapsulation: i0.ViewEncapsulation.None });
|
---|
| 4417 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColumnFilter, decorators: [{
|
---|
| 4418 | type: Component,
|
---|
| 4419 | args: [{
|
---|
| 4420 | selector: 'p-columnFilter',
|
---|
| 4421 | template: `
|
---|
| 4422 | <div class="p-column-filter" [ngClass]="{'p-column-filter-row': display === 'row', 'p-column-filter-menu': display === 'menu'}">
|
---|
| 4423 | <p-columnFilterFormElement *ngIf="display === 'row'" class="p-fluid" [type]="type" [field]="field" [filterConstraint]="dt.filters[field]" [filterTemplate]="filterTemplate" [placeholder]="placeholder" [minFractionDigits]="minFractionDigits" [maxFractionDigits]="maxFractionDigits" [prefix]="prefix" [suffix]="suffix"
|
---|
| 4424 | [locale]="locale" [localeMatcher]="localeMatcher" [currency]="currency" [currencyDisplay]="currencyDisplay" [useGrouping]="useGrouping"></p-columnFilterFormElement>
|
---|
| 4425 | <button #icon *ngIf="showMenuButton" type="button" class="p-column-filter-menu-button p-link" aria-haspopup="true" [attr.aria-expanded]="overlayVisible"
|
---|
| 4426 | [ngClass]="{'p-column-filter-menu-button-open': overlayVisible, 'p-column-filter-menu-button-active': hasFilter()}"
|
---|
| 4427 | (click)="toggleMenu()" (keydown)="onToggleButtonKeyDown($event)"><span class="pi pi-filter-icon pi-filter"></span></button>
|
---|
| 4428 | <button #icon *ngIf="showClearButton && display === 'row'" [ngClass]="{'p-hidden-space': !hasRowFilter()}" type="button" class="p-column-filter-clear-button p-link" (click)="clearFilter()"><span class="pi pi-filter-slash"></span></button>
|
---|
| 4429 | <div *ngIf="showMenu && overlayVisible" [ngClass]="{'p-column-filter-overlay p-component p-fluid': true, 'p-column-filter-overlay-menu': display === 'menu'}" (click)="onContentClick()"
|
---|
| 4430 | [@overlayAnimation]="'visible'" (@overlayAnimation.start)="onOverlayAnimationStart($event)" (@overlayAnimation.done)="onOverlayAnimationEnd($event)" (keydown.escape)="onEscape()">
|
---|
| 4431 | <ng-container *ngTemplateOutlet="headerTemplate; context: {$implicit: field}"></ng-container>
|
---|
| 4432 | <ul *ngIf="display === 'row'; else menu" class="p-column-filter-row-items">
|
---|
| 4433 | <li class="p-column-filter-row-item" *ngFor="let matchMode of matchModes; let i = index;" (click)="onRowMatchModeChange(matchMode.value)" (keydown)="onRowMatchModeKeyDown($event)" (keydown.enter)="this.onRowMatchModeChange(matchMode.value)"
|
---|
| 4434 | [ngClass]="{'p-highlight': isRowMatchModeSelected(matchMode.value)}" [attr.tabindex]="i === 0 ? '0' : null">{{matchMode.label}}</li>
|
---|
| 4435 | <li class="p-column-filter-separator"></li>
|
---|
| 4436 | <li class="p-column-filter-row-item" (click)="onRowClearItemClick()" (keydown)="onRowMatchModeKeyDown($event)" (keydown.enter)="onRowClearItemClick()">{{noFilterLabel}}</li>
|
---|
| 4437 | </ul>
|
---|
| 4438 | <ng-template #menu>
|
---|
| 4439 | <div class="p-column-filter-operator" *ngIf="isShowOperator">
|
---|
| 4440 | <p-dropdown [options]="operatorOptions" [ngModel]="operator" (ngModelChange)="onOperatorChange($event)" styleClass="p-column-filter-operator-dropdown"></p-dropdown>
|
---|
| 4441 | </div>
|
---|
| 4442 | <div class="p-column-filter-constraints">
|
---|
| 4443 | <div *ngFor="let fieldConstraint of fieldConstraints; let i = index" class="p-column-filter-constraint">
|
---|
| 4444 | <p-dropdown *ngIf="showMatchModes && matchModes" [options]="matchModes" [ngModel]="fieldConstraint.matchMode" (ngModelChange)="onMenuMatchModeChange($event, fieldConstraint)" styleClass="p-column-filter-matchmode-dropdown"></p-dropdown>
|
---|
| 4445 | <p-columnFilterFormElement [type]="type" [field]="field" [filterConstraint]="fieldConstraint" [filterTemplate]="filterTemplate" [placeholder]="placeholder"
|
---|
| 4446 | [minFractionDigits]="minFractionDigits" [maxFractionDigits]="maxFractionDigits" [prefix]="prefix" [suffix]="suffix"
|
---|
| 4447 | [locale]="locale" [localeMatcher]="localeMatcher" [currency]="currency" [currencyDisplay]="currencyDisplay" [useGrouping]="useGrouping"></p-columnFilterFormElement>
|
---|
| 4448 | <div>
|
---|
| 4449 | <button *ngIf="showRemoveIcon" type="button" pButton icon="pi pi-trash" class="p-column-filter-remove-button p-button-text p-button-danger p-button-sm" (click)="removeConstraint(fieldConstraint)" pRipple [label]="removeRuleButtonLabel"></button>
|
---|
| 4450 | </div>
|
---|
| 4451 | </div>
|
---|
| 4452 | </div>
|
---|
| 4453 | <div class="p-column-filter-add-rule" *ngIf="isShowAddConstraint">
|
---|
| 4454 | <button type="button" pButton [label]="addRuleButtonLabel" icon="pi pi-plus" class="p-column-filter-add-button p-button-text p-button-sm" (click)="addConstraint()" pRipple></button>
|
---|
| 4455 | </div>
|
---|
| 4456 | <div class="p-column-filter-buttonbar">
|
---|
| 4457 | <button *ngIf="showClearButton" type="button" pButton class="p-button-outlined" (click)="clearFilter()" [label]="clearButtonLabel" pRipple></button>
|
---|
| 4458 | <button *ngIf="showApplyButton" type="button" pButton (click)="applyFilter()" [label]="applyButtonLabel" pRipple></button>
|
---|
| 4459 | </div>
|
---|
| 4460 | </ng-template>
|
---|
| 4461 | <ng-container *ngTemplateOutlet="footerTemplate; context: {$implicit: field}"></ng-container>
|
---|
| 4462 | </div>
|
---|
| 4463 | </div>
|
---|
| 4464 | `,
|
---|
| 4465 | animations: [
|
---|
| 4466 | trigger('overlayAnimation', [
|
---|
| 4467 | transition(':enter', [
|
---|
| 4468 | style({ opacity: 0, transform: 'scaleY(0.8)' }),
|
---|
| 4469 | animate('.12s cubic-bezier(0, 0, 0.2, 1)')
|
---|
| 4470 | ]),
|
---|
| 4471 | transition(':leave', [
|
---|
| 4472 | animate('.1s linear', style({ opacity: 0 }))
|
---|
| 4473 | ])
|
---|
| 4474 | ])
|
---|
| 4475 | ],
|
---|
| 4476 | encapsulation: ViewEncapsulation.None,
|
---|
| 4477 | host: {
|
---|
| 4478 | 'class': 'p-element'
|
---|
| 4479 | }
|
---|
| 4480 | }]
|
---|
| 4481 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: Table }, { type: i0.Renderer2 }, { type: i1.PrimeNGConfig }, { type: i1.OverlayService }]; }, propDecorators: { field: [{
|
---|
| 4482 | type: Input
|
---|
| 4483 | }], type: [{
|
---|
| 4484 | type: Input
|
---|
| 4485 | }], display: [{
|
---|
| 4486 | type: Input
|
---|
| 4487 | }], showMenu: [{
|
---|
| 4488 | type: Input
|
---|
| 4489 | }], matchMode: [{
|
---|
| 4490 | type: Input
|
---|
| 4491 | }], operator: [{
|
---|
| 4492 | type: Input
|
---|
| 4493 | }], showOperator: [{
|
---|
| 4494 | type: Input
|
---|
| 4495 | }], showClearButton: [{
|
---|
| 4496 | type: Input
|
---|
| 4497 | }], showApplyButton: [{
|
---|
| 4498 | type: Input
|
---|
| 4499 | }], showMatchModes: [{
|
---|
| 4500 | type: Input
|
---|
| 4501 | }], showAddButton: [{
|
---|
| 4502 | type: Input
|
---|
| 4503 | }], hideOnClear: [{
|
---|
| 4504 | type: Input
|
---|
| 4505 | }], placeholder: [{
|
---|
| 4506 | type: Input
|
---|
| 4507 | }], matchModeOptions: [{
|
---|
| 4508 | type: Input
|
---|
| 4509 | }], maxConstraints: [{
|
---|
| 4510 | type: Input
|
---|
| 4511 | }], minFractionDigits: [{
|
---|
| 4512 | type: Input
|
---|
| 4513 | }], maxFractionDigits: [{
|
---|
| 4514 | type: Input
|
---|
| 4515 | }], prefix: [{
|
---|
| 4516 | type: Input
|
---|
| 4517 | }], suffix: [{
|
---|
| 4518 | type: Input
|
---|
| 4519 | }], locale: [{
|
---|
| 4520 | type: Input
|
---|
| 4521 | }], localeMatcher: [{
|
---|
| 4522 | type: Input
|
---|
| 4523 | }], currency: [{
|
---|
| 4524 | type: Input
|
---|
| 4525 | }], currencyDisplay: [{
|
---|
| 4526 | type: Input
|
---|
| 4527 | }], useGrouping: [{
|
---|
| 4528 | type: Input
|
---|
| 4529 | }], icon: [{
|
---|
| 4530 | type: ViewChild,
|
---|
| 4531 | args: ['icon']
|
---|
| 4532 | }], templates: [{
|
---|
| 4533 | type: ContentChildren,
|
---|
| 4534 | args: [PrimeTemplate]
|
---|
| 4535 | }] } });
|
---|
| 4536 | class TableModule {
|
---|
| 4537 | }
|
---|
| 4538 | TableModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
---|
| 4539 | TableModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableModule, declarations: [Table, SortableColumn, FrozenColumn, RowGroupHeader, SelectableRow, RowToggler, ContextMenuRow, ResizableColumn, ReorderableColumn, EditableColumn, CellEditor, TableBody, SortIcon, TableRadioButton, TableCheckbox, TableHeaderCheckbox, ReorderableRowHandle, ReorderableRow, SelectableRowDblClick, EditableRow, InitEditableRow, SaveEditableRow, CancelEditableRow, ColumnFilter, ColumnFilterFormElement], imports: [CommonModule, PaginatorModule, InputTextModule, DropdownModule, ScrollingModule, FormsModule, ButtonModule, SelectButtonModule, CalendarModule, InputNumberModule, TriStateCheckboxModule], exports: [Table, SharedModule, SortableColumn, FrozenColumn, RowGroupHeader, SelectableRow, RowToggler, ContextMenuRow, ResizableColumn, ReorderableColumn, EditableColumn, CellEditor, SortIcon, TableRadioButton, TableCheckbox, TableHeaderCheckbox, ReorderableRowHandle, ReorderableRow, SelectableRowDblClick, EditableRow, InitEditableRow, SaveEditableRow, CancelEditableRow, ScrollingModule, ColumnFilter] });
|
---|
| 4540 | TableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableModule, imports: [[CommonModule, PaginatorModule, InputTextModule, DropdownModule, ScrollingModule, FormsModule, ButtonModule, SelectButtonModule, CalendarModule, InputNumberModule, TriStateCheckboxModule], SharedModule,
|
---|
| 4541 | ScrollingModule] });
|
---|
| 4542 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: TableModule, decorators: [{
|
---|
| 4543 | type: NgModule,
|
---|
| 4544 | args: [{
|
---|
| 4545 | imports: [CommonModule, PaginatorModule, InputTextModule, DropdownModule, ScrollingModule, FormsModule, ButtonModule, SelectButtonModule, CalendarModule, InputNumberModule, TriStateCheckboxModule],
|
---|
| 4546 | exports: [Table, SharedModule, SortableColumn, FrozenColumn, RowGroupHeader, SelectableRow, RowToggler, ContextMenuRow, ResizableColumn, ReorderableColumn, EditableColumn, CellEditor, SortIcon,
|
---|
| 4547 | TableRadioButton, TableCheckbox, TableHeaderCheckbox, ReorderableRowHandle, ReorderableRow, SelectableRowDblClick, EditableRow, InitEditableRow, SaveEditableRow, CancelEditableRow, ScrollingModule, ColumnFilter],
|
---|
| 4548 | declarations: [Table, SortableColumn, FrozenColumn, RowGroupHeader, SelectableRow, RowToggler, ContextMenuRow, ResizableColumn, ReorderableColumn, EditableColumn, CellEditor, TableBody, SortIcon,
|
---|
| 4549 | TableRadioButton, TableCheckbox, TableHeaderCheckbox, ReorderableRowHandle, ReorderableRow, SelectableRowDblClick, EditableRow, InitEditableRow, SaveEditableRow, CancelEditableRow, ColumnFilter, ColumnFilterFormElement]
|
---|
| 4550 | }]
|
---|
| 4551 | }] });
|
---|
| 4552 |
|
---|
| 4553 | /**
|
---|
| 4554 | * Generated bundle index. Do not edit.
|
---|
| 4555 | */
|
---|
| 4556 |
|
---|
| 4557 | export { CancelEditableRow, CellEditor, ColumnFilter, ColumnFilterFormElement, ContextMenuRow, EditableColumn, EditableRow, FrozenColumn, InitEditableRow, ReorderableColumn, ReorderableRow, ReorderableRowHandle, ResizableColumn, RowGroupHeader, RowToggler, SaveEditableRow, SelectableRow, SelectableRowDblClick, SortIcon, SortableColumn, Table, TableBody, TableCheckbox, TableHeaderCheckbox, TableModule, TableRadioButton, TableService };
|
---|