UNPKG

@antdv/pro-utils

Version:

@antdv/pro-utils

68 lines (67 loc) 2.41 kB
import { Fragment as _Fragment, createVNode as _createVNode } from "vue"; import { InfoCircleOutlined } from "@ant-design/icons-vue"; import { Tooltip } from "ant-design-vue"; import { useConfigContextInject } from "ant-design-vue/es/config-provider/context"; import { computed, defineComponent } from "vue"; import { classNames } from "../../classNames/index.mjs"; import { oneOfType, vNodeType } from "../../vueHelper/index.mjs"; import { useStyle } from "./style.mjs"; const labelIconTipProps = { label: vNodeType(), subTitle: vNodeType(), tooltip: oneOfType([String, Object]), ellipsis: oneOfType([Boolean, Object]) }; const LabelIconTip = defineComponent({ name: "LabelIconTip", props: labelIconTipProps, slots: Object, setup(props, { slots }) { const { getPrefixCls } = useConfigContextInject(); const proClassName = computed(() => getPrefixCls("pro-core-label-tip")); const { wrapSSR, hashId } = useStyle(proClassName); return () => { var _a, _b; const { label = (_a = slots.label) == null ? void 0 : _a.call(slots), tooltip, ellipsis, subTitle = (_b = slots.subTitle) == null ? void 0 : _b.call(slots) } = props; if (!tooltip && !subTitle) { return _createVNode(_Fragment, null, [props.label]); } const tooltipProps = typeof tooltip === "string" ? { title: tooltip } : tooltip; const icon = (tooltipProps == null ? void 0 : tooltipProps.icon) || _createVNode(InfoCircleOutlined, null, null); return wrapSSR(_createVNode("div", { "class": classNames(proClassName.value, hashId.value), "onMousedown": (e) => e.stopPropagation(), "onMouseleave": (e) => e.stopPropagation(), "onMousemove": (e) => e.stopPropagation() }, [_createVNode("div", { "class": classNames(`${proClassName.value}-title`, hashId.value, { [`${proClassName.value}-title-ellipsis`]: ellipsis }) }, [label]), subTitle && _createVNode("div", { "class": `${proClassName.value}-subtitle ${hashId.value}`.trim() }, [subTitle]), tooltip && _createVNode(Tooltip, tooltipProps, { default: () => [_createVNode("span", { "class": `${proClassName.value}-icon ${hashId.value}`.trim() }, [icon])] })])); }; } }); export { LabelIconTip, labelIconTipProps };