UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

52 lines (48 loc) 2.06 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ import { r as registerInstance, c as createEvent, h } from './index-C4h1muVj.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) { registerInstance(this, hostRef); this.selectoption = 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(h("lar-button", { expand: "full", color: color, disabled: this.disabled, onClick: () => this.selectoption.emit(i) }, h("lar-translate", { t: option }))); } return h("div", { class: "radios" }, selectors); } }; RadioButtonContent.style = radioButtonCss; export { RadioButtonContent as lar_radio_button_content }; //# sourceMappingURL=lar-radio-button-content.entry.js.map