UNPKG

@sutton-signwriting/sgnw-components

Version:

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

63 lines (59 loc) 1.9 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 fswSignCss = ":host{direction:ltr}"; const FswSign = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); this.sgnw = window.sgnw; } connectedCallback() { if (!this.sign) { let sign = fsw.parse.sign(this.el.innerHTML); if (sign.style) { this.styling = style.compose(style.merge(style.parse(sign.style), style.parse(this.styling))); } sign.style = ""; this.sign = fsw.compose.sign(sign); } 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, { sign: this.sign, styling: this.styling, innerHTML: this.sgnw ? fsw$1.signSvg(this.sign + (styleStr)) : '' }, h("slot", null))); } get el() { return this; } static get style() { return fswSignCss; } }, [1, "fsw-sign", { "sign": [1537], "styling": [1537], "sgnw": [32] }]); function defineCustomElement() { if (typeof customElements === "undefined") { return; } const components = ["fsw-sign"]; components.forEach(tagName => { switch (tagName) { case "fsw-sign": if (!customElements.get(tagName)) { customElements.define(tagName, FswSign); } break; } }); } export { FswSign as F, defineCustomElement as d };