UNPKG

yanzhen-design-vue

Version:

36 lines (35 loc) 1.21 kB
import { ref, useAttrs, useSlots, computed, mergeProps, h } from "vue"; import { pick } from "lodash-es"; import { Radio } from "ant-design-vue"; import { useDynamicProps, useModelValue, useProxyProps, unref } from "@yanzhen-libs/utils-vue"; import { AntRadio } from "./radio.mjs"; function useRadio(props, emit) { const _ref = ref(); const attrs = useAttrs(); const slots = useSlots(); const updatePropsKey = useDynamicProps({ update: true }); const checkedRef = updatePropsKey.includes("checked") ? useModelValue(props, "checked", emit) : useModelValue(props, null, emit); const config = computed(() => pick(props, ...Object.keys(AntRadio.props))); const proxyProps = useProxyProps(config, AntRadio.emits, { emit, exclude: ["value", "checked"], filter: (key) => { switch (key) { case "onUpdate:value": case "onUpdate:checked": return false; } return true; } }); const propsRef = computed(() => { return mergeProps(unref(attrs), unref(proxyProps)); }); const Radio$1 = computed(() => { return h(Radio, unref(propsRef), unref(slots)); }); return { _ref, propsRef, checkedRef, Radio: Radio$1 }; } export { useRadio };