yanzhen-design-vue
Version:
92 lines (91 loc) • 4.08 kB
JavaScript
import { defineComponent, openBlock, createBlock, unref, mergeProps, isRef, withCtx, renderSlot, createElementBlock, Fragment, renderList, createVNode, createTextVNode, toDisplayString } from "vue";
import { RadioGroup, CheckableTag, RadioButton } from "ant-design-vue";
import "./radio.vue.mjs";
import { radioGroupName, radioGroupProps, radioGroupEmits, radioGroupOptions } from "./radio-group.mjs";
import { radioOptions } from "./radio.mjs";
import { useRadioGroup } from "./use-radio-group.mjs";
import _sfc_main$1 from "./radio.vue2.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
...{ name: radioGroupName },
__name: "radio-group",
props: radioGroupProps,
emits: radioGroupEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const { ns } = radioGroupOptions;
const { ns: radioNs } = radioOptions;
const props = __props;
const emit = __emit;
const [{ _ref, checkedRef, propsRef, optionsRef }] = useRadioGroup(props, emit);
__expose({
ref: _ref
});
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(RadioGroup), mergeProps({
ref_key: "_ref",
ref: _ref,
value: unref(checkedRef),
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => isRef(checkedRef) ? checkedRef.value = $event : null),
class: [unref(ns).b()]
}, unref(propsRef)), {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default", { options: unref(optionsRef) }, () => [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(optionsRef), (item) => {
return openBlock(), createElementBlock(Fragment, {
key: item.value
}, [
props.type === "tag" ? (openBlock(), createBlock(_sfc_main$1, mergeProps({
key: 0,
value: item.value,
class: [unref(radioNs).e("tag"), unref(checkedRef) === item.value && unref(radioNs).is("checked")],
ref_for: true
}, item.source), {
default: withCtx(() => [
createVNode(unref(CheckableTag), {
checked: unref(checkedRef) === item.value
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, item), () => [
createTextVNode(toDisplayString(item.label), 1)
])
]),
_: 2
}, 1032, ["checked"])
]),
_: 2
}, 1040, ["value", "class"])) : props.type === "button" ? (openBlock(), createBlock(unref(RadioButton), mergeProps({
key: 1,
class: [unref(checkedRef) === item.value && unref(radioNs).is("checked")],
value: item.value,
ref_for: true
}, item.source), {
default: withCtx(() => [
renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, item), () => [
createTextVNode(toDisplayString(item.label), 1)
])
]),
_: 2
}, 1040, ["class", "value"])) : (openBlock(), createBlock(_sfc_main$1, mergeProps({
key: 2,
value: item.value,
class: [unref(checkedRef) === item.value && unref(radioNs).is("checked")],
ref_for: true
}, item.source), {
default: withCtx(() => [
renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, item), () => [
createTextVNode(toDisplayString(item.label), 1)
])
]),
_: 2
}, 1040, ["value", "class"]))
], 64);
}), 128))
])
]),
_: 3
}, 16, ["value", "class"]);
};
}
});
export {
_sfc_main as default
};