UNPKG

@peculiar/fortify-webcomponents

Version:

Web-components for creating CSR or Certificate and viewing certificates list using Fortify

62 lines (58 loc) 2.23 kB
/*! * © Peculiar Ventures https://peculiarventures.com/ - BSD 3-Clause License */ import { proxyCustomElement, HTMLElement, h, Host, transformTag } from '@stencil/core/internal/client'; const highlightWordsCss = () => `:host{display:inline}::slotted(mark){background-color:var(--pv-color-attention-tint-4)}`; const HighlightWords = /*@__PURE__*/ proxyCustomElement(class HighlightWords extends HTMLElement { constructor(registerHost) { super(); if (registerHost !== false) { this.__registerHost(); } this.__attachShadow(); this.tag = 'mark'; } 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: '95b1cef18522eabfb495710d6756d8eee86dfa73' }, h("slot", { key: '360e1c4d7121833dbfccdd6e1021d2030017373b' }))); } get host() { return this; } static get style() { return highlightWordsCss(); } }, [257, "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(transformTag(tagName))) { customElements.define(transformTag(tagName), HighlightWords); } break; } }); } export { HighlightWords as H, defineCustomElement as d }; //# sourceMappingURL=highlight-words.js.map //# sourceMappingURL=highlight-words.js.map