UNPKG

@sutton-signwriting/sgnw-components

Version:

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

62 lines (58 loc) 1.88 kB
/*! * The Sutton SignWriting Web Components */ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client'; import { f as fsw } from './fsw2.js'; import { s as style } from './style.js'; import { f as fsw$1 } from './fsw.js'; import { c as cssValues } from './global.js'; const fswSymbolCss = ""; const FswSymbol = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); this.sgnw = window.sgnw; } connectedCallback() { if (!this.symbol) { let symbol = fsw.parse.symbol(this.el.innerHTML); if (symbol.style) { this.styling = style.compose(style.merge(style.parse(symbol.style), style.parse(this.styling))); } this.symbol = 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 ? fsw$1.symbolSvg(this.symbol + (styleStr)) : '' }, h("slot", null))); } get el() { return this; } static get style() { return fswSymbolCss; } }, [1, "fsw-symbol", { "symbol": [1537], "styling": [1537], "sgnw": [32] }]); function defineCustomElement() { if (typeof customElements === "undefined") { return; } const components = ["fsw-symbol"]; components.forEach(tagName => { switch (tagName) { case "fsw-symbol": if (!customElements.get(tagName)) { customElements.define(tagName, FswSymbol); } break; } }); } export { FswSymbol as F, defineCustomElement as d };