element-ui
Version:
A Component Library for Vue.js.
397 lines (330 loc) • 10.1 kB
JavaScript
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 207);
/******/ })
/************************************************************************/
/******/ ({
/***/ 14:
/***/ (function(module, exports) {
module.exports = require("throttle-debounce/debounce");
/***/ }),
/***/ 2:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/dom");
/***/ }),
/***/ 20:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/vdom");
/***/ }),
/***/ 207:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _main = __webpack_require__(208);
var _main2 = _interopRequireDefault(_main);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* istanbul ignore next */
_main2.default.install = function (Vue) {
Vue.component(_main2.default.name, _main2.default);
};
exports.default = _main2.default;
/***/ }),
/***/ 208:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _vuePopper = __webpack_require__(7);
var _vuePopper2 = _interopRequireDefault(_vuePopper);
var _debounce = __webpack_require__(14);
var _debounce2 = _interopRequireDefault(_debounce);
var _dom = __webpack_require__(2);
var _vdom = __webpack_require__(20);
var _util = __webpack_require__(3);
var _vue = __webpack_require__(4);
var _vue2 = _interopRequireDefault(_vue);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
name: 'ElTooltip',
mixins: [_vuePopper2.default],
props: {
openDelay: {
type: Number,
default: 0
},
disabled: Boolean,
manual: Boolean,
effect: {
type: String,
default: 'dark'
},
arrowOffset: {
type: Number,
default: 0
},
popperClass: String,
content: String,
visibleArrow: {
default: true
},
transition: {
type: String,
default: 'el-fade-in-linear'
},
popperOptions: {
default: function _default() {
return {
boundariesPadding: 10,
gpuAcceleration: false
};
}
},
enterable: {
type: Boolean,
default: true
},
hideAfter: {
type: Number,
default: 0
}
},
data: function data() {
return {
timeoutPending: null,
focusing: false
};
},
computed: {
tooltipId: function tooltipId() {
return 'el-tooltip-' + (0, _util.generateId)();
}
},
beforeCreate: function beforeCreate() {
var _this = this;
if (this.$isServer) return;
this.popperVM = new _vue2.default({
data: { node: '' },
render: function render(h) {
return this.node;
}
}).$mount();
this.debounceClose = (0, _debounce2.default)(200, function () {
return _this.handleClosePopper();
});
},
render: function render(h) {
var _this2 = this;
if (this.popperVM) {
this.popperVM.node = h(
'transition',
{
attrs: {
name: this.transition
},
on: {
'afterLeave': this.doDestroy
}
},
[h(
'div',
{
on: {
'mouseleave': function mouseleave() {
_this2.setExpectedState(false);_this2.debounceClose();
},
'mouseenter': function mouseenter() {
_this2.setExpectedState(true);
}
},
ref: 'popper',
attrs: { role: 'tooltip',
id: this.tooltipId,
'aria-hidden': this.disabled || !this.showPopper ? 'true' : 'false'
},
directives: [{
name: 'show',
value: !this.disabled && this.showPopper
}],
'class': ['el-tooltip__popper', 'is-' + this.effect, this.popperClass] },
[this.$slots.content || this.content]
)]
);
}
if (!this.$slots.default || !this.$slots.default.length) return this.$slots.default;
var vnode = (0, _vdom.getFirstComponentChild)(this.$slots.default);
if (!vnode) return vnode;
var data = vnode.data = vnode.data || {};
data.staticClass = this.concatClass(data.staticClass, 'el-tooltip');
return vnode;
},
mounted: function mounted() {
var _this3 = this;
this.referenceElm = this.$el;
if (this.$el.nodeType === 1) {
this.$el.setAttribute('aria-describedby', this.tooltipId);
this.$el.setAttribute('tabindex', 0);
(0, _dom.on)(this.referenceElm, 'mouseenter', this.show);
(0, _dom.on)(this.referenceElm, 'mouseleave', this.hide);
(0, _dom.on)(this.referenceElm, 'focus', function () {
if (!_this3.$slots.default || !_this3.$slots.default.length) {
_this3.handleFocus();
return;
}
var instance = _this3.$slots.default[0].componentInstance;
if (instance && instance.focus) {
instance.focus();
} else {
_this3.handleFocus();
}
});
(0, _dom.on)(this.referenceElm, 'blur', this.handleBlur);
(0, _dom.on)(this.referenceElm, 'click', this.removeFocusing);
}
},
watch: {
focusing: function focusing(val) {
if (val) {
(0, _dom.addClass)(this.referenceElm, 'focusing');
} else {
(0, _dom.removeClass)(this.referenceElm, 'focusing');
}
}
},
methods: {
show: function show() {
this.setExpectedState(true);
this.handleShowPopper();
},
hide: function hide() {
this.setExpectedState(false);
this.debounceClose();
},
handleFocus: function handleFocus() {
this.focusing = true;
this.show();
},
handleBlur: function handleBlur() {
this.focusing = false;
this.hide();
},
removeFocusing: function removeFocusing() {
this.focusing = false;
},
concatClass: function concatClass(a, b) {
if (a && a.indexOf(b) > -1) return a;
return a ? b ? a + ' ' + b : a : b || '';
},
handleShowPopper: function handleShowPopper() {
var _this4 = this;
if (!this.expectedState || this.manual) return;
clearTimeout(this.timeout);
this.timeout = setTimeout(function () {
_this4.showPopper = true;
}, this.openDelay);
if (this.hideAfter > 0) {
this.timeoutPending = setTimeout(function () {
_this4.showPopper = false;
}, this.hideAfter);
}
},
handleClosePopper: function handleClosePopper() {
if (this.enterable && this.expectedState || this.manual) return;
clearTimeout(this.timeout);
if (this.timeoutPending) {
clearTimeout(this.timeoutPending);
}
this.showPopper = false;
if (this.disabled) {
this.doDestroy();
}
},
setExpectedState: function setExpectedState(expectedState) {
if (expectedState === false) {
clearTimeout(this.timeoutPending);
}
this.expectedState = expectedState;
}
},
destroyed: function destroyed() {
var reference = this.referenceElm;
(0, _dom.off)(reference, 'mouseenter', this.show);
(0, _dom.off)(reference, 'mouseleave', this.hide);
(0, _dom.off)(reference, 'focus', this.handleFocus);
(0, _dom.off)(reference, 'blur', this.handleBlur);
(0, _dom.off)(reference, 'click', this.removeFocusing);
}
};
/***/ }),
/***/ 3:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/util");
/***/ }),
/***/ 4:
/***/ (function(module, exports) {
module.exports = require("vue");
/***/ }),
/***/ 7:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/vue-popper");
/***/ })
/******/ });