@peculiar/fortify-webcomponents
Version:
Web-components for creating CSR or Certificate and viewing certificates list using Fortify
61 lines (57 loc) • 2.17 kB
JavaScript
/*!
* © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License
*/
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
const highlightWordsCss = ":host{display:inline}::slotted(mark){background-color:var(--pv-color-attention-tint-4)}";
const PeculiarHighlightWordsStyle0 = highlightWordsCss;
const HighlightWords = /*@__PURE__*/ proxyCustomElement(class HighlightWords extends HTMLElement {
constructor() {
super();
this.__registerHost();
this.__attachShadow();
this.tag = 'mark';
this.search = undefined;
}
componentDidLoad() {
this.handleHighlightSearch();
}
componentDidUpdate() {
this.handleHighlightSearch();
}
handleHighlightSearch() {
const basicString = this.resetHighlightSearch(this.host.innerHTML);
let result = basicString;
if (this.search) {
const substring = new RegExp(`(${this.search})`, 'gi');
result = basicString.replace(substring, `<${this.tag}>$1</${this.tag}>`);
}
this.host.innerHTML = result;
}
resetHighlightSearch(source) {
// eslint-disable-next-line no-useless-escape
const substring = new RegExp(`<\/?${this.tag}>`, 'g');
return source.replace(substring, '');
}
render() {
return (h(Host, { key: '353abad7e2fc43ea4af75ec025e08d2ff3159ee6' }, h("slot", { key: '9ac44c0a2b95ea7a778e2d6a2909c797f8c17b6d' })));
}
get host() { return this; }
static get style() { return PeculiarHighlightWordsStyle0; }
}, [1, "peculiar-highlight-words", {
"search": [1]
}]);
function defineCustomElement() {
if (typeof customElements === "undefined") {
return;
}
const components = ["peculiar-highlight-words"];
components.forEach(tagName => { switch (tagName) {
case "peculiar-highlight-words":
if (!customElements.get(tagName)) {
customElements.define(tagName, HighlightWords);
}
break;
} });
}
export { HighlightWords as H, defineCustomElement as d };
//# sourceMappingURL=highlight-words.js.map