UNPKG

element-ui

Version:

A Component Library for Vue.js.

873 lines (735 loc) 21.5 kB
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] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = 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; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/dist/"; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ function(module, exports, __webpack_require__) { module.exports = __webpack_require__(206); /***/ }, /***/ 3: /***/ function(module, exports) { /* globals __VUE_SSR_CONTEXT__ */ // this module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle module.exports = function normalizeComponent ( rawScriptExports, compiledTemplate, injectStyles, scopeId, moduleIdentifier /* server only */ ) { var esModule var scriptExports = rawScriptExports = rawScriptExports || {} // ES6 modules interop var type = typeof rawScriptExports.default if (type === 'object' || type === 'function') { esModule = rawScriptExports scriptExports = rawScriptExports.default } // Vue.extend constructor export interop var options = typeof scriptExports === 'function' ? scriptExports.options : scriptExports // render functions if (compiledTemplate) { options.render = compiledTemplate.render options.staticRenderFns = compiledTemplate.staticRenderFns } // scopedId if (scopeId) { options._scopeId = scopeId } var hook if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || (this.$vnode && this.$vnode.ssrContext) // 2.2 with runInNewContext: true if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { context = __VUE_SSR_CONTEXT__ } // inject component styles if (injectStyles) { injectStyles.call(this, context) } // register component module identifier for async chunk inferrence if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier) } } // used by ssr in case component is cached and beforeCreate // never gets called options._ssrRegister = hook } else if (injectStyles) { hook = injectStyles } if (hook) { // inject component registration as beforeCreate hook var existing = options.beforeCreate options.beforeCreate = existing ? [].concat(existing, hook) : [hook] } return { esModule: esModule, exports: scriptExports, options: options } } /***/ }, /***/ 9: /***/ function(module, exports) { module.exports = require("element-ui/lib/input"); /***/ }, /***/ 55: /***/ function(module, exports) { module.exports = require("vue"); /***/ }, /***/ 61: /***/ function(module, exports) { module.exports = require("element-ui/lib/mixins/locale"); /***/ }, /***/ 62: /***/ function(module, exports) { module.exports = require("element-ui/lib/locale"); /***/ }, /***/ 123: /***/ function(module, exports) { module.exports = require("element-ui/lib/utils/dom"); /***/ }, /***/ 138: /***/ function(module, exports) { module.exports = require("element-ui/lib/utils/popup"); /***/ }, /***/ 143: /***/ function(module, exports) { module.exports = require("element-ui/lib/button"); /***/ }, /***/ 170: /***/ function(module, exports) { module.exports = require("element-ui/lib/utils/merge"); /***/ }, /***/ 197: /***/ function(module, exports) { module.exports = require("element-ui/lib/utils/vdom"); /***/ }, /***/ 206: /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; var _main = __webpack_require__(207); var _main2 = _interopRequireDefault(_main); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = _main2.default; /***/ }, /***/ 207: /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; exports.MessageBox = undefined; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _vue = __webpack_require__(55); var _vue2 = _interopRequireDefault(_vue); var _main = __webpack_require__(208); var _main2 = _interopRequireDefault(_main); var _merge = __webpack_require__(170); var _merge2 = _interopRequireDefault(_merge); var _vdom = __webpack_require__(197); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var defaults = { title: undefined, message: '', type: '', showInput: false, showClose: true, modalFade: true, lockScroll: true, closeOnClickModal: true, closeOnPressEscape: true, inputValue: null, inputPlaceholder: '', inputPattern: null, inputValidator: null, inputErrorMessage: '', showConfirmButton: true, showCancelButton: false, confirmButtonPosition: 'right', confirmButtonHighlight: false, cancelButtonHighlight: false, confirmButtonText: '', cancelButtonText: '', confirmButtonClass: '', cancelButtonClass: '', customClass: '', beforeClose: null }; var MessageBoxConstructor = _vue2.default.extend(_main2.default); var currentMsg = void 0, instance = void 0; var msgQueue = []; var defaultCallback = function defaultCallback(action) { if (currentMsg) { var callback = currentMsg.callback; if (typeof callback === 'function') { if (instance.showInput) { callback(instance.inputValue, action); } else { callback(action); } } if (currentMsg.resolve) { if (action === 'confirm') { if (instance.showInput) { currentMsg.resolve({ value: instance.inputValue, action: action }); } else { currentMsg.resolve(action); } } else if (action === 'cancel' && currentMsg.reject) { currentMsg.reject(action); } } } }; var initInstance = function initInstance() { instance = new MessageBoxConstructor({ el: document.createElement('div') }); instance.callback = defaultCallback; }; var showNextMsg = function showNextMsg() { if (!instance) { initInstance(); } instance.action = ''; if (!instance.visible || instance.closeTimer) { if (msgQueue.length > 0) { (function () { currentMsg = msgQueue.shift(); var options = currentMsg.options; for (var prop in options) { if (options.hasOwnProperty(prop)) { instance[prop] = options[prop]; } } if (options.callback === undefined) { instance.callback = defaultCallback; } var oldCb = instance.callback; instance.callback = function (action, instance) { oldCb(action, instance); showNextMsg(); }; if ((0, _vdom.isVNode)(instance.message)) { instance.$slots.default = [instance.message]; instance.message = null; } else { delete instance.$slots.default; } ['modal', 'showClose', 'closeOnClickModal', 'closeOnPressEscape'].forEach(function (prop) { if (instance[prop] === undefined) { instance[prop] = true; } }); document.body.appendChild(instance.$el); _vue2.default.nextTick(function () { instance.visible = true; }); })(); } } }; var MessageBox = function MessageBox(options, callback) { if (_vue2.default.prototype.$isServer) return; if (typeof options === 'string') { options = { message: options }; if (arguments[1]) { options.title = arguments[1]; } if (arguments[2]) { options.type = arguments[2]; } } else if (options.callback && !callback) { callback = options.callback; } if (typeof Promise !== 'undefined') { return new Promise(function (resolve, reject) { // eslint-disable-line msgQueue.push({ options: (0, _merge2.default)({}, defaults, MessageBox.defaults, options), callback: callback, resolve: resolve, reject: reject }); showNextMsg(); }); } else { msgQueue.push({ options: (0, _merge2.default)({}, defaults, MessageBox.defaults, options), callback: callback }); showNextMsg(); } }; MessageBox.setDefaults = function (defaults) { MessageBox.defaults = defaults; }; MessageBox.alert = function (message, title, options) { if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') { options = title; title = ''; } else if (title === undefined) { title = ''; } return MessageBox((0, _merge2.default)({ title: title, message: message, $type: 'alert', closeOnPressEscape: false, closeOnClickModal: false }, options)); }; MessageBox.confirm = function (message, title, options) { if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') { options = title; title = ''; } else if (title === undefined) { title = ''; } return MessageBox((0, _merge2.default)({ title: title, message: message, $type: 'confirm', showCancelButton: true }, options)); }; MessageBox.prompt = function (message, title, options) { if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') { options = title; title = ''; } else if (title === undefined) { title = ''; } return MessageBox((0, _merge2.default)({ title: title, message: message, showCancelButton: true, showInput: true, $type: 'prompt' }, options)); }; MessageBox.close = function () { instance.visible = false; msgQueue = []; currentMsg = null; }; exports.default = MessageBox; exports.MessageBox = MessageBox; /***/ }, /***/ 208: /***/ function(module, exports, __webpack_require__) { var Component = __webpack_require__(3)( /* script */ __webpack_require__(209), /* template */ __webpack_require__(210), /* styles */ null, /* scopeId */ null, /* moduleIdentifier (server only) */ null ) module.exports = Component.exports /***/ }, /***/ 209: /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; var _popup = __webpack_require__(138); var _popup2 = _interopRequireDefault(_popup); var _locale = __webpack_require__(61); var _locale2 = _interopRequireDefault(_locale); var _input = __webpack_require__(9); var _input2 = _interopRequireDefault(_input); var _button = __webpack_require__(143); var _button2 = _interopRequireDefault(_button); var _dom = __webpack_require__(123); var _locale3 = __webpack_require__(62); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // var typeMap = { success: 'circle-check', info: 'information', warning: 'warning', error: 'circle-cross' }; exports.default = { mixins: [_popup2.default, _locale2.default], props: { modal: { default: true }, lockScroll: { default: true }, showClose: { type: Boolean, default: true }, closeOnClickModal: { default: true }, closeOnPressEscape: { default: true } }, components: { ElInput: _input2.default, ElButton: _button2.default }, computed: { typeClass: function typeClass() { return this.type && typeMap[this.type] ? 'el-icon-' + typeMap[this.type] : ''; }, confirmButtonClasses: function confirmButtonClasses() { return 'el-button--primary ' + this.confirmButtonClass; }, cancelButtonClasses: function cancelButtonClasses() { return '' + this.cancelButtonClass; } }, methods: { getSafeClose: function getSafeClose() { var _this = this; var currentId = this.uid; return function () { _this.$nextTick(function () { if (currentId === _this.uid) _this.doClose(); }); }; }, doClose: function doClose() { var _this2 = this; if (!this.visible) return; this.visible = false; this._closing = true; this.onClose && this.onClose(); if (this.lockScroll) { setTimeout(function () { if (_this2.modal && _this2.bodyOverflow !== 'hidden') { document.body.style.overflow = _this2.bodyOverflow; document.body.style.paddingRight = _this2.bodyPaddingRight; } _this2.bodyOverflow = null; _this2.bodyPaddingRight = null; }, 200); } this.opened = false; if (!this.transition) { this.doAfterClose(); } if (this.action) this.callback(this.action, this); }, handleWrapperClick: function handleWrapperClick() { if (this.closeOnClickModal) { this.handleAction('cancel'); } }, handleAction: function handleAction(action) { if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) { return; } this.action = action; if (typeof this.beforeClose === 'function') { this.close = this.getSafeClose(); this.beforeClose(action, this, this.close); } else { this.doClose(); } }, validate: function validate() { if (this.$type === 'prompt') { var inputPattern = this.inputPattern; if (inputPattern && !inputPattern.test(this.inputValue || '')) { this.editorErrorMessage = this.inputErrorMessage || (0, _locale3.t)('el.messagebox.error'); (0, _dom.addClass)(this.$refs.input.$el.querySelector('input'), 'invalid'); return false; } var inputValidator = this.inputValidator; if (typeof inputValidator === 'function') { var validateResult = inputValidator(this.inputValue); if (validateResult === false) { this.editorErrorMessage = this.inputErrorMessage || (0, _locale3.t)('el.messagebox.error'); (0, _dom.addClass)(this.$refs.input.$el.querySelector('input'), 'invalid'); return false; } if (typeof validateResult === 'string') { this.editorErrorMessage = validateResult; return false; } } } this.editorErrorMessage = ''; (0, _dom.removeClass)(this.$refs.input.$el.querySelector('input'), 'invalid'); return true; } }, watch: { inputValue: { immediate: true, handler: function handler(val) { var _this3 = this; this.$nextTick(function (_) { if (_this3.$type === 'prompt' && val !== null) { _this3.validate(); } }); } }, visible: function visible(val) { var _this4 = this; if (val) this.uid++; if (this.$type === 'alert' || this.$type === 'confirm') { this.$nextTick(function () { _this4.$refs.confirm.$el.focus(); }); } if (this.$type !== 'prompt') return; if (val) { setTimeout(function () { if (_this4.$refs.input && _this4.$refs.input.$el) { _this4.$refs.input.$el.querySelector('input').focus(); } }, 500); } else { this.editorErrorMessage = ''; (0, _dom.removeClass)(this.$refs.input.$el.querySelector('input'), 'invalid'); } } }, data: function data() { return { uid: 1, title: undefined, message: '', type: '', customClass: '', showInput: false, inputValue: null, inputPlaceholder: '', inputPattern: null, inputValidator: null, inputErrorMessage: '', showConfirmButton: true, showCancelButton: false, action: '', confirmButtonText: '', cancelButtonText: '', confirmButtonLoading: false, cancelButtonLoading: false, confirmButtonClass: '', confirmButtonDisabled: false, cancelButtonClass: '', editorErrorMessage: null, callback: null }; } }; /***/ }, /***/ 210: /***/ function(module, exports) { module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h; return _c('transition', { attrs: { "name": "msgbox-fade" } }, [_c('div', { directives: [{ name: "show", rawName: "v-show", value: (_vm.visible), expression: "visible" }], staticClass: "el-message-box__wrapper", attrs: { "tabindex": "-1" }, on: { "click": function($event) { if ($event.target !== $event.currentTarget) { return null; } _vm.handleWrapperClick($event) } } }, [_c('div', { staticClass: "el-message-box", class: _vm.customClass }, [(_vm.title !== undefined) ? _c('div', { staticClass: "el-message-box__header" }, [_c('div', { staticClass: "el-message-box__title" }, [_vm._v(_vm._s(_vm.title))]), (_vm.showClose) ? _c('button', { staticClass: "el-message-box__headerbtn", attrs: { "type": "button", "aria-label": "Close" }, on: { "click": function($event) { _vm.handleAction('cancel') } } }, [_c('i', { staticClass: "el-message-box__close el-icon-close" })]) : _vm._e()]) : _vm._e(), (_vm.message !== '') ? _c('div', { staticClass: "el-message-box__content" }, [_c('div', { staticClass: "el-message-box__status", class: [_vm.typeClass] }), _c('div', { staticClass: "el-message-box__message", style: ({ 'margin-left': _vm.typeClass ? '50px' : '0' }) }, [_vm._t("default", [_c('p', [_vm._v(_vm._s(_vm.message))])])], 2), _c('div', { directives: [{ name: "show", rawName: "v-show", value: (_vm.showInput), expression: "showInput" }], staticClass: "el-message-box__input" }, [_c('el-input', { ref: "input", attrs: { "placeholder": _vm.inputPlaceholder }, nativeOn: { "keyup": function($event) { if (!('button' in $event) && _vm._k($event.keyCode, "enter", 13)) { return null; } _vm.handleAction('confirm') } }, model: { value: (_vm.inputValue), callback: function($$v) { _vm.inputValue = $$v }, expression: "inputValue" } }), _c('div', { staticClass: "el-message-box__errormsg", style: ({ visibility: !!_vm.editorErrorMessage ? 'visible' : 'hidden' }) }, [_vm._v(_vm._s(_vm.editorErrorMessage))])], 1)]) : _vm._e(), _c('div', { staticClass: "el-message-box__btns" }, [_c('el-button', { directives: [{ name: "show", rawName: "v-show", value: (_vm.showCancelButton), expression: "showCancelButton" }], class: [_vm.cancelButtonClasses], attrs: { "loading": _vm.cancelButtonLoading }, nativeOn: { "click": function($event) { _vm.handleAction('cancel') } } }, [_vm._v("\n " + _vm._s(_vm.cancelButtonText || _vm.t('el.messagebox.cancel')) + "\n ")]), _c('el-button', { directives: [{ name: "show", rawName: "v-show", value: (_vm.showConfirmButton), expression: "showConfirmButton" }], ref: "confirm", class: [_vm.confirmButtonClasses], attrs: { "loading": _vm.confirmButtonLoading }, nativeOn: { "click": function($event) { _vm.handleAction('confirm') } } }, [_vm._v("\n " + _vm._s(_vm.confirmButtonText || _vm.t('el.messagebox.confirm')) + "\n ")])], 1)])])]) },staticRenderFns: []} /***/ } /******/ });