igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
59 lines (58 loc) • 2.07 kB
TypeScript
import { type ReactiveController } from 'lit';
import type IgcHighlightComponent from './highlight.js';
/**
* Options for controlling navigation behavior when moving the active highlight.
*/
export type HighlightNavigation = {
/** If true, prevents the component from scrolling the new active match into view. */
preventScroll?: boolean;
};
declare class HighlightService implements ReactiveController {
private readonly _host;
private readonly _id;
private readonly _activeId;
private readonly _styles;
private readonly _styleSheet?;
private _highlight;
private _activeHighlight;
private _ranges;
private _current;
/**
* The total number of matches found in the component's content.
*/
get size(): number;
/**
* The index of the currently active match. Returns 0 if there are no matches.
*/
get current(): number;
constructor(host: IgcHighlightComponent);
/** @internal */
hostConnected(): void;
/** @internal */
hostDisconnected(): void;
private _removeStyleSheet;
private _createHighlightEntries;
private _removeHighlightEntries;
private _createRegex;
private _updateActiveHighlight;
private _goTo;
/**
* Attaches the service's stylesheet to the render root.
* Necessary for the component to apply highlight styles to its content.
*/
attachStylesheet(): void;
/**
* Finds matches for the given search text in the component's content and creates highlight ranges for them.
*/
find(value: string): void;
/** Moves the active state to the next match. */
next(options?: HighlightNavigation): void;
/** Moves the active state to the previous match. */
previous(options?: HighlightNavigation): void;
/** Moves the active state to the given index. */
setActive(index: number, options?: HighlightNavigation): void;
/** Clears highlight collections. */
clear(): void;
}
export declare function createHighlightController(host: IgcHighlightComponent): HighlightService;
export {};