UNPKG

@progress/kendo-angular-grid

Version:

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

49 lines (48 loc) 2 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'; import { isDocumentAvailable } from '@progress/kendo-angular-common'; 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 isDocumentAvailable() && document.activeElement !== this.element && closest(document.activeElement, e => e === this.element); } }