yuang-framework-ui-pc
Version:
yuang-framework-ui-pc Library
72 lines (71 loc) • 2.19 kB
JavaScript
;
const vue = require("vue");
const hook = require("../utils/hook");
const props$1 = require("../ele-toolbar/props");
const props = require("./props");
const _sfc_main = vue.defineComponent({
name: "EleTool",
props: props.toolProps,
emits: props.toolEmits,
setup(props2, { emit }) {
const toolbarProvide = vue.inject(props$1.TOOLBAR_KEY, {});
const [startHideTipTimer, stopHideTipTimer] = hook.useTimer(200);
const showTooltip = (text, el, options) => {
if (toolbarProvide.showTooltip) {
toolbarProvide.showTooltip(text, el, options);
}
};
const hideTooltip = () => {
toolbarProvide.hideTooltip && toolbarProvide.hideTooltip();
};
const handleClick = (e) => {
if (props2.clickHideTooltip) {
startHideTipTimer(() => {
hideTooltip();
});
}
emit("click", e);
};
const handleMouseover = (e) => {
if (props2.title && !props2.disabled) {
stopHideTipTimer();
showTooltip(props2.title, e.currentTarget, {
placement: props2.placement,
offset: 10
});
}
};
vue.watch([() => props2.disabled, () => props2.title], () => {
if (!props2.title || props2.disabled) {
hideTooltip();
}
});
return {
handleClick,
handleMouseover,
showTooltip,
hideTooltip
};
}
});
const _export_sfc = (sfc, props2) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props2) {
target[key] = val;
}
return target;
};
const _hoisted_1 = { class: "ele-tool-body" };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("div", {
class: "ele-tool",
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
onMouseover: _cache[1] || (_cache[1] = (...args) => _ctx.handleMouseover && _ctx.handleMouseover(...args))
}, [
vue.createElementVNode("div", _hoisted_1, [
vue.renderSlot(_ctx.$slots, "default")
])
], 32);
}
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
module.exports = index;