UNPKG

@sutton-signwriting/sgnw-components

Version:

a javascript package of web components for use with the SignWriting script.

63 lines (59 loc) 1.93 kB
/*! * The Sutton SignWriting Web Components */ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client'; import { s as swu } from './swu2.js'; import { s as style } from './style.js'; import { s as swu$1 } from './swu.js'; import { c as cssValues } from './global.js'; const sgnwSymbolCss = ""; const SgnwSymbol = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); this.sgnw = window.sgnw; } connectedCallback() { if (!this.symbol) { let symbol = swu.parse.symbol(this.el.innerHTML); if (symbol.style) { this.styling = style.compose(style.merge(style.parse(symbol.style), style.parse(this.styling))); } symbol.style = ""; this.symbol = swu.compose.symbol(symbol); } if (!this.sgnw) { let self = this; function handleSgnw() { self.sgnw = window.sgnw; window.removeEventListener("sgnw", handleSgnw, false); } window.addEventListener('sgnw', handleSgnw, false); } } render() { const styleStr = style.compose(style.merge(cssValues(this.el), style.parse(this.styling))); return (h(Host, { symbol: this.symbol, styling: this.styling, innerHTML: this.sgnw ? swu$1.symbolSvg(this.symbol + (styleStr)) : '' }, h("slot", null))); } get el() { return this; } static get style() { return sgnwSymbolCss; } }, [1, "sgnw-symbol", { "symbol": [1537], "styling": [1537], "sgnw": [32] }]); function defineCustomElement() { if (typeof customElements === "undefined") { return; } const components = ["sgnw-symbol"]; components.forEach(tagName => { switch (tagName) { case "sgnw-symbol": if (!customElements.get(tagName)) { customElements.define(tagName, SgnwSymbol); } break; } }); } export { SgnwSymbol as S, defineCustomElement as d };