UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

92 lines (87 loc) 3.38 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ 'use strict'; var index = require('./index-B0SElCD3.js'); var isNumber = require('./isNumber-CprvAKw5.js'); var isArray = require('./isArray-D5T3FFPp.js'); require('./isObjectLike-DYIul5Fz.js'); require('./global-C03WvntH.js'); const radioButtonCss = "slot-fb[hidden],slot[hidden]{display:initial !important}lar-button{margin:0.4rem 0}.radios{margin:0 1rem}"; const RadioButton = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.output = index.createEvent(this, "output"); this.request = index.createEvent(this, "request"); /////// 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.isNumber(data)) { this.selected = data; } else if (isArray.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 [ index.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 }, index.h("slot", { key: '28cf2813b01498b8a5ae7c1c2465728a164c0077' })) ]; } get el() { return index.getElement(this); } }; RadioButton.style = radioButtonCss; exports.lar_radio_button = RadioButton; //# sourceMappingURL=lar-radio-button.entry.cjs.js.map