UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

118 lines (117 loc) 4.58 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ import { h } from "@stencil/core"; import map from "lodash-es/map"; import moment from "moment"; export class LogEntryList { constructor() { this.values = '[]'; this.measuringUnit = ''; this.webComponentValueType = ''; } render() { const values = JSON.parse(this.values); const months = values && Array.isArray(values) ? values : []; let latestMonth = months.length > 0 ? months[0] : null; if (latestMonth && latestMonth.date !== moment().format('MM-YYYY')) { latestMonth = null; } const entries = map(months, (month, key) => { return { start: h("lar-translate", { t: 'date.months.' + (moment(month.date, 'MM-YYYY').month() + 1) }), content: '', end: (h("div", null, h("small", null, month.abs), h("small", null, this.measuringUnit), " \u2022 ", h("small", null, "\u0394"), " ", month.rel, h("small", null, this.measuringUnit))), group: moment(month.date, 'MM-YYYY').format('YYYY') }; }); const header = latestMonth ? (h("div", null, h("lar-list-item", null, h("div", { slot: "start" }, h("strong", null, h("lar-translate", { t: "utilityMeter.currentMonthReading" }))), h("div", { slot: "end" }, h("small", null, latestMonth.abs, this.measuringUnit))), h("lar-list-item", null, h("div", { slot: "start" }, h("strong", null, h("lar-translate", { t: "utilityMeter.currentMonthUsage" }))), h("div", { slot: "end" }, h("small", null, latestMonth.rel, this.measuringUnit))))) : null; const groups = {}; return (h("lar-list", null, header, map(entries, entry => { // tslint:disable-next-line: no-shadowed-variable let header; if (!groups[entry.group]) { groups[entry.group] = entry.group; header = (h("lar-list-header", null, entry.group)); } return (h("div", null, header ? header : null, h("lar-list-item", null, h("div", { slot: "start" }, entry.start), h("div", null, entry.content), h("div", { slot: "end" }, entry.end)))); }))); } static get is() { return "lar-utility-log"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["utility-log.scss"] }; } static get styleUrls() { return { "$": ["utility-log.css"] }; } static get properties() { return { "values": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "reflect": false, "attribute": "values", "defaultValue": "'[]'" }, "measuringUnit": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "reflect": false, "attribute": "measuring-unit", "defaultValue": "''" }, "webComponentValueType": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "reflect": false, "attribute": "web-component-value-type", "defaultValue": "''" } }; } } //# sourceMappingURL=utility-log.js.map