UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

473 lines (472 loc) 16.7 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ const TIMEOUT = 600; import { h } from "@stencil/core"; import isBoolean from "lodash-es/isBoolean"; import isObject from "lodash-es/isObject"; export class TwoPosControllerNode { constructor() { /////// LarvaNode base properties /** * Component main icon */ this.icon = 'off'; /** * 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.fullState = {}; this.setPointEdit = 0; this.loading = true; } componentDidLoad() { const el = this.el.shadowRoot || this.el; this.node = el.querySelector('lar-node'); this.output.emit({ command: 'get' }); } /** * Larva error input */ async error(data) { if (this.node) { this.node.error(data); } this.loading = false; } /** * Input Larva event message (see above) */ async input(data) { if (isBoolean(data)) { this.fullState.outputValue = data; } else if (isObject(data)) { this.fullState = data; this.setPointEdit = this.fullState.setPoint; this.manualcontrols = !!this.fullState.manualControls; this.step = Number(this.fullState.step); this.min = Number(this.fullState.min); this.max = Number(this.fullState.max); } this.loading = false; } changeSetpoint(increase) { if (this.loading) { return; } const step = (this.step || 1) * (increase ? 1 : -1); this.setPointEdit = this.setPointEdit + step; if (this.max !== undefined && this.setPointEdit > this.max) { this.setPointEdit = this.max; } if (this.min !== undefined && this.setPointEdit < this.min) { this.setPointEdit = this.min; } // tslint:disable-next-line: strict-boolean-conditions if (this.timeout) { window.clearTimeout(this.timeout); this.timeout = null; } this.timeout = window.setTimeout(() => { this.loading = true; this.output.emit({ command: 'set', setPoint: this.setPointEdit }); this.timeout = null; }, TIMEOUT); } changeMode(mode) { if (this.loading) { return; } this.loading = true; this.output.emit({ command: 'mode', mode }); } render() { const value = String(this.fullState.inputValue || ''); const componentProps = { color: this.colorInputs || this.color, min: this.min, max: this.max, step: this.step, mode: this.fullState.mode, manualcontrols: !!this.fullState.manualControls, setpoint: this.setPointEdit, disabled: this.loading, onChangemode: (ev) => this.changeMode(ev.detail), onChangesetpoint: (ev) => this.changeSetpoint(ev.detail), }; return (h("lar-node", { key: '0234d5f376f60a99c298d49691581eee9a04af69', 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, loading: this.loading, log: this.log, nodeSize: this.nodeSize, component: "two-pos-controller-content", componentProps: componentProps }, h("slot", { key: '59b99abfc4b8fa172e851c1911db8215e2e72393' }))); } static get is() { return "lar-two-pos-controller"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["two-pos-controller.scss"] }; } static get styleUrls() { return { "$": ["two-pos-controller.css"] }; } static get properties() { return { "icon": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Component main icon" }, "getter": false, "setter": false, "reflect": false, "attribute": "icon", "defaultValue": "'off'" }, "color": { "type": "string", "mutable": true, "complexType": { "original": "Color", "resolved": "string", "references": { "Color": { "location": "import", "path": "../../interface", "id": "src/interface.d.ts::Color" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The color to use from your application's color palette.\nDetrouble options are: `\"primary\"`, `\"secondary\"`, `\"tertiary\"`, `\"success\"`, `\"warning\"`, `\"danger\"`, `\"light\"`, `\"medium\"`, and `\"dark\"`." }, "getter": false, "setter": false, "reflect": false, "attribute": "color", "defaultValue": "'primary'" }, "colorModal": { "type": "string", "mutable": true, "complexType": { "original": "Color", "resolved": "string", "references": { "Color": { "location": "import", "path": "../../interface", "id": "src/interface.d.ts::Color" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The color to use from your application's color palette for Components modal window." }, "getter": false, "setter": false, "reflect": false, "attribute": "color-modal" }, "colorInputs": { "type": "string", "mutable": true, "complexType": { "original": "Color", "resolved": "string", "references": { "Color": { "location": "import", "path": "../../interface", "id": "src/interface.d.ts::Color" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The color to use from your application's color palette for inputs" }, "getter": false, "setter": false, "reflect": false, "attribute": "color-inputs" }, "colorIconSmall": { "type": "string", "mutable": false, "complexType": { "original": "Color", "resolved": "string", "references": { "Color": { "location": "import", "path": "../../interface", "id": "src/interface.d.ts::Color" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The color to use from your application's color palette for indication icon" }, "getter": false, "setter": false, "reflect": false, "attribute": "color-icon-small" }, "hideTitles": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Hide node titles" }, "getter": false, "setter": false, "reflect": false, "attribute": "hide-titles" }, "supTitle": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Component superscript title" }, "getter": false, "setter": false, "reflect": false, "attribute": "sup-title" }, "subTitle": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Component subtitle" }, "getter": false, "setter": false, "reflect": false, "attribute": "sub-title" }, "log": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Is logging for this component enabled (lar-log subcomponent loaded)" }, "getter": false, "setter": false, "reflect": false, "attribute": "log", "defaultValue": "false" }, "mainTitle": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": true, "optional": false, "docs": { "tags": [], "text": "Component main title" }, "getter": false, "setter": false, "reflect": false, "attribute": "main-title" }, "nodeSize": { "type": "string", "mutable": false, "complexType": { "original": "Size", "resolved": "\"default\" | \"small\"", "references": { "Size": { "location": "import", "path": "../../interface", "id": "src/interface.d.ts::Size" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "Node size" }, "getter": false, "setter": false, "reflect": false, "attribute": "node-size", "defaultValue": "'default'" } }; } static get states() { return { "fullState": {}, "setPointEdit": {}, "loading": {}, "step": {}, "min": {}, "max": {}, "manualcontrols": {} }; } static get events() { return [{ "method": "output", "name": "output", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [{ "name": "see", "text": "{@link ../readme.md} chapter \"Components input and output\" for further information." }], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }, { "method": "request", "name": "request", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [{ "name": "see", "text": "{@link ../readme.md} chapter \"Sub-Components requests and responses\" for further information." }], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }]; } static get methods() { return { "error": { "complexType": { "signature": "(data: any) => Promise<void>", "parameters": [{ "name": "data", "type": "any", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "Larva error input", "tags": [] } }, "input": { "complexType": { "signature": "(data: boolean | TwoPosState) => Promise<void>", "parameters": [{ "name": "data", "type": "boolean | TwoPosState", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" }, "TwoPosState": { "location": "import", "path": "./two-pos-controller-interface", "id": "src/components/two-pos-controller/two-pos-controller-interface.tsx::TwoPosState" } }, "return": "Promise<void>" }, "docs": { "text": "Input Larva event message (see above)", "tags": [] } } }; } static get elementRef() { return "el"; } } //# sourceMappingURL=two-pos-controller.js.map