@larva.io/webcomponents
Version:
Fentrica SmartUnits WebComponents package
90 lines (86 loc) • 3.37 kB
JavaScript
/*!
* (C) Fentrica http://fentrica.com - Seee LICENSE.md
*/
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-C4h1muVj.js';
import { i as isNumber } from './isNumber-hN3DcWii.js';
import { i as isArray } from './isArray-C_HhfJYh.js';
import './isObjectLike-CIR68wtF.js';
import './global-C56buD75.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) {
registerInstance(this, hostRef);
this.output = createEvent(this, "output");
this.request = 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(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' }))
];
}
get el() { return getElement(this); }
};
RadioButton.style = radioButtonCss;
export { RadioButton as lar_radio_button };
//# sourceMappingURL=lar-radio-button.entry.js.map