import { w as withInstall } from "../badge/index2.js"; import { defineComponent, inject, computed, openBlock, createElementBlock, createElementVNode, unref, normalizeClass, withModifiers, renderSlot, createTextVNode, toDisplayString } from "vue"; var index = /* @__PURE__ */ (() => ".layui-radio[size=lg] .layui-form-radio>i{font-size:24px}.layui-radio[size=md] .layui-form-radio>i{font-size:22px}.layui-radio[size=sm] .layui-form-radio>i{font-size:20px}.layui-radio[size=xs] .layui-form-radio>i{font-size:18px}.layui-radio input[type=radio]{display:none}.layui-form-radio,.layui-form-radio *{display:inline-block;vertical-align:middle}.layui-form-radio{line-height:28px;margin:6px 10px 0 0;padding-right:10px;cursor:pointer;font-size:0}.layui-form-radio *{font-size:14px}.layui-form-radio>i{margin-right:8px;font-size:22px;color:var(--global-neutral-color-8)}.layui-form-radio:hover *,.layui-form-radioed,.layui-form-radioed>i{color:var(--global-checked-color)}.layui-radio-disabled>i{color:var(--global-neutral-color-3)!important}.layui-radio-disabled *{color:var(--global-neutral-color-8)!important}\n")(); const _hoisted_1 = ["size"]; const _hoisted_2 = ["value", "name"]; const _hoisted_3 = ["onClick"]; const _hoisted_4 = { key: 0, class: "layui-anim layui-icon layui-anim-scaleSpring" }; const _hoisted_5 = { key: 1, class: "layui-icon layui-form-radioed" }; const __default__ = { name: "LayRadio" }; const _sfc_main = defineComponent({ ...__default__, props: { name: null, size: { default: "md" }, disabled: { type: Boolean }, modelValue: { type: [String, Boolean, Number] }, value: { type: [String, Boolean, Number] }, label: null }, emits: ["update:modelValue", "change"], setup(__props, { emit }) { const props = __props; const radioGroup = inject("radioGroup", {}); const isGroup = computed(() => { return radioGroup != void 0 && (radioGroup == null ? void 0 : radioGroup.name) === "LayRadioGroup"; }); const naiveName = computed(() => { if (radioGroup.naiveName) { return radioGroup.naiveName; } else { return props.name; } }); const isChecked = computed({ get() { if (isGroup.value) { return radioGroup.modelValue.value === props.value; } else { return props.modelValue === props.value; } }, set(val) { if (isGroup.value) { radioGroup.modelValue.value = props.value; } else { if (val) { emit("change", props.value); emit("update:modelValue", props.value); } } } }); const handleClick = function() { if (!ifDisabled.value) { isChecked.value = !isChecked.value; } }; const ifDisabled = computed(() => { if (props.disabled) { return true; } if (radioGroup.hasOwnProperty("disabled") && radioGroup.disabled.value) { return true; } return false; }); return (_ctx, _cache) => { return openBlock(), createElementBlock("span", { class: "layui-radio", size: __props.size }, [ createElementVNode("input", { type: "radio", value: __props.value, name: unref(naiveName) }, null, 8, _hoisted_2), createElementVNode("div", { class: normalizeClass(["layui-unselect layui-form-radio", { "layui-form-radioed": unref(isChecked), "layui-radio-disabled layui-disabled": unref(ifDisabled) }]), onClick: withModifiers(handleClick, ["stop"]) }, [ unref(isChecked) ? (openBlock(), createElementBlock("i", _hoisted_4, "\uE643")) : (openBlock(), createElementBlock("i", _hoisted_5, "\uE63F")), createElementVNode("span", null, [ renderSlot(_ctx.$slots, "default", {}, () => [ createTextVNode(toDisplayString(__props.label), 1) ]) ]) ], 10, _hoisted_3) ], 8, _hoisted_1); }; } }); const component = withInstall(_sfc_main); export { _sfc_main as _, component as c };