/** * Copyright (c) Microsoft. All rights reserved. */ import { LabelerA11yStore } from '../stores/LabelerA11yStore'; import { LabelerSelectionStore } from '../stores/LabelerSelectionStore'; import { AnnotationData, ITokenStore, TokenEventListenersFactory, TokenPaddingCalculator } from '../types/labelerTypes'; /** * Searches the DOM in the given container for the token * with the given index. * * @param ref The reference of the container to search in. * @param index The index of the token to find. * @returns The token HTML element. */ export declare const getNewLabelerTokenElementByIndex: (ref: HTMLElement, index: number) => Element; /** * Labels need space under tokens. If a token has more than one * label, it needs multiple levels of padding for the multiple * levels of labels. * * Note that we add an additional level in the * max level calculations. That is even level 0 labels need * token padding to ensure that they don't overlap with annotations * on the line below them. * * @param tokenStore The token store of the token getting * the padding levels for. * @param annotationsPerToken An array of the annotations that * pass through this token. * @returns A tuple that indicates the top and bottom padding needed. */ export declare const calculateLabelTokenPadding: TokenPaddingCalculator; /** * Relations need space above tokens. If a token has more than one * relation, it needs multiple levels of top padding for the multiple * levels of relations. * * @param tokenStore The token store of the token getting * the padding levels for. * @param annotationsPerToken An array of the annotations that * pass through this token. * @returns A tuple that indicates the top and bottom padding needed. */ export declare const calculateRelationTokenPadding: TokenPaddingCalculator; /** * Predictions need space under tokens. If a token has more than one * prediction, it needs multiple levels of padding for the multiple * levels of predictions. * * @param tokenStore The token store of the token getting * the padding levels for. * @param annotationsPerToken An array of the annotations that * pass through this token. * @returns A tuple that indicates the top and bottom padding needed. */ export declare const calculatePredictionTokenPadding: TokenPaddingCalculator; /** * Calculates the maximum top and bottom padding steps * for the given tokens given the padding calculators. * * For example, for each token, the following is run: * - An entity labeling padding calculator returned 3 as the * top padding due to the existence of 3 levels of entities. * - A relations padding calculator returned 4 as the top * padding due to the existence of 4 levels of relations. * - The returned value for the top padding is then 4. * * The maximum value of all tokens provided is returned. * * @param stores The token store underlying this specific token. * @param calculators An array of functions that calculate padding levels. */ export declare const calculateMaxTokenPadding: (stores: ITokenStore[], calculators: TokenPaddingCalculator[], annotationsPerTokenMap: Map) => [number, number]; /** * Creates a factory function that creates an object that contains * event listeners for user interactions to be attached on tokens. * * @param selectionStore The labeling selection store that governs * the hover and selection state of the labeler. * @param tokenStore The token store of the token that the events * will be attached to. */ export declare const getTokenEventListenersFactory: ({ a11yStore, selectionStore }: { a11yStore: LabelerA11yStore; selectionStore: LabelerSelectionStore; }) => TokenEventListenersFactory; /** * Get the element that contains the given attribute in the given * array of elements or html collection. * * @param elements The elements that may contain element with the given attribute. * @param attribute The attribute to search for. * @returns The element that contains the given attribute. */ export declare const getElementWithAttribute: (elements: Element[] | HTMLCollection, attribute: string) => Element;