yanzhen-design-vue
Version:
36 lines (35 loc) • 1.36 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const lodashEs = require("lodash-es");
const antDesignVue = require("ant-design-vue");
const utilsVue = require("@yanzhen-libs/utils-vue");
const radio = require("./radio.cjs");
function useRadio(props, emit) {
const _ref = vue.ref();
const attrs = vue.useAttrs();
const slots = vue.useSlots();
const updatePropsKey = utilsVue.useDynamicProps({ update: true });
const checkedRef = updatePropsKey.includes("checked") ? utilsVue.useModelValue(props, "checked", emit) : utilsVue.useModelValue(props, null, emit);
const config = vue.computed(() => lodashEs.pick(props, ...Object.keys(radio.AntRadio.props)));
const proxyProps = utilsVue.useProxyProps(config, radio.AntRadio.emits, {
emit,
exclude: ["value", "checked"],
filter: (key) => {
switch (key) {
case "onUpdate:value":
case "onUpdate:checked":
return false;
}
return true;
}
});
const propsRef = vue.computed(() => {
return vue.mergeProps(utilsVue.unref(attrs), utilsVue.unref(proxyProps));
});
const Radio = vue.computed(() => {
return vue.h(antDesignVue.Radio, utilsVue.unref(propsRef), utilsVue.unref(slots));
});
return { _ref, propsRef, checkedRef, Radio };
}
exports.useRadio = useRadio;