@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
30 lines (29 loc) • 1.16 kB
TypeScript
import React from "react";
export interface HighlighterProps {
label?: string;
searchValue?: string;
}
/**
* Returns a highlighted string according to the words of the search query.
* @param label The string to highlight.
* @param searchValue The mutli-word search query from which single words should be highlighted in the label.
*/
export declare function Highlighter({ label, searchValue }: HighlighterProps): React.JSX.Element;
/**
* Extracts search words separated by white space.
*/
declare function extractSearchWords(textQuery: string, toLowerCase?: boolean): string[];
/**
* Returns true if all search words are included in the given text
*/
declare function matchesAllWords(text: string, searchWords: string[]): boolean;
/**
* Creates a case-insensitive multi-word regex, that matches any of the given words.
*/
declare function createMultiWordRegex(multiWordQuery: string[], global?: boolean): RegExp;
export declare const highlighterUtils: {
extractSearchWords: typeof extractSearchWords;
matchesAllWords: typeof matchesAllWords;
createMultiWordRegex: typeof createMultiWordRegex;
};
export default Highlighter;