UNPKG

@synergy-design-system/components

Version:

This package provides the base of the Synergy Design System as native web components. It uses [lit](https://www.lit.dev) and parts of [shoelace](https://shoelace.style/). Synergy officially supports the latest two versions of all major browsers (as define

27 lines (25 loc) 1.07 kB
// src/components/combobox/option-renderer.ts import "lit"; var defaultOptionRenderer = (option) => option; var highlightOptionRenderer = (option, query) => { if (!query) { return option; } const clonedOption = option.cloneNode(true); const optionLabel = clonedOption.getTextLabel(); const queryIndex = optionLabel.toLowerCase().indexOf(query.toLowerCase()); const indexLabel = clonedOption.innerHTML.indexOf(optionLabel); const mark = document.createElement("mark"); mark.textContent = optionLabel.slice(queryIndex, queryIndex + query.length); mark.classList.add("syn-highlight-style"); const exchangedText = optionLabel.replace(new RegExp(query, "i"), mark.outerHTML); const previousContent = clonedOption.innerHTML.slice(0, indexLabel); const followingContent = clonedOption.innerHTML.slice(indexLabel + optionLabel.length); clonedOption.innerHTML = previousContent.concat(exchangedText, followingContent); return clonedOption; }; export { defaultOptionRenderer, highlightOptionRenderer }; //# sourceMappingURL=chunk.HVVPX2VA.js.map