@sutton-signwriting/sgnw-components
Version:
a javascript package of web components for use with the SignWriting script.
86 lines (79 loc) • 3.58 kB
JavaScript
/*!
* The Sutton SignWriting Web Components
*/
'use strict';
var index = require('./index-bYThyFO7.js');
var fsw = require('./fsw-BRgKY4JX.js');
var colorWatch = require('./color-watch-BMNbpkmB.js');
var fsw$1 = require('./fsw-jfoZGp9D.js');
const fswSignCss = () => `:host{direction:ltr}:host{transition:color 1ms, background-color 1ms}`;
const FswSign = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.sgnw = window.sgnw;
}
connectedCallback() {
this.colorWatch = new colorWatch.ColorWatch(this.el, this);
if (!this.sign) {
let sign = fsw.fswExports.parse.sign(this.el.innerHTML);
if (sign.style) {
this.styling = colorWatch.styleExports.compose(colorWatch.styleExports.merge(colorWatch.styleExports.parse(sign.style), colorWatch.styleExports.parse(this.styling)));
}
sign.style = "";
this.sign = fsw.fswExports.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 = colorWatch.styleExports.compose(colorWatch.styleExports.merge(index.cssValues(this.el), colorWatch.styleExports.parse(this.styling)));
return (index.h(index.Host, { key: '569666a6b261005ca3f9219e6320b6729824c420', sign: this.sign, styling: this.styling, innerHTML: this.sgnw ? fsw$1.fswExports.signSvg(this.sign + (styleStr)) : '' }, index.h("slot", { key: 'b53feac3a744d011833be0e65e3927c92ca6f63f' })));
}
get el() { return index.getElement(this); }
};
FswSign.style = fswSignCss();
const fswSymbolCss = () => `:host{transition:color 1ms, background-color 1ms}`;
const FswSymbol = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.sgnw = window.sgnw;
}
connectedCallback() {
this.colorWatch = new colorWatch.ColorWatch(this.el, this);
if (!this.symbol) {
let symbol = fsw.fswExports.parse.symbol(this.el.innerHTML);
if (symbol.style) {
this.styling = colorWatch.styleExports.compose(colorWatch.styleExports.merge(colorWatch.styleExports.parse(symbol.style), colorWatch.styleExports.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);
}
}
disconnectedCallback() {
this.colorWatch.dispose();
}
render() {
const styleStr = colorWatch.styleExports.compose(colorWatch.styleExports.merge(index.cssValues(this.el), colorWatch.styleExports.parse(this.styling)));
return (index.h(index.Host, { key: '86f20d62b1a9c98b90474a9ec054a76ee3a2d1b9', symbol: this.symbol, styling: this.styling, innerHTML: this.sgnw ? fsw$1.fswExports.symbolSvg(this.symbol + (styleStr)) : '' }, index.h("slot", { key: '526c8016004ba63407640a123475c6a9e3b48041' })));
}
get el() { return index.getElement(this); }
};
FswSymbol.style = fswSymbolCss();
exports.fsw_sign = FswSign;
exports.fsw_symbol = FswSymbol;