cascader-panel.js 43 KB

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