UNPKG

33.2 kBJavaScriptView Raw
1module.exports =
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5/******/
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8/******/
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId]) {
11/******/ return installedModules[moduleId].exports;
12/******/ }
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ i: moduleId,
16/******/ l: false,
17/******/ exports: {}
18/******/ };
19/******/
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22/******/
23/******/ // Flag the module as loaded
24/******/ module.l = true;
25/******/
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29/******/
30/******/
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33/******/
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36/******/
37/******/ // define getter function for harmony exports
38/******/ __webpack_require__.d = function(exports, name, getter) {
39/******/ if(!__webpack_require__.o(exports, name)) {
40/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
41/******/ }
42/******/ };
43/******/
44/******/ // define __esModule on exports
45/******/ __webpack_require__.r = function(exports) {
46/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48/******/ }
49/******/ Object.defineProperty(exports, '__esModule', { value: true });
50/******/ };
51/******/
52/******/ // create a fake namespace object
53/******/ // mode & 1: value is a module id, require it
54/******/ // mode & 2: merge all properties of value into the ns
55/******/ // mode & 4: return value when already ns object
56/******/ // mode & 8|1: behave like require
57/******/ __webpack_require__.t = function(value, mode) {
58/******/ if(mode & 1) value = __webpack_require__(value);
59/******/ if(mode & 8) return value;
60/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61/******/ var ns = Object.create(null);
62/******/ __webpack_require__.r(ns);
63/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65/******/ return ns;
66/******/ };
67/******/
68/******/ // getDefaultExport function for compatibility with non-harmony modules
69/******/ __webpack_require__.n = function(module) {
70/******/ var getter = module && module.__esModule ?
71/******/ function getDefault() { return module['default']; } :
72/******/ function getModuleExports() { return module; };
73/******/ __webpack_require__.d(getter, 'a', getter);
74/******/ return getter;
75/******/ };
76/******/
77/******/ // Object.prototype.hasOwnProperty.call
78/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79/******/
80/******/ // __webpack_public_path__
81/******/ __webpack_require__.p = "/dist/";
82/******/
83/******/
84/******/ // Load entry module and return exports
85/******/ return __webpack_require__(__webpack_require__.s = 73);
86/******/ })
87/************************************************************************/
88/******/ ({
89
90/***/ 0:
91/***/ (function(module, __webpack_exports__, __webpack_require__) {
92
93"use strict";
94/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
95/* globals __VUE_SSR_CONTEXT__ */
96
97// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
98// This module is a runtime utility for cleaner component module output and will
99// be included in the final webpack user bundle.
100
101function normalizeComponent (
102 scriptExports,
103 render,
104 staticRenderFns,
105 functionalTemplate,
106 injectStyles,
107 scopeId,
108 moduleIdentifier, /* server only */
109 shadowMode /* vue-cli only */
110) {
111 // Vue.extend constructor export interop
112 var options = typeof scriptExports === 'function'
113 ? scriptExports.options
114 : scriptExports
115
116 // render functions
117 if (render) {
118 options.render = render
119 options.staticRenderFns = staticRenderFns
120 options._compiled = true
121 }
122
123 // functional template
124 if (functionalTemplate) {
125 options.functional = true
126 }
127
128 // scopedId
129 if (scopeId) {
130 options._scopeId = 'data-v-' + scopeId
131 }
132
133 var hook
134 if (moduleIdentifier) { // server build
135 hook = function (context) {
136 // 2.3 injection
137 context =
138 context || // cached call
139 (this.$vnode && this.$vnode.ssrContext) || // stateful
140 (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
141 // 2.2 with runInNewContext: true
142 if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
143 context = __VUE_SSR_CONTEXT__
144 }
145 // inject component styles
146 if (injectStyles) {
147 injectStyles.call(this, context)
148 }
149 // register component module identifier for async chunk inferrence
150 if (context && context._registeredComponents) {
151 context._registeredComponents.add(moduleIdentifier)
152 }
153 }
154 // used by ssr in case component is cached and beforeCreate
155 // never gets called
156 options._ssrRegister = hook
157 } else if (injectStyles) {
158 hook = shadowMode
159 ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
160 : injectStyles
161 }
162
163 if (hook) {
164 if (options.functional) {
165 // for template-only hot-reload because in that case the render fn doesn't
166 // go through the normalizer
167 options._injectStyles = hook
168 // register for functioal component in vue file
169 var originalRender = options.render
170 options.render = function renderWithStyleInjection (h, context) {
171 hook.call(context)
172 return originalRender(h, context)
173 }
174 } else {
175 // inject component registration as beforeCreate hook
176 var existing = options.beforeCreate
177 options.beforeCreate = existing
178 ? [].concat(existing, hook)
179 : [hook]
180 }
181 }
182
183 return {
184 exports: scriptExports,
185 options: options
186 }
187}
188
189
190/***/ }),
191
192/***/ 10:
193/***/ (function(module, exports) {
194
195module.exports = require("element-ui/lib/input");
196
197/***/ }),
198
199/***/ 16:
200/***/ (function(module, exports) {
201
202module.exports = require("element-ui/lib/utils/popup");
203
204/***/ }),
205
206/***/ 18:
207/***/ (function(module, exports) {
208
209module.exports = require("element-ui/lib/button");
210
211/***/ }),
212
213/***/ 2:
214/***/ (function(module, exports) {
215
216module.exports = require("element-ui/lib/utils/dom");
217
218/***/ }),
219
220/***/ 20:
221/***/ (function(module, exports) {
222
223module.exports = require("element-ui/lib/locale");
224
225/***/ }),
226
227/***/ 23:
228/***/ (function(module, exports) {
229
230module.exports = require("element-ui/lib/utils/vdom");
231
232/***/ }),
233
234/***/ 47:
235/***/ (function(module, exports) {
236
237module.exports = require("element-ui/lib/utils/aria-dialog");
238
239/***/ }),
240
241/***/ 6:
242/***/ (function(module, exports) {
243
244module.exports = require("element-ui/lib/mixins/locale");
245
246/***/ }),
247
248/***/ 7:
249/***/ (function(module, exports) {
250
251module.exports = require("vue");
252
253/***/ }),
254
255/***/ 73:
256/***/ (function(module, __webpack_exports__, __webpack_require__) {
257
258"use strict";
259__webpack_require__.r(__webpack_exports__);
260
261// EXTERNAL MODULE: external "vue"
262var external_vue_ = __webpack_require__(7);
263var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
264
265// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/message-box/src/main.vue?vue&type=template&id=6b29b012&
266var render = function() {
267 var _vm = this
268 var _h = _vm.$createElement
269 var _c = _vm._self._c || _h
270 return _c("transition", { attrs: { name: "msgbox-fade" } }, [
271 _c(
272 "div",
273 {
274 directives: [
275 {
276 name: "show",
277 rawName: "v-show",
278 value: _vm.visible,
279 expression: "visible"
280 }
281 ],
282 staticClass: "el-message-box__wrapper",
283 attrs: {
284 tabindex: "-1",
285 role: "dialog",
286 "aria-modal": "true",
287 "aria-label": _vm.title || "dialog"
288 },
289 on: {
290 click: function($event) {
291 if ($event.target !== $event.currentTarget) {
292 return null
293 }
294 return _vm.handleWrapperClick($event)
295 }
296 }
297 },
298 [
299 _c(
300 "div",
301 {
302 staticClass: "el-message-box",
303 class: [_vm.customClass, _vm.center && "el-message-box--center"]
304 },
305 [
306 _vm.title !== null
307 ? _c("div", { staticClass: "el-message-box__header" }, [
308 _c("div", { staticClass: "el-message-box__title" }, [
309 _vm.icon && _vm.center
310 ? _c("div", {
311 class: ["el-message-box__status", _vm.icon]
312 })
313 : _vm._e(),
314 _c("span", [_vm._v(_vm._s(_vm.title))])
315 ]),
316 _vm.showClose
317 ? _c(
318 "button",
319 {
320 staticClass: "el-message-box__headerbtn",
321 attrs: { type: "button", "aria-label": "Close" },
322 on: {
323 click: function($event) {
324 _vm.handleAction(
325 _vm.distinguishCancelAndClose
326 ? "close"
327 : "cancel"
328 )
329 },
330 keydown: function($event) {
331 if (
332 !("button" in $event) &&
333 _vm._k(
334 $event.keyCode,
335 "enter",
336 13,
337 $event.key,
338 "Enter"
339 )
340 ) {
341 return null
342 }
343 _vm.handleAction(
344 _vm.distinguishCancelAndClose
345 ? "close"
346 : "cancel"
347 )
348 }
349 }
350 },
351 [
352 _c("i", {
353 staticClass: "el-message-box__close el-icon-close"
354 })
355 ]
356 )
357 : _vm._e()
358 ])
359 : _vm._e(),
360 _c("div", { staticClass: "el-message-box__content" }, [
361 _vm.icon && !_vm.center && _vm.message !== ""
362 ? _c("div", { class: ["el-message-box__status", _vm.icon] })
363 : _vm._e(),
364 _vm.message !== ""
365 ? _c(
366 "div",
367 { staticClass: "el-message-box__message" },
368 [
369 _vm._t("default", [
370 !_vm.dangerouslyUseHTMLString
371 ? _c("p", [_vm._v(_vm._s(_vm.message))])
372 : _c("p", {
373 domProps: { innerHTML: _vm._s(_vm.message) }
374 })
375 ])
376 ],
377 2
378 )
379 : _vm._e(),
380 _c(
381 "div",
382 {
383 directives: [
384 {
385 name: "show",
386 rawName: "v-show",
387 value: _vm.showInput,
388 expression: "showInput"
389 }
390 ],
391 staticClass: "el-message-box__input"
392 },
393 [
394 _c("el-input", {
395 ref: "input",
396 attrs: {
397 type: _vm.inputType,
398 placeholder: _vm.inputPlaceholder
399 },
400 nativeOn: {
401 keydown: function($event) {
402 if (
403 !("button" in $event) &&
404 _vm._k(
405 $event.keyCode,
406 "enter",
407 13,
408 $event.key,
409 "Enter"
410 )
411 ) {
412 return null
413 }
414 return _vm.handleInputEnter($event)
415 }
416 },
417 model: {
418 value: _vm.inputValue,
419 callback: function($$v) {
420 _vm.inputValue = $$v
421 },
422 expression: "inputValue"
423 }
424 }),
425 _c(
426 "div",
427 {
428 staticClass: "el-message-box__errormsg",
429 style: {
430 visibility: !!_vm.editorErrorMessage
431 ? "visible"
432 : "hidden"
433 }
434 },
435 [_vm._v(_vm._s(_vm.editorErrorMessage))]
436 )
437 ],
438 1
439 )
440 ]),
441 _c(
442 "div",
443 { staticClass: "el-message-box__btns" },
444 [
445 _vm.showCancelButton
446 ? _c(
447 "el-button",
448 {
449 class: [_vm.cancelButtonClasses],
450 attrs: {
451 loading: _vm.cancelButtonLoading,
452 round: _vm.roundButton,
453 size: "small"
454 },
455 on: {
456 keydown: function($event) {
457 if (
458 !("button" in $event) &&
459 _vm._k(
460 $event.keyCode,
461 "enter",
462 13,
463 $event.key,
464 "Enter"
465 )
466 ) {
467 return null
468 }
469 _vm.handleAction("cancel")
470 }
471 },
472 nativeOn: {
473 click: function($event) {
474 _vm.handleAction("cancel")
475 }
476 }
477 },
478 [
479 _vm._v(
480 "\n " +
481 _vm._s(
482 _vm.cancelButtonText ||
483 _vm.t("el.messagebox.cancel")
484 ) +
485 "\n "
486 )
487 ]
488 )
489 : _vm._e(),
490 _c(
491 "el-button",
492 {
493 directives: [
494 {
495 name: "show",
496 rawName: "v-show",
497 value: _vm.showConfirmButton,
498 expression: "showConfirmButton"
499 }
500 ],
501 ref: "confirm",
502 class: [_vm.confirmButtonClasses],
503 attrs: {
504 loading: _vm.confirmButtonLoading,
505 round: _vm.roundButton,
506 size: "small"
507 },
508 on: {
509 keydown: function($event) {
510 if (
511 !("button" in $event) &&
512 _vm._k(
513 $event.keyCode,
514 "enter",
515 13,
516 $event.key,
517 "Enter"
518 )
519 ) {
520 return null
521 }
522 _vm.handleAction("confirm")
523 }
524 },
525 nativeOn: {
526 click: function($event) {
527 _vm.handleAction("confirm")
528 }
529 }
530 },
531 [
532 _vm._v(
533 "\n " +
534 _vm._s(
535 _vm.confirmButtonText ||
536 _vm.t("el.messagebox.confirm")
537 ) +
538 "\n "
539 )
540 ]
541 )
542 ],
543 1
544 )
545 ]
546 )
547 ]
548 )
549 ])
550}
551var staticRenderFns = []
552render._withStripped = true
553
554
555// CONCATENATED MODULE: ./packages/message-box/src/main.vue?vue&type=template&id=6b29b012&
556
557// EXTERNAL MODULE: external "element-ui/lib/utils/popup"
558var popup_ = __webpack_require__(16);
559var popup_default = /*#__PURE__*/__webpack_require__.n(popup_);
560
561// EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
562var locale_ = __webpack_require__(6);
563var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
564
565// EXTERNAL MODULE: external "element-ui/lib/input"
566var input_ = __webpack_require__(10);
567var input_default = /*#__PURE__*/__webpack_require__.n(input_);
568
569// EXTERNAL MODULE: external "element-ui/lib/button"
570var button_ = __webpack_require__(18);
571var button_default = /*#__PURE__*/__webpack_require__.n(button_);
572
573// EXTERNAL MODULE: external "element-ui/lib/utils/dom"
574var dom_ = __webpack_require__(2);
575
576// EXTERNAL MODULE: external "element-ui/lib/locale"
577var lib_locale_ = __webpack_require__(20);
578
579// EXTERNAL MODULE: external "element-ui/lib/utils/aria-dialog"
580var aria_dialog_ = __webpack_require__(47);
581var aria_dialog_default = /*#__PURE__*/__webpack_require__.n(aria_dialog_);
582
583// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/message-box/src/main.vue?vue&type=script&lang=js&
584//
585//
586//
587//
588//
589//
590//
591//
592//
593//
594//
595//
596//
597//
598//
599//
600//
601//
602//
603//
604//
605//
606//
607//
608//
609//
610//
611//
612//
613//
614//
615//
616//
617//
618//
619//
620//
621//
622//
623//
624//
625//
626//
627//
628//
629//
630//
631//
632//
633//
634//
635//
636//
637//
638//
639//
640//
641//
642//
643//
644//
645//
646//
647//
648//
649//
650//
651//
652//
653//
654//
655//
656//
657//
658//
659//
660//
661//
662
663
664
665
666
667
668
669
670
671var messageBox = void 0;
672var typeMap = {
673 success: 'success',
674 info: 'info',
675 warning: 'warning',
676 error: 'error'
677};
678
679/* harmony default export */ var mainvue_type_script_lang_js_ = ({
680 mixins: [popup_default.a, locale_default.a],
681
682 props: {
683 modal: {
684 default: true
685 },
686 lockScroll: {
687 default: true
688 },
689 showClose: {
690 type: Boolean,
691 default: true
692 },
693 closeOnClickModal: {
694 default: true
695 },
696 closeOnPressEscape: {
697 default: true
698 },
699 closeOnHashChange: {
700 default: true
701 },
702 center: {
703 default: false,
704 type: Boolean
705 },
706 roundButton: {
707 default: false,
708 type: Boolean
709 }
710 },
711
712 components: {
713 ElInput: input_default.a,
714 ElButton: button_default.a
715 },
716
717 computed: {
718 icon: function icon() {
719 var type = this.type,
720 iconClass = this.iconClass;
721
722 return iconClass || (type && typeMap[type] ? 'el-icon-' + typeMap[type] : '');
723 },
724 confirmButtonClasses: function confirmButtonClasses() {
725 return 'el-button--primary ' + this.confirmButtonClass;
726 },
727 cancelButtonClasses: function cancelButtonClasses() {
728 return '' + this.cancelButtonClass;
729 }
730 },
731
732 methods: {
733 getSafeClose: function getSafeClose() {
734 var _this = this;
735
736 var currentId = this.uid;
737 return function () {
738 _this.$nextTick(function () {
739 if (currentId === _this.uid) _this.doClose();
740 });
741 };
742 },
743 doClose: function doClose() {
744 var _this2 = this;
745
746 if (!this.visible) return;
747 this.visible = false;
748 this._closing = true;
749
750 this.onClose && this.onClose();
751 messageBox.closeDialog(); // 解绑
752 if (this.lockScroll) {
753 setTimeout(this.restoreBodyStyle, 200);
754 }
755 this.opened = false;
756 this.doAfterClose();
757 setTimeout(function () {
758 if (_this2.action) _this2.callback(_this2.action, _this2);
759 });
760 },
761 handleWrapperClick: function handleWrapperClick() {
762 if (this.closeOnClickModal) {
763 this.handleAction(this.distinguishCancelAndClose ? 'close' : 'cancel');
764 }
765 },
766 handleInputEnter: function handleInputEnter() {
767 if (this.inputType !== 'textarea') {
768 return this.handleAction('confirm');
769 }
770 },
771 handleAction: function handleAction(action) {
772 if (this.$type === 'prompt' && action === 'confirm' && !this.validate()) {
773 return;
774 }
775 this.action = action;
776 if (typeof this.beforeClose === 'function') {
777 this.close = this.getSafeClose();
778 this.beforeClose(action, this, this.close);
779 } else {
780 this.doClose();
781 }
782 },
783 validate: function validate() {
784 if (this.$type === 'prompt') {
785 var inputPattern = this.inputPattern;
786 if (inputPattern && !inputPattern.test(this.inputValue || '')) {
787 this.editorErrorMessage = this.inputErrorMessage || Object(lib_locale_["t"])('el.messagebox.error');
788 Object(dom_["addClass"])(this.getInputElement(), 'invalid');
789 return false;
790 }
791 var inputValidator = this.inputValidator;
792 if (typeof inputValidator === 'function') {
793 var validateResult = inputValidator(this.inputValue);
794 if (validateResult === false) {
795 this.editorErrorMessage = this.inputErrorMessage || Object(lib_locale_["t"])('el.messagebox.error');
796 Object(dom_["addClass"])(this.getInputElement(), 'invalid');
797 return false;
798 }
799 if (typeof validateResult === 'string') {
800 this.editorErrorMessage = validateResult;
801 Object(dom_["addClass"])(this.getInputElement(), 'invalid');
802 return false;
803 }
804 }
805 }
806 this.editorErrorMessage = '';
807 Object(dom_["removeClass"])(this.getInputElement(), 'invalid');
808 return true;
809 },
810 getFirstFocus: function getFirstFocus() {
811 var btn = this.$el.querySelector('.el-message-box__btns .el-button');
812 var title = this.$el.querySelector('.el-message-box__btns .el-message-box__title');
813 return btn || title;
814 },
815 getInputElement: function getInputElement() {
816 var inputRefs = this.$refs.input.$refs;
817 return inputRefs.input || inputRefs.textarea;
818 },
819 handleClose: function handleClose() {
820 this.handleAction('close');
821 }
822 },
823
824 watch: {
825 inputValue: {
826 immediate: true,
827 handler: function handler(val) {
828 var _this3 = this;
829
830 this.$nextTick(function (_) {
831 if (_this3.$type === 'prompt' && val !== null) {
832 _this3.validate();
833 }
834 });
835 }
836 },
837
838 visible: function visible(val) {
839 var _this4 = this;
840
841 if (val) {
842 this.uid++;
843 if (this.$type === 'alert' || this.$type === 'confirm') {
844 this.$nextTick(function () {
845 _this4.$refs.confirm.$el.focus();
846 });
847 }
848 this.focusAfterClosed = document.activeElement;
849 messageBox = new aria_dialog_default.a(this.$el, this.focusAfterClosed, this.getFirstFocus());
850 }
851
852 // prompt
853 if (this.$type !== 'prompt') return;
854 if (val) {
855 setTimeout(function () {
856 if (_this4.$refs.input && _this4.$refs.input.$el) {
857 _this4.getInputElement().focus();
858 }
859 }, 500);
860 } else {
861 this.editorErrorMessage = '';
862 Object(dom_["removeClass"])(this.getInputElement(), 'invalid');
863 }
864 }
865 },
866
867 mounted: function mounted() {
868 var _this5 = this;
869
870 this.$nextTick(function () {
871 if (_this5.closeOnHashChange) {
872 window.addEventListener('hashchange', _this5.close);
873 }
874 });
875 },
876 beforeDestroy: function beforeDestroy() {
877 if (this.closeOnHashChange) {
878 window.removeEventListener('hashchange', this.close);
879 }
880 setTimeout(function () {
881 messageBox.closeDialog();
882 });
883 },
884 data: function data() {
885 return {
886 uid: 1,
887 title: undefined,
888 message: '',
889 type: '',
890 iconClass: '',
891 customClass: '',
892 showInput: false,
893 inputValue: null,
894 inputPlaceholder: '',
895 inputType: 'text',
896 inputPattern: null,
897 inputValidator: null,
898 inputErrorMessage: '',
899 showConfirmButton: true,
900 showCancelButton: false,
901 action: '',
902 confirmButtonText: '',
903 cancelButtonText: '',
904 confirmButtonLoading: false,
905 cancelButtonLoading: false,
906 confirmButtonClass: '',
907 confirmButtonDisabled: false,
908 cancelButtonClass: '',
909 editorErrorMessage: null,
910 callback: null,
911 dangerouslyUseHTMLString: false,
912 focusAfterClosed: null,
913 isOnComposition: false,
914 distinguishCancelAndClose: false
915 };
916 }
917});
918// CONCATENATED MODULE: ./packages/message-box/src/main.vue?vue&type=script&lang=js&
919 /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
920// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
921var componentNormalizer = __webpack_require__(0);
922
923// CONCATENATED MODULE: ./packages/message-box/src/main.vue
924
925
926
927
928
929/* normalize component */
930
931var component = Object(componentNormalizer["a" /* default */])(
932 src_mainvue_type_script_lang_js_,
933 render,
934 staticRenderFns,
935 false,
936 null,
937 null,
938 null
939
940)
941
942/* hot reload */
943if (false) { var api; }
944component.options.__file = "packages/message-box/src/main.vue"
945/* harmony default export */ var main = (component.exports);
946// EXTERNAL MODULE: external "element-ui/lib/utils/merge"
947var merge_ = __webpack_require__(9);
948var merge_default = /*#__PURE__*/__webpack_require__.n(merge_);
949
950// EXTERNAL MODULE: external "element-ui/lib/utils/vdom"
951var vdom_ = __webpack_require__(23);
952
953// CONCATENATED MODULE: ./packages/message-box/src/main.js
954var _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; };
955
956var defaults = {
957 title: null,
958 message: '',
959 type: '',
960 iconClass: '',
961 showInput: false,
962 showClose: true,
963 modalFade: true,
964 lockScroll: true,
965 closeOnClickModal: true,
966 closeOnPressEscape: true,
967 closeOnHashChange: true,
968 inputValue: null,
969 inputPlaceholder: '',
970 inputType: 'text',
971 inputPattern: null,
972 inputValidator: null,
973 inputErrorMessage: '',
974 showConfirmButton: true,
975 showCancelButton: false,
976 confirmButtonPosition: 'right',
977 confirmButtonHighlight: false,
978 cancelButtonHighlight: false,
979 confirmButtonText: '',
980 cancelButtonText: '',
981 confirmButtonClass: '',
982 cancelButtonClass: '',
983 customClass: '',
984 beforeClose: null,
985 dangerouslyUseHTMLString: false,
986 center: false,
987 roundButton: false,
988 distinguishCancelAndClose: false
989};
990
991
992
993
994
995
996var MessageBoxConstructor = external_vue_default.a.extend(main);
997
998var currentMsg = void 0,
999 instance = void 0;
1000var msgQueue = [];
1001
1002var defaultCallback = function defaultCallback(action) {
1003 if (currentMsg) {
1004 var callback = currentMsg.callback;
1005 if (typeof callback === 'function') {
1006 if (instance.showInput) {
1007 callback(instance.inputValue, action);
1008 } else {
1009 callback(action);
1010 }
1011 }
1012 if (currentMsg.resolve) {
1013 if (action === 'confirm') {
1014 if (instance.showInput) {
1015 currentMsg.resolve({ value: instance.inputValue, action: action });
1016 } else {
1017 currentMsg.resolve(action);
1018 }
1019 } else if (currentMsg.reject && (action === 'cancel' || action === 'close')) {
1020 currentMsg.reject(action);
1021 }
1022 }
1023 }
1024};
1025
1026var initInstance = function initInstance() {
1027 instance = new MessageBoxConstructor({
1028 el: document.createElement('div')
1029 });
1030
1031 instance.callback = defaultCallback;
1032};
1033
1034var main_showNextMsg = function showNextMsg() {
1035 if (!instance) {
1036 initInstance();
1037 }
1038 instance.action = '';
1039
1040 if (!instance.visible || instance.closeTimer) {
1041 if (msgQueue.length > 0) {
1042 currentMsg = msgQueue.shift();
1043
1044 var options = currentMsg.options;
1045 for (var prop in options) {
1046 if (options.hasOwnProperty(prop)) {
1047 instance[prop] = options[prop];
1048 }
1049 }
1050 if (options.callback === undefined) {
1051 instance.callback = defaultCallback;
1052 }
1053
1054 var oldCb = instance.callback;
1055 instance.callback = function (action, instance) {
1056 oldCb(action, instance);
1057 showNextMsg();
1058 };
1059 if (Object(vdom_["isVNode"])(instance.message)) {
1060 instance.$slots.default = [instance.message];
1061 instance.message = null;
1062 } else {
1063 delete instance.$slots.default;
1064 }
1065 ['modal', 'showClose', 'closeOnClickModal', 'closeOnPressEscape', 'closeOnHashChange'].forEach(function (prop) {
1066 if (instance[prop] === undefined) {
1067 instance[prop] = true;
1068 }
1069 });
1070 document.body.appendChild(instance.$el);
1071
1072 external_vue_default.a.nextTick(function () {
1073 instance.visible = true;
1074 });
1075 }
1076 }
1077};
1078
1079var main_MessageBox = function MessageBox(options, callback) {
1080 if (external_vue_default.a.prototype.$isServer) return;
1081 if (typeof options === 'string' || Object(vdom_["isVNode"])(options)) {
1082 options = {
1083 message: options
1084 };
1085 if (typeof arguments[1] === 'string') {
1086 options.title = arguments[1];
1087 }
1088 } else if (options.callback && !callback) {
1089 callback = options.callback;
1090 }
1091
1092 if (typeof Promise !== 'undefined') {
1093 return new Promise(function (resolve, reject) {
1094 // eslint-disable-line
1095 msgQueue.push({
1096 options: merge_default()({}, defaults, MessageBox.defaults, options),
1097 callback: callback,
1098 resolve: resolve,
1099 reject: reject
1100 });
1101
1102 main_showNextMsg();
1103 });
1104 } else {
1105 msgQueue.push({
1106 options: merge_default()({}, defaults, MessageBox.defaults, options),
1107 callback: callback
1108 });
1109
1110 main_showNextMsg();
1111 }
1112};
1113
1114main_MessageBox.setDefaults = function (defaults) {
1115 main_MessageBox.defaults = defaults;
1116};
1117
1118main_MessageBox.alert = function (message, title, options) {
1119 if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
1120 options = title;
1121 title = '';
1122 } else if (title === undefined) {
1123 title = '';
1124 }
1125 return main_MessageBox(merge_default()({
1126 title: title,
1127 message: message,
1128 $type: 'alert',
1129 closeOnPressEscape: false,
1130 closeOnClickModal: false
1131 }, options));
1132};
1133
1134main_MessageBox.confirm = function (message, title, options) {
1135 if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
1136 options = title;
1137 title = '';
1138 } else if (title === undefined) {
1139 title = '';
1140 }
1141 return main_MessageBox(merge_default()({
1142 title: title,
1143 message: message,
1144 $type: 'confirm',
1145 showCancelButton: true
1146 }, options));
1147};
1148
1149main_MessageBox.prompt = function (message, title, options) {
1150 if ((typeof title === 'undefined' ? 'undefined' : _typeof(title)) === 'object') {
1151 options = title;
1152 title = '';
1153 } else if (title === undefined) {
1154 title = '';
1155 }
1156 return main_MessageBox(merge_default()({
1157 title: title,
1158 message: message,
1159 showCancelButton: true,
1160 showInput: true,
1161 $type: 'prompt'
1162 }, options));
1163};
1164
1165main_MessageBox.close = function () {
1166 instance.doClose();
1167 instance.visible = false;
1168 msgQueue = [];
1169 currentMsg = null;
1170};
1171
1172/* harmony default export */ var src_main = (main_MessageBox);
1173
1174// CONCATENATED MODULE: ./packages/message-box/index.js
1175
1176/* harmony default export */ var message_box = __webpack_exports__["default"] = (src_main);
1177
1178/***/ }),
1179
1180/***/ 9:
1181/***/ (function(module, exports) {
1182
1183module.exports = require("element-ui/lib/utils/merge");
1184
1185/***/ })
1186
1187/******/ });
\No newline at end of file