UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

91 lines (86 loc) 3.4 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ import { p as proxyCustomElement, H, c as createEvent, h } from './p-AOwgnAK2.js'; import { d as defineCustomElement$3 } from './p-BiG3U7GV.js'; import { d as defineCustomElement$2 } from './p-B-fmI6sr.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 = /*@__PURE__*/ proxyCustomElement(class RadioButtonContent extends H { constructor(registerHost) { super(); if (registerHost !== false) { this.__registerHost(); } 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); } static get style() { return radioButtonCss; } }, [258, "lar-radio-button-content", { "color": [1], "disabled": [4], "value": [1], "radios": [1], "selected": [8] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["lar-radio-button-content", "lar-button", "lar-translate"]; components.forEach(tagName => { switch (tagName) { case "lar-radio-button-content": if (!customElements.get(tagName)) { customElements.define(tagName, RadioButtonContent); } break; case "lar-button": if (!customElements.get(tagName)) { defineCustomElement$3(); } break; case "lar-translate": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; } }); } defineCustomElement$1(); const LarRadioButtonContent = RadioButtonContent; const defineCustomElement = defineCustomElement$1; export { LarRadioButtonContent, defineCustomElement }; //# sourceMappingURL=lar-radio-button-content.js.map //# sourceMappingURL=lar-radio-button-content.js.map