@progress/kendo-angular-grid
Version: 
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
132 lines (131 loc) • 5.75 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Directive, HostBinding, Input } from '@angular/core';
import { IdService } from '../common/id.service';
import { NavigationService } from './navigation.service';
import { anyChanged } from '@progress/kendo-angular-common';
import { ColumnsContainer } from '../columns/columns-container';
import * as i0 from "@angular/core";
import * as i1 from "../common/id.service";
import * as i2 from "./navigation.service";
let id = 0;
function nextId() {
    return id++;
}
/**
 * @hidden
 */
export class LogicalRowDirective {
    idService;
    navigation;
    logicalRowIndex;
    logicalSlaveRow = false;
    logicalCellsCount;
    logicalSlaveCellsCount = 0;
    dataRowIndex = -1;
    dataItem;
    totalColumns;
    uid = nextId();
    get hostRole() {
        return this.logicalSlaveRow ? 'presentation' : 'row';
    }
    get ariaRowIndex() {
        return this.logicalSlaveRow ? null : this.logicalRowIndex + 1;
    }
    get rowIndex() {
        return this.logicalSlaveRow ? this.logicalRowIndex + 1 : null;
    }
    tableRowClass = true;
    get ariaOwns() {
        if (this.logicalSlaveRow || this.logicalSlaveCellsCount === 0) {
            return undefined;
        }
        const ids = [];
        if (this.dataRowIndex < 0) {
            let total = this.logicalCellsCount + this.logicalSlaveCellsCount;
            this.columnsArray.forEach(column => {
                if (column.isSpanColumn) {
                    total += column.colspan - 1;
                }
            });
            for (let cellIndex = this.logicalCellsCount; cellIndex < total; cellIndex++) {
                ids.push(this.idService.cellId(this.logicalRowIndex, cellIndex));
            }
        }
        else {
            let columnIndex = 0;
            this.columnsArray.forEach(column => {
                if (!column.isLocked) {
                    ids.push(this.idService.cellId(this.logicalRowIndex, columnIndex));
                }
                columnIndex += column.isSpanColumn ? column.colspan : 1;
            });
        }
        return ids.join(' ');
    }
    constructor(idService, navigation) {
        this.idService = idService;
        this.navigation = navigation;
    }
    ngOnChanges(changes) {
        if (!this.navigation.enabled || this.logicalSlaveRow) {
            return;
        }
        const indexChange = changes.logicalRowIndex;
        const logicalSlaveRowChange = changes.logicalSlaveRow;
        if (indexChange || logicalSlaveRowChange) {
            const index = indexChange && !indexChange.isFirstChange() ? indexChange.previousValue : this.logicalRowIndex;
            this.navigation.unregisterRow(index, this);
            this.navigation.registerRow(this);
        }
        else if (anyChanged(['dataRowIndex', 'dataItem'], changes)) {
            this.navigation.updateRow(this);
        }
    }
    ngOnDestroy() {
        this.navigation.unregisterRow(this.logicalRowIndex, this);
    }
    get columnsArray() {
        return this.totalColumns?.allColumns.toArray() || [];
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LogicalRowDirective, deps: [{ token: i1.IdService }, { token: i2.NavigationService }], target: i0.ɵɵFactoryTarget.Directive });
    static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: LogicalRowDirective, isStandalone: true, selector: "[kendoGridLogicalRow]", inputs: { logicalRowIndex: "logicalRowIndex", logicalSlaveRow: "logicalSlaveRow", logicalCellsCount: "logicalCellsCount", logicalSlaveCellsCount: "logicalSlaveCellsCount", dataRowIndex: "dataRowIndex", dataItem: "dataItem", totalColumns: "totalColumns" }, host: { properties: { "attr.role": "this.hostRole", "attr.aria-rowindex": "this.ariaRowIndex", "attr.data-kendo-grid-row-index": "this.rowIndex", "class.k-table-row": "this.tableRowClass", "attr.aria-owns": "this.ariaOwns" } }, usesOnChanges: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LogicalRowDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[kendoGridLogicalRow]',
                    standalone: true
                }]
        }], ctorParameters: function () { return [{ type: i1.IdService }, { type: i2.NavigationService }]; }, propDecorators: { logicalRowIndex: [{
                type: Input
            }], logicalSlaveRow: [{
                type: Input
            }], logicalCellsCount: [{
                type: Input
            }], logicalSlaveCellsCount: [{
                type: Input
            }], dataRowIndex: [{
                type: Input
            }], dataItem: [{
                type: Input
            }], totalColumns: [{
                type: Input
            }], hostRole: [{
                type: HostBinding,
                args: ['attr.role']
            }], ariaRowIndex: [{
                type: HostBinding,
                args: ['attr.aria-rowindex']
            }], rowIndex: [{
                type: HostBinding,
                args: ['attr.data-kendo-grid-row-index']
            }], tableRowClass: [{
                type: HostBinding,
                args: ['class.k-table-row']
            }], ariaOwns: [{
                type: HostBinding,
                args: ['attr.aria-owns']
            }] } });