tdesign-vue
Version:
156 lines (152 loc) • 5.73 kB
JavaScript
/**
* tdesign v1.14.1
* (c) 2025 tdesign
* @license MIT
*/
import { h as helper } from '../_chunks/dep-e77071c7.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { isFunction } from 'lodash-es';
import props from './props.js';
import popupProps from '../popup/props.js';
import Popup from '../popup/popup.js';
import { renderTNodeJSX, renderContent } from '../utils/render-tnode.js';
import { getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../utils/mixins.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../utils/dom.js';
import 'vue';
import 'raf';
import '../utils/easing.js';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../_common/js/utils/setStyle.js';
import '../popup/container.js';
import '../utils/event.js';
import '../popup/utils.js';
import '@babel/runtime/helpers/readOnlyError';
import '@vue/composition-api';
import '../config-provider/context.js';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-d2f11e9e.js';
import '../_chunks/dep-05dc6583.js';
import 'dayjs';
import '../_chunks/dep-62386ed0.js';
import '../config-provider/type.js';
import '../_common/js/global-config/t.js';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var classPrefixMixins = getClassPrefixMixins("tooltip");
var _Tooltip = mixins(classPrefixMixins).extend({
name: "TTooltip",
components: {
Popup: Popup
},
props: _objectSpread(_objectSpread({}, popupProps), props),
data: function data() {
return {
timer: null,
x: 0,
offsetX: 0,
tooltipVisible: false
};
},
computed: {
tooltipOverlayClassName: function tooltipOverlayClassName() {
return [this.componentName, _defineProperty({}, "".concat(this.componentName, "--").concat(this.theme), this.theme), this.overlayClassName];
},
tooltipOverlayInnerStyle: function tooltipOverlayInnerStyle() {
var _this = this;
if (this.placement !== "mouse" || this.offsetX === 0) {
return this.overlayInnerStyle;
}
var offsetStyle = function offsetStyle(triggerEl) {
return {
transform: "translateX(".concat(_this.offsetX - triggerEl.getBoundingClientRect().left, "px)")
};
};
if (this.overlayInnerStyle) {
return function (triggerEl, popupEl) {
return _objectSpread(_objectSpread({}, offsetStyle(triggerEl)), isFunction(_this.overlayInnerStyle) ? _this.overlayInnerStyle(triggerEl, popupEl) : _this.overlayInnerStyle);
};
}
return offsetStyle;
}
},
watch: {
visible: function visible(_visible) {
if (this.timer && !_visible) {
clearTimeout(this.timer);
this.timer = null;
}
}
},
created: function created() {
var _this2 = this;
if (this.duration && this.visible) {
this.timer = setTimeout(function () {
_this2.$emit("visible-change", false);
clearTimeout(_this2.timer);
_this2.timer = null;
}, this.duration);
}
},
mounted: function mounted() {
var _window;
(_window = window) === null || _window === void 0 || _window.addEventListener("mousemove", this.onMouseMove, {
passive: true
});
},
destroyed: function destroyed() {
var _window2;
(_window2 = window) === null || _window2 === void 0 || _window2.removeEventListener("mousemove", this.onMouseMove);
},
methods: {
onMouseMove: function onMouseMove(e) {
this.x = e.clientX;
},
onTipVisibleChange: function onTipVisibleChange(val, ctx) {
if (this.timer && (ctx === null || ctx === void 0 ? void 0 : ctx.trigger) !== "document") return;
if (val) this.offsetX = this.x;
this.$emit("visible-change", val);
},
getPopupProps: function getPopupProps() {
var _this3 = this;
var r = _objectSpread(_objectSpread({}, this.$props), {}, {
showArrow: this.placement === "mouse" ? false : this.showArrow,
placement: this.placement === "mouse" ? "bottom-left" : this.placement,
content: function content() {
return renderTNodeJSX(_this3, "content");
},
"default": function _default() {
return renderContent(_this3, "default", "triggerElement");
},
overlayClassName: this.tooltipOverlayClassName,
overlayInnerStyle: this.tooltipOverlayInnerStyle
});
return r;
},
updatedTooltip: function updatedTooltip() {
this.$refs.popup && this.$refs.popup.updatePopper();
}
},
render: function render() {
var h = arguments[0];
return h(Popup, helper([{
"ref": "popup",
"attrs": {
"visible": this.visible
}
}, {
"props": this.getPopupProps()
}, {}, {
"on": {
"visible-change": this.onTipVisibleChange
}
}]));
}
});
export { _Tooltip as default };
//# sourceMappingURL=tooltip.js.map