yanzhen-design-vue
Version:
66 lines (65 loc) • 1.95 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const utilsVue = require("@yanzhen-libs/utils-vue");
const lodashEs = require("lodash-es");
const antDesignVue = require("ant-design-vue");
const tooltip = require("./tooltip.cjs");
function useTooltip(props, emit) {
const _ref = vue.ref(null);
const attrs = vue.useAttrs();
const slots = vue.useSlots();
const config = vue.computed(() => {
return lodashEs.pick(props, ...Object.keys(tooltip.AntTooltip.props));
});
const proxyProps = utilsVue.useProxyProps(config, tooltip.AntTooltip.emits, {
emit,
exclude: []
});
const propsRef = vue.computed(() => {
return vue.mergeProps(utilsVue.unref(attrs), utilsVue.unref(proxyProps));
});
function handleTextVNode() {
if (vue.isVNode(props.text)) {
return props.text;
} else if (lodashEs.isString(props.text)) {
return vue.createTextVNode(props.text);
}
}
function handleTagVNode() {
if (vue.isVNode(props.tagName)) {
return props.tagName;
} else if (lodashEs.isString(props.tagName)) {
return vue.createVNode(
antDesignVue.Tag,
{
color: props.tagColor
},
props.tagName
);
}
}
function handleDefaultVNode(props2) {
const defaultVNodes = [handleTextVNode(), handleTagVNode()].filter((value) => vue.isVNode(value));
if (lodashEs.isFunction(slots.default)) {
return lodashEs.flattenDeep([slots.default(props2), defaultVNodes]);
}
return lodashEs.flattenDeep(defaultVNodes);
}
return [
{ _ref, propsRef },
(props2) => {
return vue.h(
antDesignVue.Tooltip,
vue.mergeProps(utilsVue.unref(attrs), utilsVue.unref(props2) ?? {}, {
ref: _ref
}),
{
...slots,
default: vue.withCtx(handleDefaultVNode)
}
);
}
];
}
exports.useTooltip = useTooltip;