UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

24 lines (23 loc) 585 B
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import { html } from "lit"; import { safeClassMap } from "@arcgis/lumina"; const CSS = { textMatch: "text-match" }; function capitalizeWord(word) { return word.charAt(0).toUpperCase() + word.slice(1); } function highlightText({ text, pattern }) { if (!pattern || !text) { return text; } const parts = text.split(pattern); if (parts.length > 1) { parts[1] = html`<mark class=${safeClassMap(CSS.textMatch)}>${parts[1]}</mark>`; } return parts; } export { capitalizeWord as c, highlightText as h };