@llselect/core
Version:
Low-level select: a minimal, flexible, framework-agnostic replacement for the native HTML select element.
23 lines • 1.43 kB
TypeScript
/**
* Build a detached `<span>` of `text` with every `query` match wrapped for
* highlighting.
* - Each case-insensitive occurrence of `query` becomes a `<mark>` element;
* everything else stays plain text nodes.
* - Matching mirrors the built-in filter exactly: `toLowerCase` on both
* sides, no trimming, scanned left to right without overlap.
* - If `query` is `''`, the span holds the plain text and no `<mark>`.
* - `createMatchElFn` replaces the default `<mark>` builder. It receives the
* matched text and must return a fully built element: the helper inserts
* it as-is and does not put the text inside for you.
* - If a custom `filterFn` drives your matching, the helper cannot know its
* match ranges: it always marks plain substring occurrences.
* - Intended for `createItemContentElFn` / `createItemContentEl`: they re-run
* on every filter keystroke, so the marks stay in sync with the query. The
* option's accessible name is unaffected (it comes from `itemToString`).
* - Rare edge: if lower-casing changes the string's length (a Unicode
* expansion, e.g. dotted capital I, U+0130), the span degrades to plain
* unmarked text instead of marking wrong ranges.
* @group Filtering
*/
export declare function createHighlightedTextEl(text: string, query: string, createMatchElFn?: (matchedText: string) => HTMLElement): HTMLElement;
//# sourceMappingURL=query-highlight.d.ts.map