UNPKG

@progress/kendo-angular-grid

Version:

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

55 lines (54 loc) 2.59 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Injectable, Renderer2 } from '@angular/core'; import { isDocumentAvailable } from '@progress/kendo-angular-common'; import * as i0 from "@angular/core"; /** * @hidden */ export class GridToolbarNavigationService { renderer; navigableElements = []; currentActiveIndex = 0; defaultFocusableSelector = ` [kendogridtoolbarfocusable], [kendogridaddcommand], [kendogridcancelcommand], [kendogrideditcommand], [kendogridremovecommand], [kendogridsavecommand], [kendogridexcelcommand], [kendogridpdfcommand] `; constructor(renderer) { this.renderer = renderer; } notify() { // ensure focusable elements are in the same order as in the DOM this.navigableElements = (this.navigableElements.length && this.navigableElements[0]?.parentElement) ? Array.from(this.navigableElements[0]?.parentElement?.querySelectorAll(this.defaultFocusableSelector) || []) : []; this.currentActiveIndex = 0; this.updateFocus(); } focus() { this.navigableElements[this.currentActiveIndex]?.focus(); } updateFocus() { if (!this.navigableElements.length) { return; } this.navigableElements.forEach(el => { this.renderer.setAttribute(el, 'tabindex', '-1'); }); this.renderer.setAttribute(this.navigableElements[this.currentActiveIndex], 'tabindex', '0'); if (isDocumentAvailable() && document.activeElement.closest('.k-toolbar')) { this.navigableElements[this.currentActiveIndex].focus(); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GridToolbarNavigationService, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GridToolbarNavigationService }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GridToolbarNavigationService, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i0.Renderer2 }]; } });