message-box.js 32 KB

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