cascader-panel.js 45 KB

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