UNPKG

@dvcol/common-utils

Version:

Typescript library for common utility functions and constants

19 lines (17 loc) 1.96 kB
declare const focusableElementSelectors: readonly ["button:not([disabled])", "[href]", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", "[tabindex]"]; declare const tabFocusableElementSelectors: readonly ["button:not([disabled], [tabindex=\"-1\"])", "[href]:not([tabindex=\"-1\"])", "input:not([disabled], [tabindex=\"-1\"])", "select:not([disabled], [tabindex=\"-1\"])", "textarea:not([disabled], [tabindex=\"-1\"])", "[tabindex]:not([tabindex=\"-1\"])"]; declare const getFocusableElement: (element?: Element | null, targets?: string[] | readonly string[]) => HTMLElement | null | undefined; /** * Get all focusable children of an element (excluding non tabbable elements (disabled, readonly, tabIndex=-1)) * @param element - The element to search within * @param targets - Array of selectors to search for focusable elements * @returns Array of focusable elements sorted by tabIndex (from lowest to highest) */ declare const getFocusableElements: (element?: Element | null, targets?: string[] | readonly string[]) => HTMLElement[] | undefined; declare const getLastFocusableElement: (element?: Element | null, targets?: string[] | readonly string[]) => HTMLElement | null | undefined; declare const clickableTags: Set<string>; declare const isClickable: (element: Element) => boolean; declare const getClickableAncestor: (element: Element, boundary?: Element | (() => Element), selector?: (node: Element) => boolean) => Element | undefined; declare const clickableSelector = "a, button, input, textarea, select, details, summary, [role='button'], [role='link'], [onclick], audio, video, [tabindex]:not([tabindex='-1'])"; declare const closestClickableElement: (element: Element) => Element; export { clickableSelector, clickableTags, closestClickableElement, focusableElementSelectors, getClickableAncestor, getFocusableElement, getFocusableElements, getLastFocusableElement, isClickable, tabFocusableElementSelectors };