@ordojs/accessibility
Version:
Comprehensive accessibility system for OrdoJS with ARIA generation, automated testing, and screen reader support
163 lines (159 loc) • 4.1 kB
text/typescript
import { EventEmitter } from 'events';
import { F as FocusConfig, f as FocusInfo } from '../index-C9qyHjXw.mjs';
/**
* @fileoverview OrdoJS Accessibility - Focus Management Module
*
* Focus management, skip links, and keyboard navigation.
*/
/**
* Focus manager for handling focus management and keyboard navigation
*/
declare class FocusManager extends EventEmitter {
private config;
private focusableElements;
private focusTraps;
private skipLinks;
private isInitialized;
/**
* Create a new FocusManager instance
*
* @param config - Focus configuration
*/
constructor(config: FocusConfig);
/**
* Initialize the focus manager
*/
initialize(): Promise<void>;
/**
* Register focusable element
*
* @param element - Element selector
* @param info - Focus information
*/
registerFocusableElement(element: string, info?: Partial<FocusInfo>): void;
/**
* Create focus trap
*
* @param trapId - Focus trap ID
* @param elements - Elements in the trap
* @param options - Trap options
*/
createFocusTrap(trapId: string, elements: string[], options?: {
restoreFocus?: boolean;
initialFocus?: string;
returnFocus?: boolean;
}): void;
/**
* Remove focus trap
*
* @param trapId - Focus trap ID
* @param options - Removal options
*/
removeFocusTrap(trapId: string, options?: {
restoreFocus?: boolean;
returnFocus?: boolean;
}): void;
/**
* Set focus to element
*
* @param element - Element selector
*/
setFocus(element: string): void;
/**
* Move focus to next element
*
* @param currentElement - Current element
* @returns Next focused element or undefined
*/
moveToNextElement(currentElement: string): FocusInfo | undefined;
/**
* Move focus to previous element
*
* @param currentElement - Current element
* @returns Previous focused element or undefined
*/
moveToPreviousElement(currentElement: string): FocusInfo | undefined;
/**
* Add skip link
*
* @param target - Target element
* @param label - Skip link label
* @param position - Skip link position
*/
addSkipLink(target: string, label: string, position?: 'top' | 'bottom'): void;
/**
* Remove skip link
*
* @param target - Target element
*/
removeSkipLink(target: string): void;
/**
* Handle keyboard navigation
*
* @param event - Keyboard event
* @param currentElement - Current element
* @returns Navigation result
*/
handleKeyboardNavigation(event: KeyboardEvent, currentElement: string): {
handled: boolean;
action: string;
target?: string;
};
/**
* Get focusable elements
*
* @returns Array of focusable elements
*/
getFocusableElements(): FocusInfo[];
/**
* Get focus trap elements
*
* @param trapId - Focus trap ID
* @returns Array of trapped elements
*/
getFocusTrapElements(trapId: string): FocusInfo[];
/**
* Get skip links
*
* @returns Array of skip links
*/
getSkipLinks(): Array<{
target: string;
label: string;
}>;
/**
* Get currently focused element
*
* @returns Focused element or undefined
*/
getFocusedElement(): FocusInfo | undefined;
/**
* Get focus manager statistics
*
* @returns Statistics
*/
getStats(): {
totalElements: number;
focusableElements: number;
focusedElements: number;
focusTraps: number;
skipLinks: number;
};
/**
* Initialize focus management
*/
private initializeFocusManagement;
/**
* Setup focus indicators
*/
private setupFocusIndicators;
/**
* Setup skip links
*/
private setupSkipLinks;
/**
* Setup focus restoration
*/
private setupFocusRestoration;
}
export { FocusManager };