UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

26 lines (25 loc) 704 B
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details. v3.2.1 */ import { html } from "lit-html"; 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 };