@arco-design/web-vue
Version:
Arco Design Vue 2.0: A Vue.js 3 UI Library
141 lines (140 loc) • 3.93 kB
JavaScript
;
var vue = require("vue");
var globalConfig = require("../_utils/global-config.js");
var index = require("../trigger/index.js");
var pluginVue_exportHelper = require("../_virtual/plugin-vue_export-helper.js");
const _sfc_main = vue.defineComponent({
name: "Tooltip",
components: {
Trigger: index
},
props: {
popupVisible: {
type: Boolean,
default: void 0
},
defaultPopupVisible: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
content: String,
position: {
type: String,
default: "top"
},
mini: {
type: Boolean,
default: false
},
backgroundColor: {
type: String
},
contentClass: {
type: [String, Array, Object]
},
contentStyle: {
type: Object
},
arrowClass: {
type: [String, Array, Object]
},
arrowStyle: {
type: Object
},
popupContainer: {
type: [String, Object]
}
},
emits: {
"update:popupVisible": (visible) => true,
"popupVisibleChange": (visible) => true
},
setup(props, { emit }) {
const prefixCls = globalConfig.getPrefixCls("tooltip");
const _popupVisible = vue.ref(props.defaultPopupVisible);
const computedPopupVisible = vue.computed(
() => {
var _a;
return (_a = props.popupVisible) != null ? _a : _popupVisible.value;
}
);
const handlePopupVisibleChange = (visible) => {
_popupVisible.value = visible;
emit("update:popupVisible", visible);
emit("popupVisibleChange", visible);
};
const contentCls = vue.computed(() => [
`${prefixCls}-content`,
props.contentClass,
{ [`${prefixCls}-mini`]: props.mini }
]);
const computedContentStyle = vue.computed(() => {
if (props.backgroundColor || props.contentStyle) {
return {
backgroundColor: props.backgroundColor,
...props.contentStyle
};
}
return void 0;
});
const arrowCls = vue.computed(() => [
`${prefixCls}-popup-arrow`,
props.arrowClass
]);
const computedArrowStyle = vue.computed(() => {
if (props.backgroundColor || props.arrowStyle) {
return {
backgroundColor: props.backgroundColor,
...props.arrowStyle
};
}
return void 0;
});
return {
prefixCls,
computedPopupVisible,
contentCls,
computedContentStyle,
arrowCls,
computedArrowStyle,
handlePopupVisibleChange
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_Trigger = vue.resolveComponent("Trigger");
return vue.openBlock(), vue.createBlock(_component_Trigger, {
class: vue.normalizeClass(_ctx.prefixCls),
trigger: "hover",
position: _ctx.position,
"popup-visible": _ctx.computedPopupVisible,
disabled: _ctx.disabled,
"popup-offset": 10,
"show-arrow": "",
"content-class": _ctx.contentCls,
"content-style": _ctx.computedContentStyle,
"arrow-class": _ctx.arrowCls,
"arrow-style": _ctx.computedArrowStyle,
"popup-container": _ctx.popupContainer,
"animation-name": "zoom-in-fade-out",
"auto-fit-transform-origin": "",
role: "tooltip",
onPopupVisibleChange: _ctx.handlePopupVisibleChange
}, {
content: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "content", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.content), 1)
])
]),
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["class", "position", "popup-visible", "disabled", "content-class", "content-style", "arrow-class", "arrow-style", "popup-container", "onPopupVisibleChange"]);
}
var _Tooltip = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]);
module.exports = _Tooltip;