yanzhen-design-vue
Version:
36 lines (35 loc) • 1.05 kB
JavaScript
import { computed, createCommentVNode, defineAsyncComponent, useAttrs, createVNode, mergeProps, defineComponent, unref } from "vue";
import { upperFirst, camelCase } from "@yanzhen-libs/utils";
import { omit } from "lodash-es";
import { iconName, iconProps, iconEmits } from "./icon.mjs";
let icons;
function useIcon(props, emit) {
const Icon2 = computed(() => {
if (!props.type) {
return createCommentVNode("v-if", true);
}
const type = upperFirst(camelCase(props.type));
const Icon3 = defineAsyncComponent(async () => {
if (!icons) icons = await import("@ant-design/icons-vue");
return icons == null ? void 0 : icons[type];
});
const attrs = useAttrs();
return createVNode(Icon3, mergeProps(attrs, omit(props, "type")));
});
return {
Icon: Icon2
};
}
const Icon = defineComponent({
name: iconName,
props: iconProps,
emits: iconEmits,
setup(props, { emit }) {
const { Icon: Icon2 } = useIcon(props, emit);
return () => unref(Icon2);
}
});
export {
Icon,
useIcon
};