app模板、应用模板、组件模板、widget模板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

869 lines
24 KiB

4 years ago
  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 = 322);
  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 () {
  152. injectStyles.call(
  153. this,
  154. (options.functional ? this.parent : this).$root.$options.shadowRoot
  155. )
  156. }
  157. : injectStyles
  158. }
  159. if (hook) {
  160. if (options.functional) {
  161. // for template-only hot-reload because in that case the render fn doesn't
  162. // go through the normalizer
  163. options._injectStyles = hook
  164. // register for functional component in vue file
  165. var originalRender = options.render
  166. options.render = function renderWithStyleInjection (h, context) {
  167. hook.call(context)
  168. return originalRender(h, context)
  169. }
  170. } else {
  171. // inject component registration as beforeCreate hook
  172. var existing = options.beforeCreate
  173. options.beforeCreate = existing
  174. ? [].concat(existing, hook)
  175. : [hook]
  176. }
  177. }
  178. return {
  179. exports: scriptExports,
  180. options: options
  181. }
  182. }
  183. /***/ }),
  184. /***/ 10:
  185. /***/ (function(module, exports) {
  186. module.exports = require("tis-ui/lib/mixins/emitter");
  187. /***/ }),
  188. /***/ 2:
  189. /***/ (function(module, exports) {
  190. module.exports = require("tis-ui/lib/utils/dom");
  191. /***/ }),
  192. /***/ 22:
  193. /***/ (function(module, exports) {
  194. module.exports = require("tis-ui/lib/mixins/migrating");
  195. /***/ }),
  196. /***/ 322:
  197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  198. "use strict";
  199. // ESM COMPAT FLAG
  200. __webpack_require__.r(__webpack_exports__);
  201. // EXTERNAL MODULE: external "tis-ui/lib/mixins/emitter"
  202. var emitter_ = __webpack_require__(10);
  203. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  204. // EXTERNAL MODULE: external "tis-ui/lib/mixins/migrating"
  205. var migrating_ = __webpack_require__(22);
  206. var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
  207. // CONCATENATED MODULE: ./src/utils/aria-utils.js
  208. var aria = aria || {};
  209. aria.Utils = aria.Utils || {};
  210. /**
  211. * @desc Set focus on descendant nodes until the first focusable element is
  212. * found.
  213. * @param element
  214. * DOM node for which to find the first focusable descendant.
  215. * @returns
  216. * true if a focusable element is found and focus is set.
  217. */
  218. aria.Utils.focusFirstDescendant = function (element) {
  219. for (var i = 0; i < element.childNodes.length; i++) {
  220. var child = element.childNodes[i];
  221. if (aria.Utils.attemptFocus(child) || aria.Utils.focusFirstDescendant(child)) {
  222. return true;
  223. }
  224. }
  225. return false;
  226. };
  227. /**
  228. * @desc Find the last descendant node that is focusable.
  229. * @param element
  230. * DOM node for which to find the last focusable descendant.
  231. * @returns
  232. * true if a focusable element is found and focus is set.
  233. */
  234. aria.Utils.focusLastDescendant = function (element) {
  235. for (var i = element.childNodes.length - 1; i >= 0; i--) {
  236. var child = element.childNodes[i];
  237. if (aria.Utils.attemptFocus(child) || aria.Utils.focusLastDescendant(child)) {
  238. return true;
  239. }
  240. }
  241. return false;
  242. };
  243. /**
  244. * @desc Set Attempt to set focus on the current node.
  245. * @param element
  246. * The node to attempt to focus on.
  247. * @returns
  248. * true if element is focused.
  249. */
  250. aria.Utils.attemptFocus = function (element) {
  251. if (!aria.Utils.isFocusable(element)) {
  252. return false;
  253. }
  254. aria.Utils.IgnoreUtilFocusChanges = true;
  255. try {
  256. element.focus();
  257. } catch (e) {}
  258. aria.Utils.IgnoreUtilFocusChanges = false;
  259. return document.activeElement === element;
  260. };
  261. aria.Utils.isFocusable = function (element) {
  262. if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute('tabIndex') !== null) {
  263. return true;
  264. }
  265. if (element.disabled) {
  266. return false;
  267. }
  268. switch (element.nodeName) {
  269. case 'A':
  270. return !!element.href && element.rel !== 'ignore';
  271. case 'INPUT':
  272. return element.type !== 'hidden' && element.type !== 'file';
  273. case 'BUTTON':
  274. case 'SELECT':
  275. case 'TEXTAREA':
  276. return true;
  277. default:
  278. return false;
  279. }
  280. };
  281. /**
  282. * 触发一个事件
  283. * mouseenter, mouseleave, mouseover, keyup, change, click
  284. * @param {Element} elm
  285. * @param {String} name
  286. * @param {*} opts
  287. */
  288. aria.Utils.triggerEvent = function (elm, name) {
  289. var eventName = void 0;
  290. if (/^mouse|click/.test(name)) {
  291. eventName = 'MouseEvents';
  292. } else if (/^key/.test(name)) {
  293. eventName = 'KeyboardEvent';
  294. } else {
  295. eventName = 'HTMLEvents';
  296. }
  297. var evt = document.createEvent(eventName);
  298. for (var _len = arguments.length, opts = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  299. opts[_key - 2] = arguments[_key];
  300. }
  301. evt.initEvent.apply(evt, [name].concat(opts));
  302. elm.dispatchEvent ? elm.dispatchEvent(evt) : elm.fireEvent('on' + name, evt);
  303. return elm;
  304. };
  305. aria.Utils.keys = {
  306. tab: 9,
  307. enter: 13,
  308. space: 32,
  309. left: 37,
  310. up: 38,
  311. right: 39,
  312. down: 40,
  313. esc: 27
  314. };
  315. /* harmony default export */ var aria_utils = (aria.Utils);
  316. // CONCATENATED MODULE: ./src/utils/menu/aria-submenu.js
  317. var SubMenu = function SubMenu(parent, domNode) {
  318. this.domNode = domNode;
  319. this.parent = parent;
  320. this.subMenuItems = [];
  321. this.subIndex = 0;
  322. this.init();
  323. };
  324. SubMenu.prototype.init = function () {
  325. this.subMenuItems = this.domNode.querySelectorAll('li');
  326. this.addListeners();
  327. };
  328. SubMenu.prototype.gotoSubIndex = function (idx) {
  329. if (idx === this.subMenuItems.length) {
  330. idx = 0;
  331. } else if (idx < 0) {
  332. idx = this.subMenuItems.length - 1;
  333. }
  334. this.subMenuItems[idx].focus();
  335. this.subIndex = idx;
  336. };
  337. SubMenu.prototype.addListeners = function () {
  338. var _this = this;
  339. var keys = aria_utils.keys;
  340. var parentNode = this.parent.domNode;
  341. Array.prototype.forEach.call(this.subMenuItems, function (el) {
  342. el.addEventListener('keydown', function (event) {
  343. var prevDef = false;
  344. switch (event.keyCode) {
  345. case keys.down:
  346. _this.gotoSubIndex(_this.subIndex + 1);
  347. prevDef = true;
  348. break;
  349. case keys.up:
  350. _this.gotoSubIndex(_this.subIndex - 1);
  351. prevDef = true;
  352. break;
  353. case keys.tab:
  354. aria_utils.triggerEvent(parentNode, 'mouseleave');
  355. break;
  356. case keys.enter:
  357. case keys.space:
  358. prevDef = true;
  359. event.currentTarget.click();
  360. break;
  361. }
  362. if (prevDef) {
  363. event.preventDefault();
  364. event.stopPropagation();
  365. }
  366. return false;
  367. });
  368. });
  369. };
  370. /* harmony default export */ var aria_submenu = (SubMenu);
  371. // CONCATENATED MODULE: ./src/utils/menu/aria-menuitem.js
  372. var MenuItem = function MenuItem(domNode) {
  373. this.domNode = domNode;
  374. this.submenu = null;
  375. this.init();
  376. };
  377. MenuItem.prototype.init = function () {
  378. this.domNode.setAttribute('tabindex', '0');
  379. var menuChild = this.domNode.querySelector('.el-menu');
  380. if (menuChild) {
  381. this.submenu = new aria_submenu(this, menuChild);
  382. }
  383. this.addListeners();
  384. };
  385. MenuItem.prototype.addListeners = function () {
  386. var _this = this;
  387. var keys = aria_utils.keys;
  388. this.domNode.addEventListener('keydown', function (event) {
  389. var prevDef = false;
  390. switch (event.keyCode) {
  391. case keys.down:
  392. aria_utils.triggerEvent(event.currentTarget, 'mouseenter');
  393. _this.submenu && _this.submenu.gotoSubIndex(0);
  394. prevDef = true;
  395. break;
  396. case keys.up:
  397. aria_utils.triggerEvent(event.currentTarget, 'mouseenter');
  398. _this.submenu && _this.submenu.gotoSubIndex(_this.submenu.subMenuItems.length - 1);
  399. prevDef = true;
  400. break;
  401. case keys.tab:
  402. aria_utils.triggerEvent(event.currentTarget, 'mouseleave');
  403. break;
  404. case keys.enter:
  405. case keys.space:
  406. prevDef = true;
  407. event.currentTarget.click();
  408. break;
  409. }
  410. if (prevDef) {
  411. event.preventDefault();
  412. }
  413. });
  414. };
  415. /* harmony default export */ var aria_menuitem = (MenuItem);
  416. // CONCATENATED MODULE: ./src/utils/menu/aria-menubar.js
  417. var Menu = function Menu(domNode) {
  418. this.domNode = domNode;
  419. this.init();
  420. };
  421. Menu.prototype.init = function () {
  422. var menuChildren = this.domNode.childNodes;
  423. [].filter.call(menuChildren, function (child) {
  424. return child.nodeType === 1;
  425. }).forEach(function (child) {
  426. new aria_menuitem(child); // eslint-disable-line
  427. });
  428. };
  429. /* harmony default export */ var aria_menubar = (Menu);
  430. // EXTERNAL MODULE: external "tis-ui/lib/utils/dom"
  431. var dom_ = __webpack_require__(2);
  432. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/menu/src/menu.vue?vue&type=script&lang=js&
  433. /* harmony default export */ var menuvue_type_script_lang_js_ = ({
  434. name: 'TisMenu',
  435. render: function render(h) {
  436. var component = h(
  437. 'ul',
  438. {
  439. attrs: {
  440. role: 'menubar'
  441. },
  442. key: +this.collapse,
  443. style: { backgroundColor: this.backgroundColor || '' },
  444. 'class': {
  445. 'el-menu--horizontal': this.mode === 'horizontal',
  446. 'el-menu--collapse': this.collapse,
  447. "el-menu": true
  448. }
  449. },
  450. [this.$slots.default]
  451. );
  452. if (this.collapseTransition) {
  453. return h('tis-menu-collapse-transition', [component]);
  454. } else {
  455. return component;
  456. }
  457. },
  458. componentName: 'TisMenu',
  459. mixins: [emitter_default.a, migrating_default.a],
  460. provide: function provide() {
  461. return {
  462. rootMenu: this
  463. };
  464. },
  465. components: {
  466. 'tis-menu-collapse-transition': {
  467. functional: true,
  468. render: function render(createElement, context) {
  469. var data = {
  470. props: {
  471. mode: 'out-in'
  472. },
  473. on: {
  474. beforeEnter: function beforeEnter(el) {
  475. el.style.opacity = 0.2;
  476. },
  477. enter: function enter(el) {
  478. Object(dom_["addClass"])(el, 'el-opacity-transition');
  479. el.style.opacity = 1;
  480. },
  481. afterEnter: function afterEnter(el) {
  482. Object(dom_["removeClass"])(el, 'el-opacity-transition');
  483. el.style.opacity = '';
  484. },
  485. beforeLeave: function beforeLeave(el) {
  486. if (!el.dataset) el.dataset = {};
  487. if (Object(dom_["hasClass"])(el, 'el-menu--collapse')) {
  488. Object(dom_["removeClass"])(el, 'el-menu--collapse');
  489. el.dataset.oldOverflow = el.style.overflow;
  490. el.dataset.scrollWidth = el.clientWidth;
  491. Object(dom_["addClass"])(el, 'el-menu--collapse');
  492. } else {
  493. Object(dom_["addClass"])(el, 'el-menu--collapse');
  494. el.dataset.oldOverflow = el.style.overflow;
  495. el.dataset.scrollWidth = el.clientWidth;
  496. Object(dom_["removeClass"])(el, 'el-menu--collapse');
  497. }
  498. el.style.width = el.scrollWidth + 'px';
  499. el.style.overflow = 'hidden';
  500. },
  501. leave: function leave(el) {
  502. Object(dom_["addClass"])(el, 'horizontal-collapse-transition');
  503. el.style.width = el.dataset.scrollWidth + 'px';
  504. }
  505. }
  506. };
  507. return createElement('transition', data, context.children);
  508. }
  509. }
  510. },
  511. props: {
  512. mode: {
  513. type: String,
  514. default: 'vertical'
  515. },
  516. defaultActive: {
  517. type: String,
  518. default: ''
  519. },
  520. defaultOpeneds: Array,
  521. uniqueOpened: Boolean,
  522. router: Boolean,
  523. menuTrigger: {
  524. type: String,
  525. default: 'hover'
  526. },
  527. collapse: Boolean,
  528. backgroundColor: String,
  529. textColor: String,
  530. activeTextColor: String,
  531. collapseTransition: {
  532. type: Boolean,
  533. default: true
  534. }
  535. },
  536. data: function data() {
  537. return {
  538. activeIndex: this.defaultActive,
  539. openedMenus: this.defaultOpeneds && !this.collapse ? this.defaultOpeneds.slice(0) : [],
  540. items: {},
  541. submenus: {}
  542. };
  543. },
  544. computed: {
  545. hoverBackground: function hoverBackground() {
  546. return this.backgroundColor ? this.mixColor(this.backgroundColor, 0.2) : '';
  547. },
  548. isMenuPopup: function isMenuPopup() {
  549. return this.mode === 'horizontal' || this.mode === 'vertical' && this.collapse;
  550. }
  551. },
  552. watch: {
  553. defaultActive: function defaultActive(value) {
  554. if (!this.items[value]) {
  555. this.activeIndex = null;
  556. }
  557. this.updateActiveIndex(value);
  558. },
  559. defaultOpeneds: function defaultOpeneds(value) {
  560. if (!this.collapse) {
  561. this.openedMenus = value;
  562. }
  563. },
  564. collapse: function collapse(value) {
  565. if (value) this.openedMenus = [];
  566. this.broadcast('TisSubmenu', 'toggle-collapse', value);
  567. }
  568. },
  569. methods: {
  570. updateActiveIndex: function updateActiveIndex(val) {
  571. var item = this.items[val] || this.items[this.activeIndex] || this.items[this.defaultActive];
  572. if (item) {
  573. this.activeIndex = item.index;
  574. this.initOpenedMenu();
  575. } else {
  576. this.activeIndex = null;
  577. }
  578. },
  579. getMigratingConfig: function getMigratingConfig() {
  580. return {
  581. props: {
  582. 'theme': 'theme is removed.'
  583. }
  584. };
  585. },
  586. getColorChannels: function getColorChannels(color) {
  587. color = color.replace('#', '');
  588. if (/^[0-9a-fA-F]{3}$/.test(color)) {
  589. color = color.split('');
  590. for (var i = 2; i >= 0; i--) {
  591. color.splice(i, 0, color[i]);
  592. }
  593. color = color.join('');
  594. }
  595. if (/^[0-9a-fA-F]{6}$/.test(color)) {
  596. return {
  597. red: parseInt(color.slice(0, 2), 16),
  598. green: parseInt(color.slice(2, 4), 16),
  599. blue: parseInt(color.slice(4, 6), 16)
  600. };
  601. } else {
  602. return {
  603. red: 255,
  604. green: 255,
  605. blue: 255
  606. };
  607. }
  608. },
  609. mixColor: function mixColor(color, percent) {
  610. var _getColorChannels = this.getColorChannels(color),
  611. red = _getColorChannels.red,
  612. green = _getColorChannels.green,
  613. blue = _getColorChannels.blue;
  614. if (percent > 0) {
  615. // shade given color
  616. red *= 1 - percent;
  617. green *= 1 - percent;
  618. blue *= 1 - percent;
  619. } else {
  620. // tint given color
  621. red += (255 - red) * percent;
  622. green += (255 - green) * percent;
  623. blue += (255 - blue) * percent;
  624. }
  625. return 'rgb(' + Math.round(red) + ', ' + Math.round(green) + ', ' + Math.round(blue) + ')';
  626. },
  627. addItem: function addItem(item) {
  628. this.$set(this.items, item.index, item);
  629. },
  630. removeItem: function removeItem(item) {
  631. delete this.items[item.index];
  632. },
  633. addSubmenu: function addSubmenu(item) {
  634. this.$set(this.submenus, item.index, item);
  635. },
  636. removeSubmenu: function removeSubmenu(item) {
  637. delete this.submenus[item.index];
  638. },
  639. openMenu: function openMenu(index, indexPath) {
  640. var openedMenus = this.openedMenus;
  641. if (openedMenus.indexOf(index) !== -1) return;
  642. // 将不在该菜单路径下的其余菜单收起
  643. // collapse all menu that are not under current menu item
  644. if (this.uniqueOpened) {
  645. this.openedMenus = openedMenus.filter(function (index) {
  646. return indexPath.indexOf(index) !== -1;
  647. });
  648. }
  649. this.openedMenus.push(index);
  650. },
  651. closeMenu: function closeMenu(index) {
  652. var i = this.openedMenus.indexOf(index);
  653. if (i !== -1) {
  654. this.openedMenus.splice(i, 1);
  655. }
  656. },
  657. handleSubmenuClick: function handleSubmenuClick(submenu) {
  658. var index = submenu.index,
  659. indexPath = submenu.indexPath;
  660. var isOpened = this.openedMenus.indexOf(index) !== -1;
  661. if (isOpened) {
  662. this.closeMenu(index);
  663. this.$emit('close', index, indexPath);
  664. } else {
  665. this.openMenu(index, indexPath);
  666. this.$emit('open', index, indexPath);
  667. }
  668. },
  669. handleItemClick: function handleItemClick(item) {
  670. var _this = this;
  671. var index = item.index,
  672. indexPath = item.indexPath;
  673. var oldActiveIndex = this.activeIndex;
  674. var hasIndex = item.index !== null;
  675. if (hasIndex) {
  676. this.activeIndex = item.index;
  677. }
  678. this.$emit('select', index, indexPath, item);
  679. if (this.mode === 'horizontal' || this.collapse) {
  680. this.openedMenus = [];
  681. }
  682. if (this.router && hasIndex) {
  683. this.routeToItem(item, function (error) {
  684. _this.activeIndex = oldActiveIndex;
  685. if (error) {
  686. // vue-router 3.1.0+ push/replace cause NavigationDuplicated error
  687. // https://github.com/ElemeFE/element/issues/17044
  688. if (error.name === 'NavigationDuplicated') return;
  689. console.error(error);
  690. }
  691. });
  692. }
  693. },
  694. // 初始化展开菜单
  695. // initialize opened menu
  696. initOpenedMenu: function initOpenedMenu() {
  697. var _this2 = this;
  698. var index = this.activeIndex;
  699. var activeItem = this.items[index];
  700. if (!activeItem || this.mode === 'horizontal' || this.collapse) return;
  701. var indexPath = activeItem.indexPath;
  702. // 展开该菜单项的路径上所有子菜单
  703. // expand all submenus of the menu item
  704. indexPath.forEach(function (index) {
  705. var submenu = _this2.submenus[index];
  706. submenu && _this2.openMenu(index, submenu.indexPath);
  707. });
  708. },
  709. routeToItem: function routeToItem(item, onError) {
  710. var route = item.route || item.index;
  711. try {
  712. this.$router.push(route, function () {}, onError);
  713. } catch (e) {
  714. console.error(e);
  715. }
  716. },
  717. open: function open(index) {
  718. var _this3 = this;
  719. var indexPath = this.submenus[index.toString()].indexPath;
  720. indexPath.forEach(function (i) {
  721. return _this3.openMenu(i, indexPath);
  722. });
  723. },
  724. close: function close(index) {
  725. this.closeMenu(index);
  726. }
  727. },
  728. mounted: function mounted() {
  729. this.initOpenedMenu();
  730. this.$on('item-click', this.handleItemClick);
  731. this.$on('submenu-click', this.handleSubmenuClick);
  732. if (this.mode === 'horizontal') {
  733. new aria_menubar(this.$el); // eslint-disable-line
  734. }
  735. this.$watch('items', this.updateActiveIndex);
  736. }
  737. });
  738. // CONCATENATED MODULE: ./packages/menu/src/menu.vue?vue&type=script&lang=js&
  739. /* harmony default export */ var src_menuvue_type_script_lang_js_ = (menuvue_type_script_lang_js_);
  740. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  741. var componentNormalizer = __webpack_require__(0);
  742. // CONCATENATED MODULE: ./packages/menu/src/menu.vue
  743. var menu_render, staticRenderFns
  744. /* normalize component */
  745. var component = Object(componentNormalizer["a" /* default */])(
  746. src_menuvue_type_script_lang_js_,
  747. menu_render,
  748. staticRenderFns,
  749. false,
  750. null,
  751. null,
  752. null
  753. )
  754. /* hot reload */
  755. if (false) { var api; }
  756. component.options.__file = "packages/menu/src/menu.vue"
  757. /* harmony default export */ var menu = (component.exports);
  758. // CONCATENATED MODULE: ./packages/menu/index.js
  759. /* istanbul ignore next */
  760. menu.install = function (Vue) {
  761. Vue.component(menu.name, menu);
  762. };
  763. /* harmony default export */ var packages_menu = __webpack_exports__["default"] = (menu);
  764. /***/ })
  765. /******/ });