cascader-panel.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  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 = 60);
  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. /***/ 15:
  180. /***/ (function(module, exports) {
  181. module.exports = require("element-ui/lib/scrollbar");
  182. /***/ }),
  183. /***/ 18:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/checkbox");
  186. /***/ }),
  187. /***/ 21:
  188. /***/ (function(module, exports) {
  189. module.exports = require("element-ui/lib/utils/shared");
  190. /***/ }),
  191. /***/ 26:
  192. /***/ (function(module, exports) {
  193. module.exports = require("babel-helper-vue-jsx-merge-props");
  194. /***/ }),
  195. /***/ 3:
  196. /***/ (function(module, exports) {
  197. module.exports = require("element-ui/lib/utils/util");
  198. /***/ }),
  199. /***/ 31:
  200. /***/ (function(module, exports) {
  201. module.exports = require("element-ui/lib/utils/scroll-into-view");
  202. /***/ }),
  203. /***/ 40:
  204. /***/ (function(module, exports) {
  205. module.exports = require("element-ui/lib/utils/aria-utils");
  206. /***/ }),
  207. /***/ 51:
  208. /***/ (function(module, exports) {
  209. module.exports = require("element-ui/lib/radio");
  210. /***/ }),
  211. /***/ 6:
  212. /***/ (function(module, exports) {
  213. module.exports = require("element-ui/lib/mixins/locale");
  214. /***/ }),
  215. /***/ 60:
  216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  217. "use strict";
  218. __webpack_require__.r(__webpack_exports__);
  219. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-panel.vue?vue&type=template&id=34932346&
  220. var cascader_panelvue_type_template_id_34932346_render = function() {
  221. var _vm = this
  222. var _h = _vm.$createElement
  223. var _c = _vm._self._c || _h
  224. return _c(
  225. "div",
  226. {
  227. class: ["el-cascader-panel", _vm.border && "is-bordered"],
  228. on: { keydown: _vm.handleKeyDown }
  229. },
  230. _vm._l(_vm.menus, function(menu, index) {
  231. return _c("cascader-menu", {
  232. key: index,
  233. ref: "menu",
  234. refInFor: true,
  235. attrs: { index: index, nodes: menu }
  236. })
  237. }),
  238. 1
  239. )
  240. }
  241. var staticRenderFns = []
  242. cascader_panelvue_type_template_id_34932346_render._withStripped = true
  243. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue?vue&type=template&id=34932346&
  244. // EXTERNAL MODULE: external "babel-helper-vue-jsx-merge-props"
  245. var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(26);
  246. var external_babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(external_babel_helper_vue_jsx_merge_props_);
  247. // EXTERNAL MODULE: external "element-ui/lib/scrollbar"
  248. var scrollbar_ = __webpack_require__(15);
  249. var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
  250. // EXTERNAL MODULE: external "element-ui/lib/checkbox"
  251. var checkbox_ = __webpack_require__(18);
  252. var checkbox_default = /*#__PURE__*/__webpack_require__.n(checkbox_);
  253. // EXTERNAL MODULE: external "element-ui/lib/radio"
  254. var radio_ = __webpack_require__(51);
  255. var radio_default = /*#__PURE__*/__webpack_require__.n(radio_);
  256. // EXTERNAL MODULE: external "element-ui/lib/utils/util"
  257. var util_ = __webpack_require__(3);
  258. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-node.vue?vue&type=script&lang=js&
  259. var stopPropagation = function stopPropagation(e) {
  260. return e.stopPropagation();
  261. };
  262. /* harmony default export */ var cascader_nodevue_type_script_lang_js_ = ({
  263. inject: ['panel'],
  264. components: {
  265. ElCheckbox: checkbox_default.a,
  266. ElRadio: radio_default.a
  267. },
  268. props: {
  269. node: {
  270. required: true
  271. },
  272. nodeId: String
  273. },
  274. computed: {
  275. config: function config() {
  276. return this.panel.config;
  277. },
  278. isLeaf: function isLeaf() {
  279. return this.node.isLeaf;
  280. },
  281. isDisabled: function isDisabled() {
  282. return this.node.isDisabled;
  283. },
  284. checkedValue: function checkedValue() {
  285. return this.panel.checkedValue;
  286. },
  287. isChecked: function isChecked() {
  288. return this.node.isSameNode(this.checkedValue);
  289. },
  290. inActivePath: function inActivePath() {
  291. return this.isInPath(this.panel.activePath);
  292. },
  293. inCheckedPath: function inCheckedPath() {
  294. var _this = this;
  295. if (!this.config.checkStrictly) return false;
  296. return this.panel.checkedNodePaths.some(function (checkedPath) {
  297. return _this.isInPath(checkedPath);
  298. });
  299. },
  300. value: function value() {
  301. return this.node.getValueByOption();
  302. }
  303. },
  304. methods: {
  305. handleExpand: function handleExpand() {
  306. var _this2 = this;
  307. var panel = this.panel,
  308. node = this.node,
  309. isDisabled = this.isDisabled,
  310. config = this.config;
  311. var multiple = config.multiple,
  312. checkStrictly = config.checkStrictly;
  313. if (!checkStrictly && isDisabled || node.loading) return;
  314. if (config.lazy && !node.loaded) {
  315. panel.lazyLoad(node, function () {
  316. // do not use cached leaf value here, invoke this.isLeaf to get new value.
  317. var isLeaf = _this2.isLeaf;
  318. if (!isLeaf) _this2.handleExpand();
  319. if (multiple) {
  320. // if leaf sync checked state, else clear checked state
  321. var checked = isLeaf ? node.checked : false;
  322. _this2.handleMultiCheckChange(checked);
  323. }
  324. });
  325. } else {
  326. panel.handleExpand(node);
  327. }
  328. },
  329. handleCheckChange: function handleCheckChange() {
  330. var panel = this.panel,
  331. value = this.value,
  332. node = this.node;
  333. panel.handleCheckChange(value);
  334. panel.handleExpand(node);
  335. },
  336. handleMultiCheckChange: function handleMultiCheckChange(checked) {
  337. this.node.doCheck(checked);
  338. this.panel.calculateMultiCheckedValue();
  339. },
  340. isInPath: function isInPath(pathNodes) {
  341. var node = this.node;
  342. var selectedPathNode = pathNodes[node.level - 1] || {};
  343. return selectedPathNode.uid === node.uid;
  344. },
  345. renderPrefix: function renderPrefix(h) {
  346. var isLeaf = this.isLeaf,
  347. isChecked = this.isChecked,
  348. config = this.config;
  349. var checkStrictly = config.checkStrictly,
  350. multiple = config.multiple;
  351. if (multiple) {
  352. return this.renderCheckbox(h);
  353. } else if (checkStrictly) {
  354. return this.renderRadio(h);
  355. } else if (isLeaf && isChecked) {
  356. return this.renderCheckIcon(h);
  357. }
  358. return null;
  359. },
  360. renderPostfix: function renderPostfix(h) {
  361. var node = this.node,
  362. isLeaf = this.isLeaf;
  363. if (node.loading) {
  364. return this.renderLoadingIcon(h);
  365. } else if (!isLeaf) {
  366. return this.renderExpandIcon(h);
  367. }
  368. return null;
  369. },
  370. renderCheckbox: function renderCheckbox(h) {
  371. var node = this.node,
  372. config = this.config,
  373. isDisabled = this.isDisabled;
  374. var events = {
  375. on: { change: this.handleMultiCheckChange },
  376. nativeOn: {}
  377. };
  378. if (config.checkStrictly) {
  379. // when every node is selectable, click event should not trigger expand event.
  380. events.nativeOn.click = stopPropagation;
  381. }
  382. return h('el-checkbox', external_babel_helper_vue_jsx_merge_props_default()([{
  383. attrs: {
  384. value: node.checked,
  385. indeterminate: node.indeterminate,
  386. disabled: isDisabled
  387. }
  388. }, events]));
  389. },
  390. renderRadio: function renderRadio(h) {
  391. var checkedValue = this.checkedValue,
  392. value = this.value,
  393. isDisabled = this.isDisabled;
  394. // to keep same reference if value cause radio's checked state is calculated by reference comparision;
  395. if (Object(util_["isEqual"])(value, checkedValue)) {
  396. value = checkedValue;
  397. }
  398. return h(
  399. 'el-radio',
  400. {
  401. attrs: {
  402. value: checkedValue,
  403. label: value,
  404. disabled: isDisabled
  405. },
  406. on: {
  407. 'change': this.handleCheckChange
  408. },
  409. nativeOn: {
  410. 'click': stopPropagation
  411. }
  412. },
  413. [h('span')]
  414. );
  415. },
  416. renderCheckIcon: function renderCheckIcon(h) {
  417. return h('i', { 'class': 'el-icon-check el-cascader-node__prefix' });
  418. },
  419. renderLoadingIcon: function renderLoadingIcon(h) {
  420. return h('i', { 'class': 'el-icon-loading el-cascader-node__postfix' });
  421. },
  422. renderExpandIcon: function renderExpandIcon(h) {
  423. return h('i', { 'class': 'el-icon-arrow-right el-cascader-node__postfix' });
  424. },
  425. renderContent: function renderContent(h) {
  426. var panel = this.panel,
  427. node = this.node;
  428. var render = panel.renderLabelFn;
  429. var vnode = render ? render({ node: node, data: node.data }) : null;
  430. return h(
  431. 'span',
  432. { 'class': 'el-cascader-node__label' },
  433. [vnode || node.label]
  434. );
  435. }
  436. },
  437. render: function render(h) {
  438. var _this3 = this;
  439. var inActivePath = this.inActivePath,
  440. inCheckedPath = this.inCheckedPath,
  441. isChecked = this.isChecked,
  442. isLeaf = this.isLeaf,
  443. isDisabled = this.isDisabled,
  444. config = this.config,
  445. nodeId = this.nodeId;
  446. var expandTrigger = config.expandTrigger,
  447. checkStrictly = config.checkStrictly,
  448. multiple = config.multiple;
  449. var disabled = !checkStrictly && isDisabled;
  450. var events = { on: {} };
  451. if (expandTrigger === 'click') {
  452. events.on.click = this.handleExpand;
  453. } else {
  454. events.on.mouseenter = function (e) {
  455. _this3.handleExpand();
  456. _this3.$emit('expand', e);
  457. };
  458. events.on.focus = function (e) {
  459. _this3.handleExpand();
  460. _this3.$emit('expand', e);
  461. };
  462. }
  463. if (isLeaf && !isDisabled && !checkStrictly && !multiple) {
  464. events.on.click = this.handleCheckChange;
  465. }
  466. return h(
  467. 'li',
  468. external_babel_helper_vue_jsx_merge_props_default()([{
  469. attrs: {
  470. role: 'menuitem',
  471. id: nodeId,
  472. 'aria-expanded': inActivePath,
  473. tabindex: disabled ? null : -1
  474. },
  475. 'class': {
  476. 'el-cascader-node': true,
  477. 'is-selectable': checkStrictly,
  478. 'in-active-path': inActivePath,
  479. 'in-checked-path': inCheckedPath,
  480. 'is-active': isChecked,
  481. 'is-disabled': disabled
  482. }
  483. }, events]),
  484. [this.renderPrefix(h), this.renderContent(h), this.renderPostfix(h)]
  485. );
  486. }
  487. });
  488. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-node.vue?vue&type=script&lang=js&
  489. /* harmony default export */ var src_cascader_nodevue_type_script_lang_js_ = (cascader_nodevue_type_script_lang_js_);
  490. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  491. var componentNormalizer = __webpack_require__(0);
  492. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-node.vue
  493. var cascader_node_render, cascader_node_staticRenderFns
  494. /* normalize component */
  495. var component = Object(componentNormalizer["a" /* default */])(
  496. src_cascader_nodevue_type_script_lang_js_,
  497. cascader_node_render,
  498. cascader_node_staticRenderFns,
  499. false,
  500. null,
  501. null,
  502. null
  503. )
  504. /* hot reload */
  505. if (false) { var api; }
  506. component.options.__file = "packages/cascader-panel/src/cascader-node.vue"
  507. /* harmony default export */ var cascader_node = (component.exports);
  508. // EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
  509. var locale_ = __webpack_require__(6);
  510. var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
  511. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-menu.vue?vue&type=script&lang=js&
  512. /* harmony default export */ var cascader_menuvue_type_script_lang_js_ = ({
  513. name: 'ElCascaderMenu',
  514. mixins: [locale_default.a],
  515. inject: ['panel'],
  516. components: {
  517. ElScrollbar: scrollbar_default.a,
  518. CascaderNode: cascader_node
  519. },
  520. props: {
  521. nodes: {
  522. type: Array,
  523. required: true
  524. },
  525. index: Number
  526. },
  527. data: function data() {
  528. return {
  529. activeNode: null,
  530. hoverTimer: null,
  531. id: Object(util_["generateId"])()
  532. };
  533. },
  534. computed: {
  535. isEmpty: function isEmpty() {
  536. return !this.nodes.length;
  537. },
  538. menuId: function menuId() {
  539. return 'cascader-menu-' + this.id + '-' + this.index;
  540. }
  541. },
  542. methods: {
  543. handleExpand: function handleExpand(e) {
  544. this.activeNode = e.target;
  545. },
  546. handleMouseMove: function handleMouseMove(e) {
  547. var activeNode = this.activeNode,
  548. hoverTimer = this.hoverTimer;
  549. var hoverZone = this.$refs.hoverZone;
  550. if (!activeNode || !hoverZone) return;
  551. if (activeNode.contains(e.target)) {
  552. clearTimeout(hoverTimer);
  553. var _$el$getBoundingClien = this.$el.getBoundingClientRect(),
  554. left = _$el$getBoundingClien.left;
  555. var startX = e.clientX - left;
  556. var _$el = this.$el,
  557. offsetWidth = _$el.offsetWidth,
  558. offsetHeight = _$el.offsetHeight;
  559. var top = activeNode.offsetTop;
  560. var bottom = top + activeNode.offsetHeight;
  561. hoverZone.innerHTML = '\n <path style="pointer-events: auto;" fill="transparent" d="M' + startX + ' ' + top + ' L' + offsetWidth + ' 0 V' + top + ' Z" />\n <path style="pointer-events: auto;" fill="transparent" d="M' + startX + ' ' + bottom + ' L' + offsetWidth + ' ' + offsetHeight + ' V' + bottom + ' Z" />\n ';
  562. } else if (!hoverTimer) {
  563. this.hoverTimer = setTimeout(this.clearHoverZone, this.panel.config.hoverThreshold);
  564. }
  565. },
  566. clearHoverZone: function clearHoverZone() {
  567. var hoverZone = this.$refs.hoverZone;
  568. if (!hoverZone) return;
  569. hoverZone.innerHTML = '';
  570. },
  571. renderEmptyText: function renderEmptyText(h) {
  572. return h(
  573. 'div',
  574. { 'class': 'el-cascader-menu__empty-text' },
  575. [this.t('el.cascader.noData')]
  576. );
  577. },
  578. renderNodeList: function renderNodeList(h) {
  579. var menuId = this.menuId;
  580. var isHoverMenu = this.panel.isHoverMenu;
  581. var events = { on: {} };
  582. if (isHoverMenu) {
  583. events.on.expand = this.handleExpand;
  584. }
  585. var nodes = this.nodes.map(function (node, index) {
  586. var hasChildren = node.hasChildren;
  587. return h('cascader-node', external_babel_helper_vue_jsx_merge_props_default()([{
  588. key: node.uid,
  589. attrs: { node: node,
  590. 'node-id': menuId + '-' + index,
  591. 'aria-haspopup': hasChildren,
  592. 'aria-owns': hasChildren ? menuId : null
  593. }
  594. }, events]));
  595. });
  596. return [].concat(nodes, [isHoverMenu ? h('svg', { ref: 'hoverZone', 'class': 'el-cascader-menu__hover-zone' }) : null]);
  597. }
  598. },
  599. render: function render(h) {
  600. var isEmpty = this.isEmpty,
  601. menuId = this.menuId;
  602. var events = { nativeOn: {} };
  603. // optimize hover to expand experience (#8010)
  604. if (this.panel.isHoverMenu) {
  605. events.nativeOn.mousemove = this.handleMouseMove;
  606. // events.nativeOn.mouseleave = this.clearHoverZone;
  607. }
  608. return h(
  609. 'el-scrollbar',
  610. external_babel_helper_vue_jsx_merge_props_default()([{
  611. attrs: {
  612. tag: 'ul',
  613. role: 'menu',
  614. id: menuId,
  615. 'wrap-class': 'el-cascader-menu__wrap',
  616. 'view-class': {
  617. 'el-cascader-menu__list': true,
  618. 'is-empty': isEmpty
  619. }
  620. },
  621. 'class': 'el-cascader-menu' }, events]),
  622. [isEmpty ? this.renderEmptyText(h) : this.renderNodeList(h)]
  623. );
  624. }
  625. });
  626. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-menu.vue?vue&type=script&lang=js&
  627. /* harmony default export */ var src_cascader_menuvue_type_script_lang_js_ = (cascader_menuvue_type_script_lang_js_);
  628. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-menu.vue
  629. var cascader_menu_render, cascader_menu_staticRenderFns
  630. /* normalize component */
  631. var cascader_menu_component = Object(componentNormalizer["a" /* default */])(
  632. src_cascader_menuvue_type_script_lang_js_,
  633. cascader_menu_render,
  634. cascader_menu_staticRenderFns,
  635. false,
  636. null,
  637. null,
  638. null
  639. )
  640. /* hot reload */
  641. if (false) { var cascader_menu_api; }
  642. cascader_menu_component.options.__file = "packages/cascader-panel/src/cascader-menu.vue"
  643. /* harmony default export */ var cascader_menu = (cascader_menu_component.exports);
  644. // EXTERNAL MODULE: external "element-ui/lib/utils/shared"
  645. var shared_ = __webpack_require__(21);
  646. // CONCATENATED MODULE: ./packages/cascader-panel/src/node.js
  647. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  648. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  649. var uid = 0;
  650. var node_Node = function () {
  651. function Node(data, config, parentNode) {
  652. _classCallCheck(this, Node);
  653. this.data = data;
  654. this.config = config;
  655. this.parent = parentNode || null;
  656. this.level = !this.parent ? 1 : this.parent.level + 1;
  657. this.uid = uid++;
  658. this.initState();
  659. this.initChildren();
  660. }
  661. Node.prototype.initState = function initState() {
  662. var _config = this.config,
  663. valueKey = _config.value,
  664. labelKey = _config.label;
  665. this.value = this.data[valueKey];
  666. this.label = this.data[labelKey];
  667. this.pathNodes = this.calculatePathNodes();
  668. this.path = this.pathNodes.map(function (node) {
  669. return node.value;
  670. });
  671. this.pathLabels = this.pathNodes.map(function (node) {
  672. return node.label;
  673. });
  674. // lazy load
  675. this.loading = false;
  676. this.loaded = false;
  677. };
  678. Node.prototype.initChildren = function initChildren() {
  679. var _this = this;
  680. var config = this.config;
  681. var childrenKey = config.children;
  682. var childrenData = this.data[childrenKey];
  683. this.hasChildren = Array.isArray(childrenData);
  684. this.children = (childrenData || []).map(function (child) {
  685. return new Node(child, config, _this);
  686. });
  687. };
  688. Node.prototype.calculatePathNodes = function calculatePathNodes() {
  689. var nodes = [this];
  690. var parent = this.parent;
  691. while (parent) {
  692. nodes.unshift(parent);
  693. parent = parent.parent;
  694. }
  695. return nodes;
  696. };
  697. Node.prototype.getPath = function getPath() {
  698. return this.path;
  699. };
  700. Node.prototype.getValue = function getValue() {
  701. return this.value;
  702. };
  703. Node.prototype.getValueByOption = function getValueByOption() {
  704. return this.config.emitPath ? this.getPath() : this.getValue();
  705. };
  706. Node.prototype.getText = function getText(allLevels, separator) {
  707. return allLevels ? this.pathLabels.join(separator) : this.label;
  708. };
  709. Node.prototype.isSameNode = function isSameNode(checkedValue) {
  710. var value = this.getValueByOption();
  711. return this.config.multiple && Array.isArray(checkedValue) ? checkedValue.some(function (val) {
  712. return Object(util_["isEqual"])(val, value);
  713. }) : Object(util_["isEqual"])(checkedValue, value);
  714. };
  715. Node.prototype.broadcast = function broadcast(event) {
  716. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  717. args[_key - 1] = arguments[_key];
  718. }
  719. var handlerName = 'onParent' + Object(util_["capitalize"])(event);
  720. this.children.forEach(function (child) {
  721. if (child) {
  722. // bottom up
  723. child.broadcast.apply(child, [event].concat(args));
  724. child[handlerName] && child[handlerName].apply(child, args);
  725. }
  726. });
  727. };
  728. Node.prototype.emit = function emit(event) {
  729. var parent = this.parent;
  730. var handlerName = 'onChild' + Object(util_["capitalize"])(event);
  731. if (parent) {
  732. for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  733. args[_key2 - 1] = arguments[_key2];
  734. }
  735. parent[handlerName] && parent[handlerName].apply(parent, args);
  736. parent.emit.apply(parent, [event].concat(args));
  737. }
  738. };
  739. Node.prototype.onParentCheck = function onParentCheck(checked) {
  740. if (!this.isDisabled) {
  741. this.setCheckState(checked);
  742. }
  743. };
  744. Node.prototype.onChildCheck = function onChildCheck() {
  745. var children = this.children;
  746. var validChildren = children.filter(function (child) {
  747. return !child.isDisabled;
  748. });
  749. var checked = validChildren.length ? validChildren.every(function (child) {
  750. return child.checked;
  751. }) : false;
  752. this.setCheckState(checked);
  753. };
  754. Node.prototype.setCheckState = function setCheckState(checked) {
  755. var totalNum = this.children.length;
  756. var checkedNum = this.children.reduce(function (c, p) {
  757. var num = p.checked ? 1 : p.indeterminate ? 0.5 : 0;
  758. return c + num;
  759. }, 0);
  760. this.checked = checked;
  761. this.indeterminate = checkedNum !== totalNum && checkedNum > 0;
  762. };
  763. Node.prototype.syncCheckState = function syncCheckState(checkedValue) {
  764. var value = this.getValueByOption();
  765. var checked = this.isSameNode(checkedValue, value);
  766. this.doCheck(checked);
  767. };
  768. Node.prototype.doCheck = function doCheck(checked) {
  769. if (this.checked !== checked) {
  770. if (this.config.checkStrictly) {
  771. this.checked = checked;
  772. } else {
  773. // bottom up to unify the calculation of the indeterminate state
  774. this.broadcast('check', checked);
  775. this.setCheckState(checked);
  776. this.emit('check');
  777. }
  778. }
  779. };
  780. _createClass(Node, [{
  781. key: 'isDisabled',
  782. get: function get() {
  783. var data = this.data,
  784. parent = this.parent,
  785. config = this.config;
  786. var disabledKey = config.disabled;
  787. var checkStrictly = config.checkStrictly;
  788. return data[disabledKey] || !checkStrictly && parent && parent.isDisabled;
  789. }
  790. }, {
  791. key: 'isLeaf',
  792. get: function get() {
  793. var data = this.data,
  794. loaded = this.loaded,
  795. hasChildren = this.hasChildren,
  796. children = this.children;
  797. var _config2 = this.config,
  798. lazy = _config2.lazy,
  799. leafKey = _config2.leaf;
  800. if (lazy) {
  801. var isLeaf = Object(shared_["isDef"])(data[leafKey]) ? data[leafKey] : loaded ? !children.length : false;
  802. this.hasChildren = !isLeaf;
  803. return isLeaf;
  804. }
  805. return !hasChildren;
  806. }
  807. }]);
  808. return Node;
  809. }();
  810. /* harmony default export */ var src_node = (node_Node);
  811. // CONCATENATED MODULE: ./packages/cascader-panel/src/store.js
  812. function store_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  813. var flatNodes = function flatNodes(data, leafOnly) {
  814. return data.reduce(function (res, node) {
  815. if (node.isLeaf) {
  816. res.push(node);
  817. } else {
  818. !leafOnly && res.push(node);
  819. res = res.concat(flatNodes(node.children, leafOnly));
  820. }
  821. return res;
  822. }, []);
  823. };
  824. var store_Store = function () {
  825. function Store(data, config) {
  826. store_classCallCheck(this, Store);
  827. this.config = config;
  828. this.initNodes(data);
  829. }
  830. Store.prototype.initNodes = function initNodes(data) {
  831. var _this = this;
  832. data = Object(util_["coerceTruthyValueToArray"])(data);
  833. this.nodes = data.map(function (nodeData) {
  834. return new src_node(nodeData, _this.config);
  835. });
  836. this.flattedNodes = this.getFlattedNodes(false, false);
  837. this.leafNodes = this.getFlattedNodes(true, false);
  838. };
  839. Store.prototype.appendNode = function appendNode(nodeData, parentNode) {
  840. var node = new src_node(nodeData, this.config, parentNode);
  841. var children = parentNode ? parentNode.children : this.nodes;
  842. children.push(node);
  843. };
  844. Store.prototype.appendNodes = function appendNodes(nodeDataList, parentNode) {
  845. var _this2 = this;
  846. nodeDataList = Object(util_["coerceTruthyValueToArray"])(nodeDataList);
  847. nodeDataList.forEach(function (nodeData) {
  848. return _this2.appendNode(nodeData, parentNode);
  849. });
  850. };
  851. Store.prototype.getNodes = function getNodes() {
  852. return this.nodes;
  853. };
  854. Store.prototype.getFlattedNodes = function getFlattedNodes(leafOnly) {
  855. var cached = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  856. var cachedNodes = leafOnly ? this.leafNodes : this.flattedNodes;
  857. return cached ? cachedNodes : flatNodes(this.nodes, leafOnly);
  858. };
  859. Store.prototype.getNodeByValue = function getNodeByValue(value) {
  860. var nodes = this.getFlattedNodes(false, !this.config.lazy).filter(function (node) {
  861. return Object(util_["valueEquals"])(node.path, value) || node.value === value;
  862. });
  863. return nodes && nodes.length ? nodes[0] : null;
  864. };
  865. return Store;
  866. }();
  867. /* harmony default export */ var src_store = (store_Store);
  868. // EXTERNAL MODULE: external "element-ui/lib/utils/merge"
  869. var merge_ = __webpack_require__(9);
  870. var merge_default = /*#__PURE__*/__webpack_require__.n(merge_);
  871. // EXTERNAL MODULE: external "element-ui/lib/utils/aria-utils"
  872. var aria_utils_ = __webpack_require__(40);
  873. var aria_utils_default = /*#__PURE__*/__webpack_require__.n(aria_utils_);
  874. // EXTERNAL MODULE: external "element-ui/lib/utils/scroll-into-view"
  875. var scroll_into_view_ = __webpack_require__(31);
  876. var scroll_into_view_default = /*#__PURE__*/__webpack_require__.n(scroll_into_view_);
  877. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader-panel/src/cascader-panel.vue?vue&type=script&lang=js&
  878. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  879. //
  880. //
  881. //
  882. //
  883. //
  884. //
  885. //
  886. //
  887. //
  888. //
  889. //
  890. //
  891. //
  892. //
  893. //
  894. //
  895. var KeyCode = aria_utils_default.a.keys;
  896. var DefaultProps = {
  897. expandTrigger: 'click', // or hover
  898. multiple: false,
  899. checkStrictly: false, // whether all nodes can be selected
  900. emitPath: true, // wether to emit an array of all levels value in which node is located
  901. lazy: false,
  902. lazyLoad: util_["noop"],
  903. value: 'value',
  904. label: 'label',
  905. children: 'children',
  906. leaf: 'leaf',
  907. disabled: 'disabled',
  908. hoverThreshold: 500
  909. };
  910. var cascader_panelvue_type_script_lang_js_isLeaf = function isLeaf(el) {
  911. return !el.getAttribute('aria-owns');
  912. };
  913. var getSibling = function getSibling(el, distance) {
  914. var parentNode = el.parentNode;
  915. if (parentNode) {
  916. var siblings = parentNode.querySelectorAll('.el-cascader-node[tabindex="-1"]');
  917. var index = Array.prototype.indexOf.call(siblings, el);
  918. return siblings[index + distance] || null;
  919. }
  920. return null;
  921. };
  922. var getMenuIndex = function getMenuIndex(el, distance) {
  923. if (!el) return;
  924. var pieces = el.id.split('-');
  925. return Number(pieces[pieces.length - 2]);
  926. };
  927. var focusNode = function focusNode(el) {
  928. if (!el) return;
  929. el.focus();
  930. !cascader_panelvue_type_script_lang_js_isLeaf(el) && el.click();
  931. };
  932. var checkNode = function checkNode(el) {
  933. if (!el) return;
  934. var input = el.querySelector('input');
  935. if (input) {
  936. input.click();
  937. } else if (cascader_panelvue_type_script_lang_js_isLeaf(el)) {
  938. el.click();
  939. }
  940. };
  941. /* harmony default export */ var cascader_panelvue_type_script_lang_js_ = ({
  942. name: 'ElCascaderPanel',
  943. components: {
  944. CascaderMenu: cascader_menu
  945. },
  946. props: {
  947. value: {},
  948. options: Array,
  949. props: Object,
  950. border: {
  951. type: Boolean,
  952. default: true
  953. },
  954. renderLabel: Function
  955. },
  956. provide: function provide() {
  957. return {
  958. panel: this
  959. };
  960. },
  961. data: function data() {
  962. return {
  963. checkedValue: null,
  964. checkedNodePaths: [],
  965. store: [],
  966. menus: [],
  967. activePath: [],
  968. loadCount: 0
  969. };
  970. },
  971. computed: {
  972. config: function config() {
  973. return merge_default()(_extends({}, DefaultProps), this.props || {});
  974. },
  975. multiple: function multiple() {
  976. return this.config.multiple;
  977. },
  978. checkStrictly: function checkStrictly() {
  979. return this.config.checkStrictly;
  980. },
  981. leafOnly: function leafOnly() {
  982. return !this.checkStrictly;
  983. },
  984. isHoverMenu: function isHoverMenu() {
  985. return this.config.expandTrigger === 'hover';
  986. },
  987. renderLabelFn: function renderLabelFn() {
  988. return this.renderLabel || this.$scopedSlots.default;
  989. }
  990. },
  991. watch: {
  992. value: function value() {
  993. this.syncCheckedValue();
  994. this.checkStrictly && this.calculateCheckedNodePaths();
  995. },
  996. options: {
  997. handler: function handler() {
  998. this.initStore();
  999. },
  1000. immediate: true,
  1001. deep: true
  1002. },
  1003. checkedValue: function checkedValue(val) {
  1004. if (!Object(util_["isEqual"])(val, this.value)) {
  1005. this.checkStrictly && this.calculateCheckedNodePaths();
  1006. this.$emit('input', val);
  1007. this.$emit('change', val);
  1008. }
  1009. }
  1010. },
  1011. mounted: function mounted() {
  1012. if (!this.isEmptyValue(this.value)) {
  1013. this.syncCheckedValue();
  1014. }
  1015. },
  1016. methods: {
  1017. initStore: function initStore() {
  1018. var config = this.config,
  1019. options = this.options;
  1020. if (config.lazy && Object(util_["isEmpty"])(options)) {
  1021. this.lazyLoad();
  1022. } else {
  1023. this.store = new src_store(options, config);
  1024. this.menus = [this.store.getNodes()];
  1025. this.syncMenuState();
  1026. }
  1027. },
  1028. syncCheckedValue: function syncCheckedValue() {
  1029. var value = this.value,
  1030. checkedValue = this.checkedValue;
  1031. if (!Object(util_["isEqual"])(value, checkedValue)) {
  1032. this.activePath = [];
  1033. this.checkedValue = value;
  1034. this.syncMenuState();
  1035. }
  1036. },
  1037. syncMenuState: function syncMenuState() {
  1038. var multiple = this.multiple,
  1039. checkStrictly = this.checkStrictly;
  1040. this.syncActivePath();
  1041. multiple && this.syncMultiCheckState();
  1042. checkStrictly && this.calculateCheckedNodePaths();
  1043. this.$nextTick(this.scrollIntoView);
  1044. },
  1045. syncMultiCheckState: function syncMultiCheckState() {
  1046. var _this = this;
  1047. var nodes = this.getFlattedNodes(this.leafOnly);
  1048. nodes.forEach(function (node) {
  1049. node.syncCheckState(_this.checkedValue);
  1050. });
  1051. },
  1052. isEmptyValue: function isEmptyValue(val) {
  1053. var multiple = this.multiple,
  1054. config = this.config;
  1055. var emitPath = config.emitPath;
  1056. if (multiple || emitPath) {
  1057. return Object(util_["isEmpty"])(val);
  1058. }
  1059. return false;
  1060. },
  1061. syncActivePath: function syncActivePath() {
  1062. var _this2 = this;
  1063. var store = this.store,
  1064. multiple = this.multiple,
  1065. activePath = this.activePath,
  1066. checkedValue = this.checkedValue;
  1067. if (!Object(util_["isEmpty"])(activePath)) {
  1068. var nodes = activePath.map(function (node) {
  1069. return _this2.getNodeByValue(node.getValue());
  1070. });
  1071. this.expandNodes(nodes);
  1072. } else if (!this.isEmptyValue(checkedValue)) {
  1073. var value = multiple ? checkedValue[0] : checkedValue;
  1074. var checkedNode = this.getNodeByValue(value) || {};
  1075. var _nodes = (checkedNode.pathNodes || []).slice(0, -1);
  1076. this.expandNodes(_nodes);
  1077. } else {
  1078. this.activePath = [];
  1079. this.menus = [store.getNodes()];
  1080. }
  1081. },
  1082. expandNodes: function expandNodes(nodes) {
  1083. var _this3 = this;
  1084. nodes.forEach(function (node) {
  1085. return _this3.handleExpand(node, true /* silent */);
  1086. });
  1087. },
  1088. calculateCheckedNodePaths: function calculateCheckedNodePaths() {
  1089. var _this4 = this;
  1090. var checkedValue = this.checkedValue,
  1091. multiple = this.multiple;
  1092. var checkedValues = multiple ? Object(util_["coerceTruthyValueToArray"])(checkedValue) : [checkedValue];
  1093. this.checkedNodePaths = checkedValues.map(function (v) {
  1094. var checkedNode = _this4.getNodeByValue(v);
  1095. return checkedNode ? checkedNode.pathNodes : [];
  1096. });
  1097. },
  1098. handleKeyDown: function handleKeyDown(e) {
  1099. var target = e.target,
  1100. keyCode = e.keyCode;
  1101. switch (keyCode) {
  1102. case KeyCode.up:
  1103. var prev = getSibling(target, -1);
  1104. focusNode(prev);
  1105. break;
  1106. case KeyCode.down:
  1107. var next = getSibling(target, 1);
  1108. focusNode(next);
  1109. break;
  1110. case KeyCode.left:
  1111. var preMenu = this.$refs.menu[getMenuIndex(target) - 1];
  1112. if (preMenu) {
  1113. var expandedNode = preMenu.$el.querySelector('.el-cascader-node[aria-expanded="true"]');
  1114. focusNode(expandedNode);
  1115. }
  1116. break;
  1117. case KeyCode.right:
  1118. var nextMenu = this.$refs.menu[getMenuIndex(target) + 1];
  1119. if (nextMenu) {
  1120. var firstNode = nextMenu.$el.querySelector('.el-cascader-node[tabindex="-1"]');
  1121. focusNode(firstNode);
  1122. }
  1123. break;
  1124. case KeyCode.enter:
  1125. checkNode(target);
  1126. break;
  1127. case KeyCode.esc:
  1128. case KeyCode.tab:
  1129. this.$emit('close');
  1130. break;
  1131. default:
  1132. return;
  1133. }
  1134. },
  1135. handleExpand: function handleExpand(node, silent) {
  1136. var activePath = this.activePath;
  1137. var level = node.level;
  1138. var path = activePath.slice(0, level - 1);
  1139. var menus = this.menus.slice(0, level);
  1140. if (!node.isLeaf) {
  1141. path.push(node);
  1142. menus.push(node.children);
  1143. }
  1144. this.activePath = path;
  1145. this.menus = menus;
  1146. if (!silent) {
  1147. var pathValues = path.map(function (node) {
  1148. return node.getValue();
  1149. });
  1150. var activePathValues = activePath.map(function (node) {
  1151. return node.getValue();
  1152. });
  1153. if (!Object(util_["valueEquals"])(pathValues, activePathValues)) {
  1154. this.$emit('active-item-change', pathValues); // Deprecated
  1155. this.$emit('expand-change', pathValues);
  1156. }
  1157. }
  1158. },
  1159. handleCheckChange: function handleCheckChange(value) {
  1160. this.checkedValue = value;
  1161. },
  1162. lazyLoad: function lazyLoad(node, onFullfiled) {
  1163. var _this5 = this;
  1164. var config = this.config;
  1165. if (!node) {
  1166. node = node || { root: true, level: 0 };
  1167. this.store = new src_store([], config);
  1168. this.menus = [this.store.getNodes()];
  1169. }
  1170. node.loading = true;
  1171. var resolve = function resolve(dataList) {
  1172. var parent = node.root ? null : node;
  1173. dataList && dataList.length && _this5.store.appendNodes(dataList, parent);
  1174. node.loading = false;
  1175. node.loaded = true;
  1176. // dispose default value on lazy load mode
  1177. if (Array.isArray(_this5.checkedValue)) {
  1178. var nodeValue = _this5.checkedValue[_this5.loadCount++];
  1179. var valueKey = _this5.config.value;
  1180. var leafKey = _this5.config.leaf;
  1181. if (Array.isArray(dataList) && dataList.filter(function (item) {
  1182. return item[valueKey] === nodeValue;
  1183. }).length > 0) {
  1184. var checkedNode = _this5.store.getNodeByValue(nodeValue);
  1185. if (!checkedNode.data[leafKey]) {
  1186. _this5.lazyLoad(checkedNode, function () {
  1187. _this5.handleExpand(checkedNode);
  1188. });
  1189. }
  1190. if (_this5.loadCount === _this5.checkedValue.length) {
  1191. _this5.$parent.computePresentText();
  1192. }
  1193. }
  1194. }
  1195. onFullfiled && onFullfiled(dataList);
  1196. };
  1197. config.lazyLoad(node, resolve);
  1198. },
  1199. /**
  1200. * public methods
  1201. */
  1202. calculateMultiCheckedValue: function calculateMultiCheckedValue() {
  1203. this.checkedValue = this.getCheckedNodes(this.leafOnly).map(function (node) {
  1204. return node.getValueByOption();
  1205. });
  1206. },
  1207. scrollIntoView: function scrollIntoView() {
  1208. if (this.$isServer) return;
  1209. var menus = this.$refs.menu || [];
  1210. menus.forEach(function (menu) {
  1211. var menuElement = menu.$el;
  1212. if (menuElement) {
  1213. var container = menuElement.querySelector('.el-scrollbar__wrap');
  1214. var activeNode = menuElement.querySelector('.el-cascader-node.is-active') || menuElement.querySelector('.el-cascader-node.in-active-path');
  1215. scroll_into_view_default()(container, activeNode);
  1216. }
  1217. });
  1218. },
  1219. getNodeByValue: function getNodeByValue(val) {
  1220. return this.store.getNodeByValue(val);
  1221. },
  1222. getFlattedNodes: function getFlattedNodes(leafOnly) {
  1223. var cached = !this.config.lazy;
  1224. return this.store.getFlattedNodes(leafOnly, cached);
  1225. },
  1226. getCheckedNodes: function getCheckedNodes(leafOnly) {
  1227. var checkedValue = this.checkedValue,
  1228. multiple = this.multiple;
  1229. if (multiple) {
  1230. var nodes = this.getFlattedNodes(leafOnly);
  1231. return nodes.filter(function (node) {
  1232. return node.checked;
  1233. });
  1234. } else {
  1235. return this.isEmptyValue(checkedValue) ? [] : [this.getNodeByValue(checkedValue)];
  1236. }
  1237. },
  1238. clearCheckedNodes: function clearCheckedNodes() {
  1239. var config = this.config,
  1240. leafOnly = this.leafOnly;
  1241. var multiple = config.multiple,
  1242. emitPath = config.emitPath;
  1243. if (multiple) {
  1244. this.getCheckedNodes(leafOnly).filter(function (node) {
  1245. return !node.isDisabled;
  1246. }).forEach(function (node) {
  1247. return node.doCheck(false);
  1248. });
  1249. this.calculateMultiCheckedValue();
  1250. } else {
  1251. this.checkedValue = emitPath ? [] : null;
  1252. }
  1253. }
  1254. }
  1255. });
  1256. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue?vue&type=script&lang=js&
  1257. /* harmony default export */ var src_cascader_panelvue_type_script_lang_js_ = (cascader_panelvue_type_script_lang_js_);
  1258. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue
  1259. /* normalize component */
  1260. var cascader_panel_component = Object(componentNormalizer["a" /* default */])(
  1261. src_cascader_panelvue_type_script_lang_js_,
  1262. cascader_panelvue_type_template_id_34932346_render,
  1263. staticRenderFns,
  1264. false,
  1265. null,
  1266. null,
  1267. null
  1268. )
  1269. /* hot reload */
  1270. if (false) { var cascader_panel_api; }
  1271. cascader_panel_component.options.__file = "packages/cascader-panel/src/cascader-panel.vue"
  1272. /* harmony default export */ var cascader_panel = (cascader_panel_component.exports);
  1273. // CONCATENATED MODULE: ./packages/cascader-panel/index.js
  1274. /* istanbul ignore next */
  1275. cascader_panel.install = function (Vue) {
  1276. Vue.component(cascader_panel.name, cascader_panel);
  1277. };
  1278. /* harmony default export */ var packages_cascader_panel = __webpack_exports__["default"] = (cascader_panel);
  1279. /***/ }),
  1280. /***/ 9:
  1281. /***/ (function(module, exports) {
  1282. module.exports = require("element-ui/lib/utils/merge");
  1283. /***/ })
  1284. /******/ });