@sutton-signwriting/sgnw-components
Version:
a javascript package of web components for use with the SignWriting script.
84 lines (78 loc) • 3.48 kB
JavaScript
/*!
* The Sutton SignWriting Web Components
*/
import { r as registerInstance, f as cssValues, d as h, H as Host, e as getElement } from './index-BAJUTSOF.js';
import { s as swuExports } from './swu-CKUP3WBD.js';
import { C as ColorWatch, s as styleExports } from './color-watch-DoznaU7s.js';
import { s as swuExports$1 } from './swu-B5gdK0rg.js';
const sgnwSignCss = () => `:host{direction:ltr}:host{transition:color 1ms, background-color 1ms}`;
const SgnwSign = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.sgnw = window.sgnw;
}
connectedCallback() {
this.colorWatch = new ColorWatch(this.el, this);
if (!this.sign) {
let sign = swuExports.parse.sign(this.el.innerHTML);
if (sign.style) {
this.styling = styleExports.compose(styleExports.merge(styleExports.parse(sign.style), styleExports.parse(this.styling)));
}
sign.style = "";
this.sign = swuExports.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);
}
}
disconnectedCallback() {
this.colorWatch.dispose();
}
render() {
const styleStr = styleExports.compose(styleExports.merge(cssValues(this.el), styleExports.parse(this.styling)));
return (h(Host, { key: 'cc1ffd2004b25f139c6c0a6fc13884f9a40ef33d', sign: this.sign, styling: this.styling, innerHTML: this.sgnw ? swuExports$1.signSvg(this.sign + (styleStr)) : '' }, h("slot", { key: 'a02cce53502a3b97fbb13ce40d88aebdb34e2fc1' })));
}
get el() { return getElement(this); }
};
SgnwSign.style = sgnwSignCss();
const sgnwSymbolCss = () => `:host{transition:color 1ms, background-color 1ms}`;
const SgnwSymbol = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.sgnw = window.sgnw;
}
connectedCallback() {
this.colorWatch = new ColorWatch(this.el, this);
if (!this.symbol) {
let symbol = swuExports.parse.symbol(this.el.innerHTML);
if (symbol.style) {
this.styling = styleExports.compose(styleExports.merge(styleExports.parse(symbol.style), styleExports.parse(this.styling)));
}
symbol.style = "";
this.symbol = swuExports.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);
}
}
disconnectedCallback() {
this.colorWatch.dispose();
}
render() {
const styleStr = styleExports.compose(styleExports.merge(cssValues(this.el), styleExports.parse(this.styling)));
return (h(Host, { key: 'bd85ac33f6f31f16132489252f04c981433edc78', symbol: this.symbol, styling: this.styling, innerHTML: this.sgnw ? swuExports$1.symbolSvg(this.symbol + (styleStr)) : '' }, h("slot", { key: '082c6e15c0f121f3ba97d91b70f73979414c8b7a' })));
}
get el() { return getElement(this); }
};
SgnwSymbol.style = sgnwSymbolCss();
export { SgnwSign as sgnw_sign, SgnwSymbol as sgnw_symbol };