/** * Copyright (c) Microsoft. All rights reserved. */ import { TargetIndex } from '../types/labelerTypes'; type FocusDirection = 'next' | 'previous' | 'first' | 'last'; export declare class LabelerA11yStore { lineCount: number; tokenCount: number; containerRef: HTMLDivElement; focusedLineIndex: number | null; focusedTokenIndex: number | null; focusedAnnotationKey: string | null; /** * Initializes the store with necessary information for * focus calculations. * * @param containerRef The ref to the DOM element that contains the lines. * @param lineCount The number of lines in the text. * @param tokenCount The number of tokens in the text. */ initialize(containerRef: HTMLDivElement, lineCount: number, tokenCount: number): void; /** * Focuses the line with the given index. * * @param index The index of the line to focus. */ focusLineByIndex(index: number): void; /** * Focuses a new line based on the given direction. The * direction controls focus relative to the currently * focused line as follows: * * - next: Focuses the line after the current line. * - previous: Focuses the line before the current line. * - first: Focuses the first line in the text. * - last: Focuses the last line in the text. * * @param direction The direction to control focus movement. * @param isCircular If true, when focused on the last line, * moving forward jumps focus to the first line, and vice versa. */ focusLineByDirection(direction: FocusDirection, isCircular?: boolean, targetIndex?: TargetIndex): void; /** * Focuses the token by the given index. * * @param index The index of the token to focus. */ focusTokenByIndex(index: number): void; /** * Focuses a new token based on the given direction. The * directions controls focus relative to the currently * focused token as follows: * * - next: Focuses the token after the current token. * - previous: Focuses the token before the current token. * - first: Focuses the first token in the text. * - last: Focuses the last token in the text. * * @param direction The direction to control focus movement. * @param isCircular If true, when focused on the last token, * moving forward jumps focus to the first token, and vice versa. */ focusTokenByDirection(direction: FocusDirection, isCircular?: boolean): void; /** * Focuses the annotation based on the given direction and * the current focused annotation or token (if the focus is * not on an annotation). * * Read more about how this function works in `labelerA11yStore.md`. * * @param direction The direction to move the focus to. * @param isCircular If true, when focused on the last annotation, * moving forward jumps focus to the first annotation, and vice versa. */ focusAnnotationByDirection(direction: FocusDirection, isCircular?: boolean): void; /** * Blurs the currently focused token. */ blurCurrentToken(): void; /** * Blurs the currently focused annotation. */ blurCurrentAnnotation(): void; /** * Blurs focus off the current focused element of the given * type. Blurring involves un-setting the current focused * element and removing the tab index attribute from its * corresponding HTML element. * * @param elementType The element type to blur. */ private _blurCurrent; /** * Focuses the element with the given type and index. The focus * function has two modes: `default` and `withoutHtml`. This controls * whether the HTML element should actually be focused (default mode) * or just be marked as focused through state change but without an * actual change in the document active element (noDom mode). * * @param elementType The type of the element to focus. * @param index The index of the element to focus. * @param mode The focus mode, which controls whether the active element * itself would be focused or not. */ private _focus; } export {};