@sutton-signwriting/sgnw-components
Version:
a javascript package of web components for use with the SignWriting script.
81 lines (73 loc) • 2.8 kB
JavaScript
/*!
* The Sutton SignWriting Web Components
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const _commonjsHelpers = require('./_commonjsHelpers-9aed4453.js');
const fsw = require('./fsw-d1b88fb6.js');
const style = require('./style-49616a98.js');
const fsw$1 = require('./fsw-e69767e7.js');
const global = require('./global-8a256890.js');
const fswSignCss = ":host{direction:ltr}";
const FswSign = class {
constructor(hostRef) {
_commonjsHelpers.registerInstance(this, hostRef);
this.sgnw = window.sgnw;
}
connectedCallback() {
if (!this.sign) {
let sign = fsw.fsw.parse.sign(this.el.innerHTML);
if (sign.style) {
this.styling = style.style.compose(style.style.merge(style.style.parse(sign.style), style.style.parse(this.styling)));
}
sign.style = "";
this.sign = fsw.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.style.compose(style.style.merge(global.cssValues(this.el), style.style.parse(this.styling)));
return (_commonjsHelpers.h(_commonjsHelpers.Host, { sign: this.sign, styling: this.styling, innerHTML: this.sgnw ? fsw$1.fsw.signSvg(this.sign + (styleStr)) : '' }, _commonjsHelpers.h("slot", null)));
}
get el() { return _commonjsHelpers.getElement(this); }
};
FswSign.style = fswSignCss;
const fswSymbolCss = "";
const FswSymbol = class {
constructor(hostRef) {
_commonjsHelpers.registerInstance(this, hostRef);
this.sgnw = window.sgnw;
}
connectedCallback() {
if (!this.symbol) {
let symbol = fsw.fsw.parse.symbol(this.el.innerHTML);
if (symbol.style) {
this.styling = style.style.compose(style.style.merge(style.style.parse(symbol.style), 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.style.compose(style.style.merge(global.cssValues(this.el), style.style.parse(this.styling)));
return (_commonjsHelpers.h(_commonjsHelpers.Host, { symbol: this.symbol, styling: this.styling, innerHTML: this.sgnw ? fsw$1.fsw.symbolSvg(this.symbol + (styleStr)) : '' }, _commonjsHelpers.h("slot", null)));
}
get el() { return _commonjsHelpers.getElement(this); }
};
FswSymbol.style = fswSymbolCss;
exports.fsw_sign = FswSign;
exports.fsw_symbol = FswSymbol;