cascader-panel.js 45 KB

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