UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

188 lines (183 loc) 6.8 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ import { p as proxyCustomElement, H, c as createEvent, h } from './p-AOwgnAK2.js'; import { h as hooks } from './p-DAuPur-P.js'; import { a as isObject } from './p-Cvhpe3ZV.js'; import { d as defineCustomElement$8 } from './p-B7x5gzZv.js'; import { d as defineCustomElement$7 } from './p-C9VBtzS4.js'; import { d as defineCustomElement$6 } from './p-9A4J2Z7t.js'; import { d as defineCustomElement$5 } from './p-Dsy6MkCW.js'; import { d as defineCustomElement$4 } from './p-CNwVOfNs.js'; import { d as defineCustomElement$3 } from './p-Bk24sn12.js'; import { d as defineCustomElement$2 } from './p-B-fmI6sr.js'; const utilityMeterCss = "slot-fb[hidden],slot[hidden]{display:initial !important}"; const UtilityMeter = /*@__PURE__*/ proxyCustomElement(class UtilityMeter extends H { constructor(registerHost) { super(); if (registerHost !== false) { this.__registerHost(); } this.__attachShadow(); this.output = createEvent(this, "output"); this.request = createEvent(this, "request"); /////// LarvaNode base properties /** * Component main icon */ this.icon = 'chart-bar'; /** * The color to use from your application's color palette. * Detrouble options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. */ this.color = 'primary'; /** * Is logging for this component enabled (lar-log subcomponent loaded) */ this.log = false; /** * Node size */ this.nodeSize = 'default'; /////// LarvaNode base properties and events - end this.loading = true; this.values = []; this.measuringUnit = ''; this.webComponentValueType = 'abs'; } /** * Larva error input */ async error(data) { if (this.node) { this.node.error(data); } this.loading = false; } /** * Larva input message */ async input(state) { this.loading = false; if (isObject(state) && state.months) { this.values = state.months; // tslint:disable-next-line: strict-boolean-conditions if (state.webComponentValueType) { this.webComponentValueType = state.webComponentValueType; } // tslint:disable-next-line: strict-boolean-conditions if (state.measuringUnit) { this.measuringUnit = state.measuringUnit; } } } componentDidLoad() { const el = this.el.shadowRoot || this.el; this.node = el.querySelector('lar-node'); this.loading = true; this.output.emit(); } render() { const months = this.values && Array.isArray(this.values) ? this.values : []; let latestMonth = months.length > 0 ? months[0] : null; if (latestMonth && latestMonth.date !== hooks().format('MM-YYYY')) { latestMonth = null; } let value; switch (this.webComponentValueType) { case 'abs': { if (latestMonth) { value = `${latestMonth.abs}${this.measuringUnit}`; } break; } case 'rel': { if (latestMonth) { value = `${latestMonth.rel}${this.measuringUnit}`; } break; } // none } const componentProps = { measuringUnit: this.measuringUnit, webComponentValueType: this.webComponentValueType, values: JSON.stringify(this.values) }; return [ h("lar-node", { key: '4c80ddb0e20874f545b46ece6fcecd57792b905b', value: value, hideTitles: this.hideTitles, icon: this.icon, color: this.color, supTitle: this.supTitle, mainTitle: this.mainTitle, subTitle: this.subTitle, colorModal: this.colorModal, colorInputs: this.colorInputs, colorIconSmall: this.colorIconSmall, log: this.log, loading: this.loading, nodeSize: this.nodeSize, component: "lar-utility-log", componentProps: componentProps }, h("slot", { key: 'b62a3056f604be88b50df3d2caf9fae2a7fc5433' })) ]; } get el() { return this; } static get style() { return utilityMeterCss; } }, [257, "lar-utility-meter", { "icon": [1025], "color": [1025], "colorModal": [1025, "color-modal"], "colorInputs": [1025, "color-inputs"], "colorIconSmall": [1, "color-icon-small"], "hideTitles": [4, "hide-titles"], "supTitle": [1, "sup-title"], "subTitle": [1, "sub-title"], "log": [4], "mainTitle": [1, "main-title"], "nodeSize": [1, "node-size"], "loading": [32], "values": [32], "error": [64], "input": [64] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["lar-utility-meter", "lar-backdrop", "lar-icon", "lar-modal", "lar-node", "lar-node-titles", "lar-notify", "lar-translate"]; components.forEach(tagName => { switch (tagName) { case "lar-utility-meter": if (!customElements.get(tagName)) { customElements.define(tagName, UtilityMeter); } break; case "lar-backdrop": if (!customElements.get(tagName)) { defineCustomElement$8(); } break; case "lar-icon": if (!customElements.get(tagName)) { defineCustomElement$7(); } break; case "lar-modal": if (!customElements.get(tagName)) { defineCustomElement$6(); } break; case "lar-node": if (!customElements.get(tagName)) { defineCustomElement$5(); } break; case "lar-node-titles": if (!customElements.get(tagName)) { defineCustomElement$4(); } break; case "lar-notify": if (!customElements.get(tagName)) { defineCustomElement$3(); } break; case "lar-translate": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; } }); } defineCustomElement$1(); const LarUtilityMeter = UtilityMeter; const defineCustomElement = defineCustomElement$1; export { LarUtilityMeter, defineCustomElement }; //# sourceMappingURL=lar-utility-meter.js.map //# sourceMappingURL=lar-utility-meter.js.map