@larva.io/webcomponents
Version:
Fentrica SmartUnits WebComponents package
54 lines (49 loc) • 2.07 kB
JavaScript
/*!
* (C) Fentrica http://fentrica.com - Seee LICENSE.md
*/
'use strict';
var index = require('./index-B0SElCD3.js');
const radioButtonCss = "slot-fb[hidden].sc-lar-radio-button-content,slot[hidden].sc-lar-radio-button-content{display:initial !important}lar-button.sc-lar-radio-button-content{margin:0.4rem 0}.radios.sc-lar-radio-button-content{margin:0 1rem}";
const RadioButtonContent = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.selectoption = index.createEvent(this, "selectoption");
this.radios = [];
}
getRadios() {
if (typeof this.radios === 'string') {
try {
return JSON.parse(this.radios);
}
catch (e) {
return [];
}
}
return Array.isArray(this.radios) ? this.radios : [];
}
getSelected() {
const selected = typeof this.selected === 'string' ? parseInt(this.selected, 10) : this.selected;
return isNaN(selected) ? undefined : selected;
}
render() {
const selectors = [];
const radios = this.getRadios();
const selected = this.getSelected();
if (!radios || !Array.isArray(radios) || selected === undefined) {
return selectors;
}
for (let i = 0; i < radios.length; i++) {
if (!radios[i] || !radios[i].name) {
continue;
}
const option = radios[i].name;
const secondaryColor = this.color === 'dark' ? 'light' : 'dark';
const color = (i === selected) ? this.color : secondaryColor;
selectors.push(index.h("lar-button", { expand: "full", color: color, disabled: this.disabled, onClick: () => this.selectoption.emit(i) }, index.h("lar-translate", { t: option })));
}
return index.h("div", { class: "radios" }, selectors);
}
};
RadioButtonContent.style = radioButtonCss;
exports.lar_radio_button_content = RadioButtonContent;
//# sourceMappingURL=lar-radio-button-content.entry.cjs.js.map