UNPKG

@progress/kendo-angular-grid

Version:

Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.

67 lines (66 loc) 3.24 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, ElementRef } from '@angular/core'; import { isDocumentAvailable } from '@progress/kendo-angular-common'; import { ContextService } from '../../common/provider.service'; import * as i0 from "@angular/core"; import * as i1 from "../../common/provider.service"; /** * A directive applied to all toolbar elements that need to be a part of the Grid * keyboard navigation. */ export class GridToolbarFocusableDirective { host; ctx; /** * @hidden */ get element() { return this.host.nativeElement; } /** * @hidden */ get toolbarPosition() { return isDocumentAvailable() && this.host.nativeElement.closest('.k-toolbar')?.getAttribute('position'); } constructor(host, ctx) { this.host = host; this.ctx = ctx; } ngAfterViewInit() { if (!isDocumentAvailable() || !this.toolbarPosition) { return; } this.ctx[`${this.toolbarPosition}ToolbarNavigation`]?.navigableElements.push(this.element); this.ctx[`${this.toolbarPosition}ToolbarNavigation`]?.notify(); } ngOnDestroy() { if (!isDocumentAvailable() || !this.toolbarPosition) { return; } const elements = this.ctx[`${this.toolbarPosition}ToolbarNavigation`].navigableElements; this.ctx[`${this.toolbarPosition}ToolbarNavigation`].navigableElements = elements.filter(el => el !== this.element); this.ctx[`${this.toolbarPosition}ToolbarNavigation`].notify(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GridToolbarFocusableDirective, deps: [{ token: i0.ElementRef }, { token: i1.ContextService }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: GridToolbarFocusableDirective, isStandalone: true, selector: "\n [kendoGridToolbarFocusable],\n [kendoGridAddCommand],\n [kendoGridCancelCommand],\n [kendoGridEditCommand],\n [kendoGridRemoveCommand],\n [kendoGridSaveCommand],\n [kendoGridExcelCommand],\n [kendoGridPDFCommand]\n ", ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GridToolbarFocusableDirective, decorators: [{ type: Directive, args: [{ selector: ` [kendoGridToolbarFocusable], [kendoGridAddCommand], [kendoGridCancelCommand], [kendoGridEditCommand], [kendoGridRemoveCommand], [kendoGridSaveCommand], [kendoGridExcelCommand], [kendoGridPDFCommand] `, standalone: true }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.ContextService }]; } });