import { LitElement } from 'lit';
import { type HighlightNavigation } from './service.js';
/**
* The highlight component provides efficient searching and highlighting of text
* projected into it via its default slot. It uses the native CSS Custom Highlight API
* to apply highlight styles to matched text nodes without modifying the DOM.
*
* The component supports case-sensitive matching, programmatic navigation between
* matches, and automatic scroll-into-view of the active match.
*
* @element igc-highlight
*
* @slot - The default slot. Place the text content you want to search and highlight here.
*
* @cssproperty --foreground - The text color for a highlighted text node.
* @cssproperty --background - The background color for a highlighted text node.
* @cssproperty --foreground-active - The text color for the active highlighted text node.
* @cssproperty --background-active - The background color for the active highlighted text node.
*
* @example
* Basic usage — wrap your text and set the `search-text` attribute:
* ```html
*
*
*
* ```
*
* @example
* Navigating between matches programmatically:
* ```typescript
* const highlight = document.querySelector('igc-highlight');
*
* highlight.searchText = 'world';
* console.log(highlight.size); // total number of matches
* console.log(highlight.current); // index of the active match (0-based)
*
* highlight.next(); // move to the next match
* highlight.previous(); // move to the previous match
* highlight.setActive(2); // jump to a specific match by index
* ```
*
* @example
* Prevent scroll-into-view when navigating:
* ```typescript
* const highlight = document.querySelector('igc-highlight');
* highlight.next({ preventScroll: true });
* ```
*
* @example
* Re-run search after dynamic content changes (e.g. lazy-loaded text):
* ```typescript
* const highlight = document.querySelector('igc-highlight');
* // After slotted content has been updated:
* highlight.search();
* ```
*/
export default class IgcHighlightComponent extends LitElement {
static readonly tagName = "igc-highlight";
static styles: import("lit").CSSResult[];
static register(): void;
private readonly _service;
private _caseSensitive;
private _searchText;
/**
* Whether to match the searched text with case sensitivity in mind.
* When `true`, only exact-case occurrences of `searchText` are highlighted.
*
* @attr case-sensitive
* @default false
*/
set caseSensitive(value: boolean);
get caseSensitive(): boolean;
/**
* The string to search and highlight in the DOM content of the component.
* Setting this property triggers a new search automatically.
* An empty string clears all highlights.
*
* @attr search-text
*/
set searchText(value: string);
get searchText(): string;
/** The total number of matches found for the current `searchText`. Returns `0` when there are no matches or `searchText` is empty. */
get size(): number;
/** The zero-based index of the currently active (focused) match. Returns `0` when there are no matches. */
get current(): number;
constructor();
private _addStylesheet;
/**
* Moves the active highlight to the next match.
* Wraps around to the first match after the last one.
*
* @param options - Optional navigation options (e.g. `preventScroll`).
*/
next(options?: HighlightNavigation): void;
/**
* Moves the active highlight to the previous match.
* Wraps around to the last match when going back from the first one.
*
* @param options - Optional navigation options (e.g. `preventScroll`).
*/
previous(options?: HighlightNavigation): void;
/**
* Moves the active highlight to the match at the specified zero-based index.
*
* @param index - The zero-based index of the match to activate.
* @param options - Optional navigation options (e.g. `preventScroll`).
*/
setActive(index: number, options?: HighlightNavigation): void;
/**
* Re-runs the highlight search based on the current `searchText` and `caseSensitive` values.
*
* Call this method after the slotted content changes dynamically (e.g. after lazy loading
* or programmatic DOM mutations) to ensure all matches are up to date.
*/
search(): void;
protected render(): import("lit-html").TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'igc-highlight': IgcHighlightComponent;
}
}