UNPKG

@shopware-ag/meteor-component-library

Version:

The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).

63 lines (62 loc) 2.41 kB
import '../mt-radio-group-item.css'; import { defineComponent, inject, computed, openBlock, createElementBlock, normalizeClass, createVNode, createElementVNode, toDisplayString } from "vue"; import MtRadioGroupIndicator from "./MtRadioGroupIndicator.js"; import { _ as _export_sfc } from "../_plugin-vue_export-helper-cc2b3d55.mjs"; const _hoisted_1 = ["for"]; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "mt-radio-group-item", props: { id: {}, value: { type: [String, Number, Boolean] }, label: {}, required: { type: Boolean, default: false }, ariaDescribedBy: { default: void 0 }, error: { type: Boolean, default: false } }, setup(__props) { const props = __props; const radioGroup = inject("radioGroupContext"); if (!radioGroup) { throw new Error("MtRadioGroupItem must be used within MtRadioGroupRoot"); } const radioGroupContext = radioGroup; const name = computed(() => radioGroupContext.name.value); const checked = computed(() => radioGroupContext.selectedValue.value === props.value); const isDisabled = computed(() => radioGroupContext.disabled.value); function onClick() { if (isDisabled.value) { return; } radioGroupContext.selectOption(props.value); } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: normalizeClass(["mt-radio-group-item", { "mt-radio-group-item--disabled": isDisabled.value }]), onClick }, [ createVNode(MtRadioGroupIndicator, { id: _ctx.id, name: name.value, value: _ctx.value, checked: checked.value, disabled: isDisabled.value, required: _ctx.required, "aria-described-by": _ctx.ariaDescribedBy, error: _ctx.error }, null, 8, ["id", "name", "value", "checked", "disabled", "required", "aria-described-by", "error"]), createElementVNode("label", { for: _ctx.id, class: "mt-radio-group-item__label" }, toDisplayString(_ctx.label), 9, _hoisted_1) ], 2); }; } }); const mtRadioGroupItem_vue_vue_type_style_index_0_scoped_95a7195b_lang = ""; const mtRadioGroupItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-95a7195b"]]); export { mtRadioGroupItem as default }; //# sourceMappingURL=MtRadioGroupItem.js.map