UNPKG

pyro

Version:
64 lines (63 loc) 2.04 kB
import { i as u, r as h, x as f, t as c } from "./custom-element-CWJsDAat.js"; import { n as p } from "./property-Bf-I6Ep_.js"; import { o as n } from "./query-assigned-elements-DjfhL1cl.js"; import { f as b } from "./findDeepChildren-DcrW2E5D.js"; var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, s = (r, e, i, a) => { for (var o = a > 1 ? void 0 : a ? y(e, i) : e, d = r.length - 1, l; d >= 0; d--) (l = r[d]) && (o = (a ? l(e, i, o) : l(o)) || o); return a && o && v(e, i, o), o; }; let t = class extends h { constructor() { super(...arguments), this.name = "", this.value = "", this.square = !1, this._radios = []; } firstUpdated() { this._radios = b(this._slotElements, "pyro-radio"), this._radios.forEach((r) => { r.value === this.value && (r.checked = !0); }), this._radios.forEach((r) => { r.setAttribute("name", this.name); }); } handleRadioClick({ target: r }) { this._radios.forEach((e) => { e.removeAttribute("checked"), e.checked = !1; }), r.checked = !0; } render() { return f` <slot role="group" @pyro-radio-click=${this.handleRadioClick}></slot>`; } }; t.styles = u` :host { display: inline-flex; } :host([square]) ::slotted(*) { border-radius: 0; } :host([square]) ::slotted(*:last-child) { border-top-right-radius: var(--pyro-radio-border-radius, var(--pyro-border-radius)); border-bottom-right-radius: var(--pyro-radio-border-radius, var(--pyro-border-radius)); } :host([square]) ::slotted(*:first-child) { border-top-left-radius: var(--pyro-radio-border-radius, var(--pyro-border-radius)); border-bottom-left-radius: var(--pyro-radio-border-radius, var(--pyro-border-radius)); } `; s([ p() ], t.prototype, "name", 2); s([ p() ], t.prototype, "value", 2); s([ p({ type: Boolean, reflect: !0 }) ], t.prototype, "square", 2); s([ n({ flatten: !0 }) ], t.prototype, "_slotElements", 2); t = s([ c("pyro-radio-group") ], t); export { t as PyroRadioGroup };