ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
53 lines (52 loc) • 1.88 kB
JavaScript
import { a, n as i, o as r, r as n, t as h } from "./utils-D1iZnChu.js";
import { i as o, m as l } from "./factory-ZNhcQ4tf.js";
import { a as c, n as m } from "./ssr-DSGwPtEd.js";
var d = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-math-position, relative)}.ran-math{display:var(--ran-math-display, flex);justify-content:var(--ran-math-justify-content, space-around);align-items:var(--ran-math-align-items, center)}.katex-html{display:var(--ran-math-katex-display, none)}", u = class extends m {
contain;
_shadowDom;
static get observedAttributes() {
return ["latex", "sheet"];
}
constructor() {
super(), this._shadowDom = i(this, d);
const t = h(this._shadowDom, ".ran-math", () => o().class("ran-math").build());
this.contain = t;
}
get latex() {
const t = n(this, "latex");
return decodeURIComponent(t);
}
set latex(t) {
a(this, "latex", t);
}
get sheet() {
return n(this, "sheet");
}
set sheet(t) {
a(this, "sheet", t);
}
handlerExternalCss = () => {
r(this, this._shadowDom, "sheet", null, this.sheet);
};
render() {
this.latex && import("./katex-es-CKRwcaiU.js").then((t) => {
if (this.contain.innerHTML = "", this.latex) {
const e = l().text(`$$${this.latex}$$`).build();
this.contain.appendChild(e), t.renderMathInElement(this.contain);
}
}).catch(function(t) {
console.warn(`ranui math component warning: ${t.message}
${t}`);
});
}
connectedCallback() {
this.handlerExternalCss(), this.render();
}
attributeChangedCallback(t, e, s) {
e !== s && (t === "latex" && this.render(), t === "sheet" && this.handlerExternalCss());
}
};
c("r-math", u);
export {
u as t
};