/** The trigger character a Mentions field uses when it configures none. */ export declare const DEFAULT_MENTION_TRIGGER = "@"; /** The mention being typed: its trigger character, the text after it, and the range the pair occupies. */ export interface MentionToken { /** The trigger character that opened the token. */ trigger: string; /** Text between the trigger character and the caret — what the item list is filtered by. */ query: string; /** Offset of the trigger character in the field value. */ start: number; /** Offset just past the query; always the caret offset the token was found at. */ end: number; } /** Where a trigger character is allowed to open a token, and what abandons one. */ export interface MentionTokenOptions { /** * Trigger characters, either as an array or as one string read a character at a time. * @defaultValue `'@'` */ triggers?: string | readonly string[] | undefined; /** * How many spaces a query may contain before the token is abandoned. * @defaultValue 0 */ allowedSpaces?: number | undefined; /** * Whether a trigger opens a token only at the start of the value or after a non-word character, so `user@example` is left alone. * @defaultValue true */ requireWordBoundary?: boolean | undefined; } /** * The mention token the caret sits in, found by scanning backwards from the * caret to the nearest trigger character. * * Returns `null` for every condition that ends a mention: no trigger before * the caret, a line break between them, more spaces than `allowedSpaces`, a * trigger that fails the word-boundary rule, or a caret that has moved out of * the token. There is no token to cancel — call this again after every value, * caret or selection change and the answer is the whole state. * * @param value the field's full text * @param caret the caret offset, clamped into the value * @param options the trigger and boundary rules */ export declare function findMentionToken(value: string, caret: number, options?: MentionTokenOptions): MentionToken | null; /** * Whether an Escape recorded at `dismissedAt` still suppresses this token. * * Escape closes the popup while the token is still syntactically alive, so the * offset of the dismissed trigger is held until {@link findMentionToken} * returns `null` — which is the adapter's cue to forget it. * * @param token the token found for the current caret, or `null` * @param dismissedAt the `start` of the token Escape closed, or `null` */ export declare function isMentionDismissed(token: MentionToken | null, dismissedAt: number | null): boolean; /** The field value and caret offset an insertion produces. */ export interface MentionInsertion { /** The whole field value with the token's range replaced. */ value: string; /** Caret offset just past the inserted text, and past the appended space when one was added. */ caret: number; } /** * Replaces a token's range with the serialized mention text. * * @param value the field value the token was found in * @param token the token being replaced, from {@link findMentionToken} * @param text the full replacement including the trigger character * @param appendSpace whether a single space follows the mention, skipped when the value already continues with whitespace */ export declare function insertMention(value: string, token: MentionToken, text: string, appendSpace?: boolean): MentionInsertion; /** The caret's position in viewport coordinates, as an adapter measured it. */ export interface CaretRect { /** Distance in pixels from the viewport's top edge to the caret's top. */ top: number; /** Distance in pixels from the viewport's left edge to the caret. */ left: number; /** The caret's height in pixels, normally the field's computed line height. */ height: number; } /** The rectangle floating-ui reads off a positioning reference. */ export interface AnchorRect { x: number; y: number; top: number; left: number; bottom: number; right: number; width: number; height: number; } /** A positioning reference that is a rectangle rather than an element. */ export interface VirtualAnchor { getBoundingClientRect(): AnchorRect; /** The element the rect lives inside, so floating-ui can observe ancestor scroll and resize. */ contextElement: Element; } /** * Wraps a caret measurement as the zero-width virtual anchor the popup is * positioned against. * * The measurement is re-read on every call, so one anchor survives a moved * caret without being rebuilt, and `contextElement` is what lets floating-ui * observe the ancestor scroll and resize that make it re-read. * * @param measure re-reads the caret rectangle, normally closing over a {@link MeasureCaretRect}, its field and the offset * @param contextElement the field the caret sits in */ export declare function caretAnchor(measure: () => CaretRect, contextElement: Element): VirtualAnchor; /** * The caret measurement each adapter implements with its own DOM work: the * viewport rectangle of the caret at `offset` inside `field`. */ export type MeasureCaretRect = (field: HTMLTextAreaElement | HTMLInputElement, offset: number) => CaretRect;