UNPKG

@progress/kendo-angular-treelist

Version:

Kendo UI TreeList for Angular - Display hierarchical data in an Angular tree grid view that supports sorting, filtering, paging, and much more.

55 lines (54 loc) 2.63 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 TreeListToolbarNavigationService { renderer; navigableElements = []; currentActiveIndex = 0; defaultFocusableSelector = ` [kendoTreeListToolbarFocusable], [kendoTreeListAddCommand], [kendoTreeListCancelCommand], [kendoTreeListEditCommand], [kendoTreeListRemoveCommand], [kendoTreeListSaveCommand], [kendoTreeListExcelCommand], [kendoTreeListPDFCommand] `; 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: TreeListToolbarNavigationService, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListToolbarNavigationService }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListToolbarNavigationService, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i0.Renderer2 }]; } });