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.

48 lines (47 loc) 1.92 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { closest, findFocusable, isVisible, matchesNodeName } from '../rendering/common/dom-queries'; const isButton = matchesNodeName('button'); const isInputTag = matchesNodeName('input'); const isKendoInputTag = matchesNodeName('kendo-checkbox') || matchesNodeName('kendo-textbox'); const navigableRegex = /(button|checkbox|color|file|radio|reset|submit)/i; const isNavigableInput = element => isInputTag(element) && navigableRegex.test(element.type); const isNavigable = element => !element.disabled && (isButton(element) || isNavigableInput(element) || isKendoInputTag(element)); /** * @hidden */ export class DefaultFocusableElement { renderer; get enabled() { return this.focusable && !this.focusable.disabled; } get visible() { return this.focusable && isVisible(this.focusable); } element; focusable; constructor(host, renderer) { this.renderer = renderer; this.element = host.nativeElement; this.focusable = findFocusable(this.element, false) || this.element; } isNavigable() { return this.canFocus() && isNavigable(this.element); } toggle(active) { this.renderer.setAttribute(this.focusable, 'tabIndex', active ? '0' : '-1'); } focus() { if (this.focusable) { this.focusable.focus(); } } canFocus() { return this.visible && this.enabled; } hasFocus() { return document && document.activeElement !== this.element && closest(document.activeElement, e => e === this.element); } }