UNPKG

@progress/kendo-angular-grid

Version:

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

74 lines (73 loc) 2.67 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 } from '@angular/core'; import { FocusRoot } from './focus-root'; import * as i0 from "@angular/core"; import * as i1 from "./focus-root"; /** * @hidden */ export class FocusGroup { root; active = true; children = []; get focusableChildren() { return this.children.filter(el => el.canFocus()); } get isActive() { return this.active; } constructor(root) { this.root = root; this.root.registerGroup(this); } ngOnDestroy() { this.root.unregisterGroup(this); this.active = true; } registerElement(element) { this.unregisterElement(element); this.children.push(element); } unregisterElement(element) { this.children = this.children.filter(f => f !== element); } /** * Returns a Boolean value which indicates if the group will receive focus when the cell is focused. * Requires a single "simple" focusable element such as a button or a checkbox. */ isNavigable() { const focusable = this.focusableChildren; return focusable.length === 1 && focusable[0].isNavigable(); } canFocus() { return this.focusableChildren.length > 0; } focus() { if (this.canFocus() && !this.hasFocus()) { this.focusableChildren[0].focus(); } } activate() { this.toggleState(true); } deactivate() { this.toggleState(false); } hasFocus() { return this.children.reduce((focused, element) => focused || element.hasFocus(), false); } toggleState(active) { if (this.active !== active) { this.active = active; this.children.forEach(f => f.toggle(active)); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FocusGroup, deps: [{ token: i1.FocusRoot }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FocusGroup }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FocusGroup, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i1.FocusRoot }]; } });