@nent/core
Version:
56 lines (52 loc) • 1.72 kB
JavaScript
/*!
* NENT 2022
*/
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { C as CommonStateSubscriber } from './state-subscriber.js';
import { D as DATA_EVENTS } from './interfaces3.js';
import { R as ROUTE_EVENTS } from './interfaces4.js';
import { a as state } from './state.js';
const ContentShow = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
constructor() {
super();
this.__registerHost();
this.show = false;
}
componentWillLoad() {
this.dataSubscription = new CommonStateSubscriber(this, 'dataEnabled', DATA_EVENTS.DataChanged);
this.routeSubscription = new CommonStateSubscriber(this, 'routingEnabled', ROUTE_EVENTS.RouteChanged);
}
async componentWillRender() {
if (state.dataEnabled) {
const { evaluatePredicate } = await import('./expressions.js').then(function (n) { return n.f; });
this.show = await evaluatePredicate(this.when);
}
}
disconnectedCallback() {
this.dataSubscription.destroy();
this.routeSubscription.destroy();
}
render() {
return (h(Host, { hidden: !this.show }, h("slot", null)));
}
get el() { return this; }
}, [4, "n-content-show", {
"when": [1],
"show": [32]
}]);
function defineCustomElement$1() {
if (typeof customElements === "undefined") {
return;
}
const components = ["n-content-show"];
components.forEach(tagName => { switch (tagName) {
case "n-content-show":
if (!customElements.get(tagName)) {
customElements.define(tagName, ContentShow);
}
break;
} });
}
const NContentShow = ContentShow;
const defineCustomElement = defineCustomElement$1;
export { NContentShow, defineCustomElement };