UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

430 lines (429 loc) 14.9 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ import { h } from "@stencil/core"; import isNumber from "lodash-es/isNumber"; import isArray from "lodash-es/isArray"; export class RadioButton { constructor() { /////// LarvaNode base properties /** * Component main icon */ this.icon = 'device'; /** * 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; } componentDidLoad() { const el = this.el.shadowRoot || this.el; this.node = el.querySelector('lar-node'); this.output.emit(); // get selected this.output.emit({ command: 'get_radio_list' }); } /** * Larva error input */ async error(data) { if (this.node) { this.node.error(data); } this.loading = false; } /** * Input Larva event message (see abow) */ async input(data) { if (isNumber(data)) { this.selected = data; } else if (isArray(data)) { this.radios = data; } if (this.radios !== undefined && this.selected !== undefined) { this.loading = false; } } selectOption(index) { this.loading = true; this.output.emit(index); } render() { const value = (this.radios !== undefined && this.selected !== undefined) ? this.radios[this.selected].name : ''; const componentProps = { onSelectoption: (e) => this.selectOption(e.detail), disabled: this.loading, color: this.colorInputs || this.color, radios: this.radios, selected: this.selected }; return [ h("lar-node", { key: 'e530ec17a9eed4cc5179d33322d231ecdfb4e7ee', icon: this.icon, hideTitles: this.hideTitles, color: this.color, supTitle: this.supTitle, mainTitle: this.mainTitle, subTitle: this.subTitle, colorModal: this.colorModal, colorInputs: this.colorInputs, colorIconSmall: this.colorIconSmall, value: value, log: this.log, loading: this.loading, nodeSize: this.nodeSize, component: "lar-radio-button-content", componentProps: componentProps }, h("slot", { key: '28cf2813b01498b8a5ae7c1c2465728a164c0077' })) ]; } static get is() { return "lar-radio-button"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["radio-button.scss"] }; } static get styleUrls() { return { "$": ["radio-button.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": "'device'" }, "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 { "loading": {}, "selected": {}, "radios": {} }; } 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: any) => Promise<void>", "parameters": [{ "name": "data", "type": "any", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "Input Larva event message (see abow)", "tags": [] } } }; } static get elementRef() { return "el"; } } //# sourceMappingURL=radio-button.js.map