cascader-panel.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  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. /***/ 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. /***/ 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__(15);
  245. var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
  246. // EXTERNAL MODULE: external "element-ui/lib/checkbox"
  247. var checkbox_ = __webpack_require__(18);
  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__(40);
  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.activePath = [];
  1032. this.checkedValue = value;
  1033. this.syncMenuState();
  1034. }
  1035. },
  1036. syncMenuState: function syncMenuState() {
  1037. var multiple = this.multiple,
  1038. checkStrictly = this.checkStrictly;
  1039. this.syncActivePath();
  1040. multiple && this.syncMultiCheckState();
  1041. checkStrictly && this.calculateCheckedNodePaths();
  1042. this.$nextTick(this.scrollIntoView);
  1043. },
  1044. syncMultiCheckState: function syncMultiCheckState() {
  1045. var _this = this;
  1046. var nodes = this.getFlattedNodes(this.leafOnly);
  1047. nodes.forEach(function (node) {
  1048. node.syncCheckState(_this.checkedValue);
  1049. });
  1050. },
  1051. syncActivePath: function syncActivePath() {
  1052. var _this2 = this;
  1053. var store = this.store,
  1054. multiple = this.multiple,
  1055. activePath = this.activePath,
  1056. checkedValue = this.checkedValue;
  1057. if (!Object(util_["isEmpty"])(activePath)) {
  1058. var nodes = activePath.map(function (node) {
  1059. return _this2.getNodeByValue(node.getValue());
  1060. });
  1061. this.expandNodes(nodes);
  1062. } else if (!Object(util_["isEmpty"])(checkedValue)) {
  1063. var value = multiple ? checkedValue[0] : checkedValue;
  1064. var checkedNode = this.getNodeByValue(value) || {};
  1065. var _nodes = (checkedNode.pathNodes || []).slice(0, -1);
  1066. this.expandNodes(_nodes);
  1067. } else {
  1068. this.activePath = [];
  1069. this.menus = [store.getNodes()];
  1070. }
  1071. },
  1072. expandNodes: function expandNodes(nodes) {
  1073. var _this3 = this;
  1074. nodes.forEach(function (node) {
  1075. return _this3.handleExpand(node, true /* silent */);
  1076. });
  1077. },
  1078. calculateCheckedNodePaths: function calculateCheckedNodePaths() {
  1079. var _this4 = this;
  1080. var checkedValue = this.checkedValue,
  1081. multiple = this.multiple;
  1082. var checkedValues = multiple ? Object(util_["coerceTruthyValueToArray"])(checkedValue) : [checkedValue];
  1083. this.checkedNodePaths = checkedValues.map(function (v) {
  1084. var checkedNode = _this4.getNodeByValue(v);
  1085. return checkedNode ? checkedNode.pathNodes : [];
  1086. });
  1087. },
  1088. handleKeyDown: function handleKeyDown(e) {
  1089. var target = e.target,
  1090. keyCode = e.keyCode;
  1091. switch (keyCode) {
  1092. case KeyCode.up:
  1093. var prev = getSibling(target, -1);
  1094. focusNode(prev);
  1095. break;
  1096. case KeyCode.down:
  1097. var next = getSibling(target, 1);
  1098. focusNode(next);
  1099. break;
  1100. case KeyCode.left:
  1101. var preMenu = this.$refs.menu[getMenuIndex(target) - 1];
  1102. if (preMenu) {
  1103. var expandedNode = preMenu.$el.querySelector('.el-cascader-node[aria-expanded="true"]');
  1104. focusNode(expandedNode);
  1105. }
  1106. break;
  1107. case KeyCode.right:
  1108. var nextMenu = this.$refs.menu[getMenuIndex(target) + 1];
  1109. if (nextMenu) {
  1110. var firstNode = nextMenu.$el.querySelector('.el-cascader-node[tabindex="-1"]');
  1111. focusNode(firstNode);
  1112. }
  1113. break;
  1114. case KeyCode.enter:
  1115. checkNode(target);
  1116. break;
  1117. case KeyCode.esc:
  1118. case KeyCode.tab:
  1119. this.$emit('close');
  1120. break;
  1121. default:
  1122. return;
  1123. }
  1124. },
  1125. handleExpand: function handleExpand(node, silent) {
  1126. var activePath = this.activePath;
  1127. var level = node.level;
  1128. var path = activePath.slice(0, level - 1);
  1129. var menus = this.menus.slice(0, level);
  1130. if (!node.isLeaf) {
  1131. path.push(node);
  1132. menus.push(node.children);
  1133. }
  1134. this.activePath = path;
  1135. this.menus = menus;
  1136. if (!silent) {
  1137. var pathValues = path.map(function (node) {
  1138. return node.getValue();
  1139. });
  1140. var activePathValues = activePath.map(function (node) {
  1141. return node.getValue();
  1142. });
  1143. if (!Object(util_["valueEquals"])(pathValues, activePathValues)) {
  1144. this.$emit('active-item-change', pathValues); // Deprecated
  1145. this.$emit('expand-change', pathValues);
  1146. }
  1147. }
  1148. },
  1149. handleCheckChange: function handleCheckChange(value) {
  1150. this.checkedValue = value;
  1151. },
  1152. lazyLoad: function lazyLoad(node, onFullfiled) {
  1153. var _this5 = this;
  1154. var config = this.config;
  1155. if (!node) {
  1156. node = node || { root: true, level: 0 };
  1157. this.store = new src_store([], config);
  1158. this.menus = [this.store.getNodes()];
  1159. }
  1160. node.loading = true;
  1161. var resolve = function resolve(dataList) {
  1162. var parent = node.root ? null : node;
  1163. dataList && dataList.length && _this5.store.appendNodes(dataList, parent);
  1164. node.loading = false;
  1165. node.loaded = true;
  1166. // dispose default value on lazy load mode
  1167. if (Array.isArray(_this5.checkedValue)) {
  1168. var nodeValue = _this5.checkedValue[_this5.loadCount++];
  1169. var valueKey = _this5.config.value;
  1170. var leafKey = _this5.config.leaf;
  1171. if (Array.isArray(dataList) && dataList.filter(function (item) {
  1172. return item[valueKey] === nodeValue;
  1173. }).length > 0) {
  1174. var checkedNode = _this5.store.getNodeByValue(nodeValue);
  1175. if (!checkedNode.data[leafKey]) {
  1176. _this5.lazyLoad(checkedNode, function () {
  1177. _this5.handleExpand(checkedNode);
  1178. });
  1179. }
  1180. if (_this5.loadCount === _this5.checkedValue.length) {
  1181. _this5.$parent.computePresentText();
  1182. }
  1183. }
  1184. }
  1185. onFullfiled && onFullfiled(dataList);
  1186. };
  1187. config.lazyLoad(node, resolve);
  1188. },
  1189. /**
  1190. * public methods
  1191. */
  1192. calculateMultiCheckedValue: function calculateMultiCheckedValue() {
  1193. this.checkedValue = this.getCheckedNodes(this.leafOnly).map(function (node) {
  1194. return node.getValueByOption();
  1195. });
  1196. },
  1197. scrollIntoView: function scrollIntoView() {
  1198. if (this.$isServer) return;
  1199. var menus = this.$refs.menu || [];
  1200. menus.forEach(function (menu) {
  1201. var menuElement = menu.$el;
  1202. if (menuElement) {
  1203. var container = menuElement.querySelector('.el-scrollbar__wrap');
  1204. var activeNode = menuElement.querySelector('.el-cascader-node.is-active') || menuElement.querySelector('.el-cascader-node.in-active-path');
  1205. scroll_into_view_default()(container, activeNode);
  1206. }
  1207. });
  1208. },
  1209. getNodeByValue: function getNodeByValue(val) {
  1210. return this.store.getNodeByValue(val);
  1211. },
  1212. getFlattedNodes: function getFlattedNodes(leafOnly) {
  1213. var cached = !this.config.lazy;
  1214. return this.store.getFlattedNodes(leafOnly, cached);
  1215. },
  1216. getCheckedNodes: function getCheckedNodes(leafOnly) {
  1217. var checkedValue = this.checkedValue,
  1218. multiple = this.multiple;
  1219. if (multiple) {
  1220. var nodes = this.getFlattedNodes(leafOnly);
  1221. return nodes.filter(function (node) {
  1222. return node.checked;
  1223. });
  1224. } else {
  1225. return Object(util_["isEmpty"])(checkedValue) ? [] : [this.getNodeByValue(checkedValue)];
  1226. }
  1227. },
  1228. clearCheckedNodes: function clearCheckedNodes() {
  1229. var config = this.config,
  1230. leafOnly = this.leafOnly;
  1231. var multiple = config.multiple,
  1232. emitPath = config.emitPath;
  1233. if (multiple) {
  1234. this.getCheckedNodes(leafOnly).filter(function (node) {
  1235. return !node.isDisabled;
  1236. }).forEach(function (node) {
  1237. return node.doCheck(false);
  1238. });
  1239. this.calculateMultiCheckedValue();
  1240. } else {
  1241. this.checkedValue = emitPath ? [] : null;
  1242. }
  1243. }
  1244. }
  1245. });
  1246. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue?vue&type=script&lang=js&
  1247. /* harmony default export */ var src_cascader_panelvue_type_script_lang_js_ = (cascader_panelvue_type_script_lang_js_);
  1248. // CONCATENATED MODULE: ./packages/cascader-panel/src/cascader-panel.vue
  1249. /* normalize component */
  1250. var cascader_panel_component = Object(componentNormalizer["a" /* default */])(
  1251. src_cascader_panelvue_type_script_lang_js_,
  1252. cascader_panelvue_type_template_id_34932346_render,
  1253. staticRenderFns,
  1254. false,
  1255. null,
  1256. null,
  1257. null
  1258. )
  1259. /* hot reload */
  1260. if (false) { var cascader_panel_api; }
  1261. cascader_panel_component.options.__file = "packages/cascader-panel/src/cascader-panel.vue"
  1262. /* harmony default export */ var cascader_panel = (cascader_panel_component.exports);
  1263. // CONCATENATED MODULE: ./packages/cascader-panel/index.js
  1264. /* istanbul ignore next */
  1265. cascader_panel.install = function (Vue) {
  1266. Vue.component(cascader_panel.name, cascader_panel);
  1267. };
  1268. /* harmony default export */ var packages_cascader_panel = __webpack_exports__["default"] = (cascader_panel);
  1269. /***/ }),
  1270. /***/ 6:
  1271. /***/ (function(module, exports) {
  1272. module.exports = require("element-ui/lib/mixins/locale");
  1273. /***/ }),
  1274. /***/ 9:
  1275. /***/ (function(module, exports) {
  1276. module.exports = require("element-ui/lib/utils/merge");
  1277. /***/ })
  1278. /******/ });