cascader-panel.js 44 KB

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