cascader.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436
  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 = 114);
  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. /***/ 10:
  180. /***/ (function(module, exports) {
  181. module.exports = require("element-ui/lib/input");
  182. /***/ }),
  183. /***/ 11:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/mixins/migrating");
  186. /***/ }),
  187. /***/ 114:
  188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  189. "use strict";
  190. __webpack_require__.r(__webpack_exports__);
  191. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader/src/cascader.vue?vue&type=template&id=032537a6&
  192. var render = function() {
  193. var _vm = this
  194. var _h = _vm.$createElement
  195. var _c = _vm._self._c || _h
  196. return _c(
  197. "div",
  198. {
  199. directives: [
  200. {
  201. name: "clickoutside",
  202. rawName: "v-clickoutside",
  203. value: function() {
  204. return _vm.toggleDropDownVisible(false)
  205. },
  206. expression: "() => toggleDropDownVisible(false)"
  207. }
  208. ],
  209. ref: "reference",
  210. class: [
  211. "el-cascader",
  212. _vm.realSize && "el-cascader--" + _vm.realSize,
  213. { "is-disabled": _vm.isDisabled }
  214. ],
  215. on: {
  216. mouseenter: function($event) {
  217. _vm.inputHover = true
  218. },
  219. mouseleave: function($event) {
  220. _vm.inputHover = false
  221. },
  222. click: function() {
  223. return _vm.toggleDropDownVisible(_vm.readonly ? undefined : true)
  224. },
  225. keydown: _vm.handleKeyDown
  226. }
  227. },
  228. [
  229. _c(
  230. "el-input",
  231. {
  232. ref: "input",
  233. class: { "is-focus": _vm.dropDownVisible },
  234. attrs: {
  235. size: _vm.realSize,
  236. placeholder: _vm.placeholder,
  237. readonly: _vm.readonly,
  238. disabled: _vm.isDisabled,
  239. "validate-event": false
  240. },
  241. on: {
  242. focus: _vm.handleFocus,
  243. blur: _vm.handleBlur,
  244. input: _vm.handleInput
  245. },
  246. model: {
  247. value: _vm.multiple ? _vm.presentText : _vm.inputValue,
  248. callback: function($$v) {
  249. _vm.multiple ? _vm.presentText : (_vm.inputValue = $$v)
  250. },
  251. expression: "multiple ? presentText : inputValue"
  252. }
  253. },
  254. [
  255. _c("template", { slot: "suffix" }, [
  256. _vm.clearBtnVisible
  257. ? _c("i", {
  258. key: "clear",
  259. staticClass: "el-input__icon el-icon-circle-close",
  260. on: {
  261. click: function($event) {
  262. $event.stopPropagation()
  263. return _vm.handleClear($event)
  264. }
  265. }
  266. })
  267. : _c("i", {
  268. key: "arrow-down",
  269. class: [
  270. "el-input__icon",
  271. "el-icon-arrow-down",
  272. _vm.dropDownVisible && "is-reverse"
  273. ],
  274. on: {
  275. click: function($event) {
  276. $event.stopPropagation()
  277. _vm.toggleDropDownVisible()
  278. }
  279. }
  280. })
  281. ])
  282. ],
  283. 2
  284. ),
  285. _vm.multiple
  286. ? _c(
  287. "div",
  288. { staticClass: "el-cascader__tags" },
  289. [
  290. _vm._l(_vm.presentTags, function(tag) {
  291. return _c(
  292. "el-tag",
  293. {
  294. key: tag.key,
  295. attrs: {
  296. type: "info",
  297. size: _vm.tagSize,
  298. hit: tag.hitState,
  299. closable: tag.closable,
  300. "disable-transitions": ""
  301. },
  302. on: {
  303. close: function($event) {
  304. _vm.deleteTag(tag)
  305. }
  306. }
  307. },
  308. [_c("span", [_vm._v(_vm._s(tag.text))])]
  309. )
  310. }),
  311. _vm.filterable && !_vm.isDisabled
  312. ? _c("input", {
  313. directives: [
  314. {
  315. name: "model",
  316. rawName: "v-model.trim",
  317. value: _vm.inputValue,
  318. expression: "inputValue",
  319. modifiers: { trim: true }
  320. }
  321. ],
  322. staticClass: "el-cascader__search-input",
  323. attrs: {
  324. type: "text",
  325. placeholder: _vm.presentTags.length ? "" : _vm.placeholder
  326. },
  327. domProps: { value: _vm.inputValue },
  328. on: {
  329. input: [
  330. function($event) {
  331. if ($event.target.composing) {
  332. return
  333. }
  334. _vm.inputValue = $event.target.value.trim()
  335. },
  336. function(e) {
  337. return _vm.handleInput(_vm.inputValue, e)
  338. }
  339. ],
  340. click: function($event) {
  341. $event.stopPropagation()
  342. _vm.toggleDropDownVisible(true)
  343. },
  344. keydown: function($event) {
  345. if (
  346. !("button" in $event) &&
  347. _vm._k(
  348. $event.keyCode,
  349. "delete",
  350. [8, 46],
  351. $event.key,
  352. ["Backspace", "Delete", "Del"]
  353. )
  354. ) {
  355. return null
  356. }
  357. return _vm.handleDelete($event)
  358. },
  359. blur: function($event) {
  360. _vm.$forceUpdate()
  361. }
  362. }
  363. })
  364. : _vm._e()
  365. ],
  366. 2
  367. )
  368. : _vm._e(),
  369. _c(
  370. "transition",
  371. {
  372. attrs: { name: "el-zoom-in-top" },
  373. on: { "after-leave": _vm.handleDropdownLeave }
  374. },
  375. [
  376. _c(
  377. "div",
  378. {
  379. directives: [
  380. {
  381. name: "show",
  382. rawName: "v-show",
  383. value: _vm.dropDownVisible,
  384. expression: "dropDownVisible"
  385. }
  386. ],
  387. ref: "popper",
  388. class: ["el-popper", "el-cascader__dropdown", _vm.popperClass]
  389. },
  390. [
  391. _c("el-cascader-panel", {
  392. directives: [
  393. {
  394. name: "show",
  395. rawName: "v-show",
  396. value: !_vm.filtering,
  397. expression: "!filtering"
  398. }
  399. ],
  400. ref: "panel",
  401. attrs: {
  402. options: _vm.options,
  403. props: _vm.config,
  404. border: false,
  405. "render-label": _vm.$scopedSlots.default
  406. },
  407. on: {
  408. "expand-change": _vm.handleExpandChange,
  409. close: function($event) {
  410. _vm.toggleDropDownVisible(false)
  411. }
  412. },
  413. model: {
  414. value: _vm.checkedValue,
  415. callback: function($$v) {
  416. _vm.checkedValue = $$v
  417. },
  418. expression: "checkedValue"
  419. }
  420. }),
  421. _vm.filterable
  422. ? _c(
  423. "el-scrollbar",
  424. {
  425. directives: [
  426. {
  427. name: "show",
  428. rawName: "v-show",
  429. value: _vm.filtering,
  430. expression: "filtering"
  431. }
  432. ],
  433. ref: "suggestionPanel",
  434. staticClass: "el-cascader__suggestion-panel",
  435. attrs: {
  436. tag: "ul",
  437. "view-class": "el-cascader__suggestion-list"
  438. },
  439. nativeOn: {
  440. keydown: function($event) {
  441. return _vm.handleSuggestionKeyDown($event)
  442. }
  443. }
  444. },
  445. [
  446. _vm.suggestions.length
  447. ? _vm._l(_vm.suggestions, function(item, index) {
  448. return _c(
  449. "li",
  450. {
  451. key: item.uid,
  452. class: [
  453. "el-cascader__suggestion-item",
  454. item.checked && "is-checked"
  455. ],
  456. attrs: { tabindex: -1 },
  457. on: {
  458. click: function($event) {
  459. _vm.handleSuggestionClick(index)
  460. }
  461. }
  462. },
  463. [
  464. _c("span", [_vm._v(_vm._s(item.text))]),
  465. item.checked
  466. ? _c("i", { staticClass: "el-icon-check" })
  467. : _vm._e()
  468. ]
  469. )
  470. })
  471. : _vm._t("empty", [
  472. _c(
  473. "li",
  474. { staticClass: "el-cascader__empty-text" },
  475. [_vm._v(_vm._s(_vm.t("el.cascader.noMatch")))]
  476. )
  477. ])
  478. ],
  479. 2
  480. )
  481. : _vm._e()
  482. ],
  483. 1
  484. )
  485. ]
  486. )
  487. ],
  488. 1
  489. )
  490. }
  491. var staticRenderFns = []
  492. render._withStripped = true
  493. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue?vue&type=template&id=032537a6&
  494. // EXTERNAL MODULE: external "element-ui/lib/utils/vue-popper"
  495. var vue_popper_ = __webpack_require__(5);
  496. var vue_popper_default = /*#__PURE__*/__webpack_require__.n(vue_popper_);
  497. // EXTERNAL MODULE: external "element-ui/lib/utils/clickoutside"
  498. var clickoutside_ = __webpack_require__(12);
  499. var clickoutside_default = /*#__PURE__*/__webpack_require__.n(clickoutside_);
  500. // EXTERNAL MODULE: external "element-ui/lib/mixins/emitter"
  501. var emitter_ = __webpack_require__(4);
  502. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  503. // EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
  504. var locale_ = __webpack_require__(6);
  505. var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
  506. // EXTERNAL MODULE: external "element-ui/lib/mixins/migrating"
  507. var migrating_ = __webpack_require__(11);
  508. var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
  509. // EXTERNAL MODULE: external "element-ui/lib/input"
  510. var input_ = __webpack_require__(10);
  511. var input_default = /*#__PURE__*/__webpack_require__.n(input_);
  512. // EXTERNAL MODULE: external "element-ui/lib/tag"
  513. var tag_ = __webpack_require__(37);
  514. var tag_default = /*#__PURE__*/__webpack_require__.n(tag_);
  515. // EXTERNAL MODULE: external "element-ui/lib/scrollbar"
  516. var scrollbar_ = __webpack_require__(15);
  517. var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
  518. // EXTERNAL MODULE: external "element-ui/lib/cascader-panel"
  519. var cascader_panel_ = __webpack_require__(50);
  520. var cascader_panel_default = /*#__PURE__*/__webpack_require__.n(cascader_panel_);
  521. // EXTERNAL MODULE: external "element-ui/lib/utils/aria-utils"
  522. var aria_utils_ = __webpack_require__(40);
  523. var aria_utils_default = /*#__PURE__*/__webpack_require__.n(aria_utils_);
  524. // EXTERNAL MODULE: external "element-ui/lib/locale"
  525. var lib_locale_ = __webpack_require__(20);
  526. // EXTERNAL MODULE: external "element-ui/lib/utils/util"
  527. var util_ = __webpack_require__(3);
  528. // EXTERNAL MODULE: external "element-ui/lib/utils/types"
  529. var types_ = __webpack_require__(17);
  530. // EXTERNAL MODULE: external "element-ui/lib/utils/shared"
  531. var shared_ = __webpack_require__(21);
  532. // EXTERNAL MODULE: external "element-ui/lib/utils/resize-event"
  533. var resize_event_ = __webpack_require__(16);
  534. // EXTERNAL MODULE: external "throttle-debounce/debounce"
  535. var debounce_ = __webpack_require__(19);
  536. var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_);
  537. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader/src/cascader.vue?vue&type=script&lang=js&
  538. //
  539. //
  540. //
  541. //
  542. //
  543. //
  544. //
  545. //
  546. //
  547. //
  548. //
  549. //
  550. //
  551. //
  552. //
  553. //
  554. //
  555. //
  556. //
  557. //
  558. //
  559. //
  560. //
  561. //
  562. //
  563. //
  564. //
  565. //
  566. //
  567. //
  568. //
  569. //
  570. //
  571. //
  572. //
  573. //
  574. //
  575. //
  576. //
  577. //
  578. //
  579. //
  580. //
  581. //
  582. //
  583. //
  584. //
  585. //
  586. //
  587. //
  588. //
  589. //
  590. //
  591. //
  592. //
  593. //
  594. //
  595. //
  596. //
  597. //
  598. //
  599. //
  600. //
  601. //
  602. //
  603. //
  604. //
  605. //
  606. //
  607. //
  608. //
  609. //
  610. //
  611. //
  612. //
  613. //
  614. //
  615. //
  616. //
  617. //
  618. //
  619. //
  620. //
  621. //
  622. //
  623. //
  624. //
  625. //
  626. //
  627. //
  628. //
  629. //
  630. //
  631. //
  632. //
  633. //
  634. //
  635. //
  636. //
  637. //
  638. //
  639. //
  640. //
  641. //
  642. //
  643. //
  644. //
  645. //
  646. //
  647. //
  648. //
  649. //
  650. //
  651. var KeyCode = aria_utils_default.a.keys;
  652. var MigratingProps = {
  653. expandTrigger: {
  654. newProp: 'expandTrigger',
  655. type: String
  656. },
  657. changeOnSelect: {
  658. newProp: 'checkStrictly',
  659. type: Boolean
  660. },
  661. hoverThreshold: {
  662. newProp: 'hoverThreshold',
  663. type: Number
  664. }
  665. };
  666. var PopperMixin = {
  667. props: {
  668. placement: {
  669. type: String,
  670. default: 'bottom-start'
  671. },
  672. appendToBody: vue_popper_default.a.props.appendToBody,
  673. visibleArrow: {
  674. type: Boolean,
  675. default: true
  676. },
  677. arrowOffset: vue_popper_default.a.props.arrowOffset,
  678. offset: vue_popper_default.a.props.offset,
  679. boundariesPadding: vue_popper_default.a.props.boundariesPadding,
  680. popperOptions: vue_popper_default.a.props.popperOptions,
  681. transformOrigin: vue_popper_default.a.props.transformOrigin
  682. },
  683. methods: vue_popper_default.a.methods,
  684. data: vue_popper_default.a.data,
  685. beforeDestroy: vue_popper_default.a.beforeDestroy
  686. };
  687. var InputSizeMap = {
  688. medium: 36,
  689. small: 32,
  690. mini: 28
  691. };
  692. /* harmony default export */ var cascadervue_type_script_lang_js_ = ({
  693. name: 'ElCascader',
  694. directives: { Clickoutside: clickoutside_default.a },
  695. mixins: [PopperMixin, emitter_default.a, locale_default.a, migrating_default.a],
  696. inject: {
  697. elForm: {
  698. default: ''
  699. },
  700. elFormItem: {
  701. default: ''
  702. }
  703. },
  704. components: {
  705. ElInput: input_default.a,
  706. ElTag: tag_default.a,
  707. ElScrollbar: scrollbar_default.a,
  708. ElCascaderPanel: cascader_panel_default.a
  709. },
  710. props: {
  711. value: {},
  712. options: Array,
  713. props: Object,
  714. size: String,
  715. placeholder: {
  716. type: String,
  717. default: function _default() {
  718. return Object(lib_locale_["t"])('el.cascader.placeholder');
  719. }
  720. },
  721. disabled: Boolean,
  722. clearable: Boolean,
  723. filterable: Boolean,
  724. filterMethod: Function,
  725. separator: {
  726. type: String,
  727. default: ' / '
  728. },
  729. showAllLevels: {
  730. type: Boolean,
  731. default: true
  732. },
  733. collapseTags: Boolean,
  734. debounce: {
  735. type: Number,
  736. default: 300
  737. },
  738. beforeFilter: {
  739. type: Function,
  740. default: function _default() {
  741. return function () {};
  742. }
  743. },
  744. popperClass: String
  745. },
  746. data: function data() {
  747. return {
  748. dropDownVisible: false,
  749. checkedValue: this.value,
  750. inputHover: false,
  751. inputValue: null,
  752. presentText: null,
  753. presentTags: [],
  754. checkedNodes: [],
  755. filtering: false,
  756. suggestions: [],
  757. inputInitialHeight: 0,
  758. pressDeleteCount: 0
  759. };
  760. },
  761. computed: {
  762. realSize: function realSize() {
  763. var _elFormItemSize = (this.elFormItem || {}).elFormItemSize;
  764. return this.size || _elFormItemSize || (this.$ELEMENT || {}).size;
  765. },
  766. tagSize: function tagSize() {
  767. return ['small', 'mini'].indexOf(this.realSize) > -1 ? 'mini' : 'small';
  768. },
  769. isDisabled: function isDisabled() {
  770. return this.disabled || (this.elForm || {}).disabled;
  771. },
  772. config: function config() {
  773. var config = this.props || {};
  774. var $attrs = this.$attrs;
  775. Object.keys(MigratingProps).forEach(function (oldProp) {
  776. var _MigratingProps$oldPr = MigratingProps[oldProp],
  777. newProp = _MigratingProps$oldPr.newProp,
  778. type = _MigratingProps$oldPr.type;
  779. var oldValue = $attrs[oldProp] || $attrs[Object(util_["kebabCase"])(oldProp)];
  780. if (Object(shared_["isDef"])(oldProp) && !Object(shared_["isDef"])(config[newProp])) {
  781. if (type === Boolean && oldValue === '') {
  782. oldValue = true;
  783. }
  784. config[newProp] = oldValue;
  785. }
  786. });
  787. return config;
  788. },
  789. multiple: function multiple() {
  790. return this.config.multiple;
  791. },
  792. leafOnly: function leafOnly() {
  793. return !this.config.checkStrictly;
  794. },
  795. readonly: function readonly() {
  796. return !this.filterable || this.multiple;
  797. },
  798. clearBtnVisible: function clearBtnVisible() {
  799. if (!this.clearable || this.isDisabled || this.filtering || !this.inputHover) {
  800. return false;
  801. }
  802. return this.multiple ? !!this.checkedNodes.filter(function (node) {
  803. return !node.isDisabled;
  804. }).length : !!this.presentText;
  805. },
  806. panel: function panel() {
  807. return this.$refs.panel;
  808. }
  809. },
  810. watch: {
  811. disabled: function disabled() {
  812. this.computePresentContent();
  813. },
  814. value: function value(val) {
  815. if (!Object(util_["isEqual"])(val, this.checkedValue)) {
  816. this.checkedValue = val;
  817. this.computePresentContent();
  818. }
  819. },
  820. checkedValue: function checkedValue(val) {
  821. var value = this.value,
  822. dropDownVisible = this.dropDownVisible;
  823. var _config = this.config,
  824. checkStrictly = _config.checkStrictly,
  825. multiple = _config.multiple;
  826. if (!Object(util_["isEqual"])(val, value) || Object(types_["isUndefined"])(value)) {
  827. this.computePresentContent();
  828. // hide dropdown when single mode
  829. if (!multiple && !checkStrictly && dropDownVisible) {
  830. this.toggleDropDownVisible(false);
  831. }
  832. this.$emit('input', val);
  833. this.$emit('change', val);
  834. this.dispatch('ElFormItem', 'el.form.change', [val]);
  835. }
  836. },
  837. options: {
  838. handler: function handler() {
  839. this.$nextTick(this.computePresentContent);
  840. },
  841. deep: true
  842. },
  843. presentText: function presentText(val) {
  844. this.inputValue = val;
  845. },
  846. presentTags: function presentTags(val, oldVal) {
  847. if (this.multiple && (val.length || oldVal.length)) {
  848. this.$nextTick(this.updateStyle);
  849. }
  850. },
  851. filtering: function filtering(val) {
  852. this.$nextTick(this.updatePopper);
  853. }
  854. },
  855. mounted: function mounted() {
  856. var _this = this;
  857. var input = this.$refs.input;
  858. if (input && input.$el) {
  859. this.inputInitialHeight = input.$el.offsetHeight || InputSizeMap[this.realSize] || 40;
  860. }
  861. if (!this.isEmptyValue(this.value)) {
  862. this.computePresentContent();
  863. }
  864. this.filterHandler = debounce_default()(this.debounce, function () {
  865. var inputValue = _this.inputValue;
  866. if (!inputValue) {
  867. _this.filtering = false;
  868. return;
  869. }
  870. var before = _this.beforeFilter(inputValue);
  871. if (before && before.then) {
  872. before.then(_this.getSuggestions);
  873. } else if (before !== false) {
  874. _this.getSuggestions();
  875. } else {
  876. _this.filtering = false;
  877. }
  878. });
  879. Object(resize_event_["addResizeListener"])(this.$el, this.updateStyle);
  880. },
  881. beforeDestroy: function beforeDestroy() {
  882. Object(resize_event_["removeResizeListener"])(this.$el, this.updateStyle);
  883. },
  884. methods: {
  885. getMigratingConfig: function getMigratingConfig() {
  886. return {
  887. props: {
  888. 'expand-trigger': 'expand-trigger is removed, use `props.expandTrigger` instead.',
  889. 'change-on-select': 'change-on-select is removed, use `props.checkStrictly` instead.',
  890. 'hover-threshold': 'hover-threshold is removed, use `props.hoverThreshold` instead'
  891. },
  892. events: {
  893. 'active-item-change': 'active-item-change is renamed to expand-change'
  894. }
  895. };
  896. },
  897. toggleDropDownVisible: function toggleDropDownVisible(visible) {
  898. var _this2 = this;
  899. if (this.isDisabled) return;
  900. var dropDownVisible = this.dropDownVisible;
  901. var input = this.$refs.input;
  902. visible = Object(shared_["isDef"])(visible) ? visible : !dropDownVisible;
  903. if (visible !== dropDownVisible) {
  904. this.dropDownVisible = visible;
  905. if (visible) {
  906. this.$nextTick(function () {
  907. _this2.updatePopper();
  908. _this2.panel.scrollIntoView();
  909. });
  910. }
  911. input.$refs.input.setAttribute('aria-expanded', visible);
  912. this.$emit('visible-change', visible);
  913. }
  914. },
  915. handleDropdownLeave: function handleDropdownLeave() {
  916. this.filtering = false;
  917. this.inputValue = this.presentText;
  918. this.doDestroy();
  919. },
  920. handleKeyDown: function handleKeyDown(event) {
  921. switch (event.keyCode) {
  922. case KeyCode.enter:
  923. this.toggleDropDownVisible();
  924. break;
  925. case KeyCode.down:
  926. this.toggleDropDownVisible(true);
  927. this.focusFirstNode();
  928. event.preventDefault();
  929. break;
  930. case KeyCode.esc:
  931. case KeyCode.tab:
  932. this.toggleDropDownVisible(false);
  933. break;
  934. }
  935. },
  936. handleFocus: function handleFocus(e) {
  937. this.$emit('focus', e);
  938. },
  939. handleBlur: function handleBlur(e) {
  940. this.$emit('blur', e);
  941. },
  942. handleInput: function handleInput(val, event) {
  943. !this.dropDownVisible && this.toggleDropDownVisible(true);
  944. if (event && event.isComposing) return;
  945. if (val) {
  946. this.filterHandler();
  947. } else {
  948. this.filtering = false;
  949. }
  950. },
  951. handleClear: function handleClear() {
  952. this.presentText = '';
  953. this.panel.clearCheckedNodes();
  954. },
  955. handleExpandChange: function handleExpandChange(value) {
  956. this.$nextTick(this.updatePopper.bind(this));
  957. this.$emit('expand-change', value);
  958. this.$emit('active-item-change', value); // Deprecated
  959. },
  960. focusFirstNode: function focusFirstNode() {
  961. var _this3 = this;
  962. this.$nextTick(function () {
  963. var filtering = _this3.filtering;
  964. var _$refs = _this3.$refs,
  965. popper = _$refs.popper,
  966. suggestionPanel = _$refs.suggestionPanel;
  967. var firstNode = null;
  968. if (filtering && suggestionPanel) {
  969. firstNode = suggestionPanel.$el.querySelector('.el-cascader__suggestion-item');
  970. } else {
  971. var firstMenu = popper.querySelector('.el-cascader-menu');
  972. firstNode = firstMenu.querySelector('.el-cascader-node[tabindex="-1"]');
  973. }
  974. if (firstNode) {
  975. firstNode.focus();
  976. !filtering && firstNode.click();
  977. }
  978. });
  979. },
  980. computePresentContent: function computePresentContent() {
  981. var _this4 = this;
  982. // nextTick is required, because checked nodes may not change right now
  983. this.$nextTick(function () {
  984. if (_this4.config.multiple) {
  985. _this4.computePresentTags();
  986. _this4.presentText = _this4.presentTags.length ? ' ' : null;
  987. } else {
  988. _this4.computePresentText();
  989. }
  990. });
  991. },
  992. isEmptyValue: function isEmptyValue(val) {
  993. var multiple = this.multiple;
  994. var emitPath = this.panel.config.emitPath;
  995. if (multiple || emitPath) {
  996. return Object(util_["isEmpty"])(val);
  997. }
  998. return false;
  999. },
  1000. computePresentText: function computePresentText() {
  1001. var checkedValue = this.checkedValue,
  1002. config = this.config;
  1003. if (!this.isEmptyValue(checkedValue)) {
  1004. var node = this.panel.getNodeByValue(checkedValue);
  1005. if (node && (config.checkStrictly || node.isLeaf)) {
  1006. this.presentText = node.getText(this.showAllLevels, this.separator);
  1007. return;
  1008. }
  1009. }
  1010. this.presentText = null;
  1011. },
  1012. computePresentTags: function computePresentTags() {
  1013. var isDisabled = this.isDisabled,
  1014. leafOnly = this.leafOnly,
  1015. showAllLevels = this.showAllLevels,
  1016. separator = this.separator,
  1017. collapseTags = this.collapseTags;
  1018. var checkedNodes = this.getCheckedNodes(leafOnly);
  1019. var tags = [];
  1020. var genTag = function genTag(node) {
  1021. return {
  1022. node: node,
  1023. key: node.uid,
  1024. text: node.getText(showAllLevels, separator),
  1025. hitState: false,
  1026. closable: !isDisabled && !node.isDisabled
  1027. };
  1028. };
  1029. if (checkedNodes.length) {
  1030. var first = checkedNodes[0],
  1031. rest = checkedNodes.slice(1);
  1032. var restCount = rest.length;
  1033. tags.push(genTag(first));
  1034. if (restCount) {
  1035. if (collapseTags) {
  1036. tags.push({
  1037. key: -1,
  1038. text: '+ ' + restCount,
  1039. closable: false
  1040. });
  1041. } else {
  1042. rest.forEach(function (node) {
  1043. return tags.push(genTag(node));
  1044. });
  1045. }
  1046. }
  1047. }
  1048. this.checkedNodes = checkedNodes;
  1049. this.presentTags = tags;
  1050. },
  1051. getSuggestions: function getSuggestions() {
  1052. var _this5 = this;
  1053. var filterMethod = this.filterMethod;
  1054. if (!Object(types_["isFunction"])(filterMethod)) {
  1055. filterMethod = function filterMethod(node, keyword) {
  1056. return node.text.includes(keyword);
  1057. };
  1058. }
  1059. var suggestions = this.panel.getFlattedNodes(this.leafOnly).filter(function (node) {
  1060. if (node.isDisabled) return false;
  1061. node.text = node.getText(_this5.showAllLevels, _this5.separator) || '';
  1062. return filterMethod(node, _this5.inputValue);
  1063. });
  1064. if (this.multiple) {
  1065. this.presentTags.forEach(function (tag) {
  1066. tag.hitState = false;
  1067. });
  1068. } else {
  1069. suggestions.forEach(function (node) {
  1070. node.checked = Object(util_["isEqual"])(_this5.checkedValue, node.getValueByOption());
  1071. });
  1072. }
  1073. this.filtering = true;
  1074. this.suggestions = suggestions;
  1075. this.$nextTick(this.updatePopper);
  1076. },
  1077. handleSuggestionKeyDown: function handleSuggestionKeyDown(event) {
  1078. var keyCode = event.keyCode,
  1079. target = event.target;
  1080. switch (keyCode) {
  1081. case KeyCode.enter:
  1082. target.click();
  1083. break;
  1084. case KeyCode.up:
  1085. var prev = target.previousElementSibling;
  1086. prev && prev.focus();
  1087. break;
  1088. case KeyCode.down:
  1089. var next = target.nextElementSibling;
  1090. next && next.focus();
  1091. break;
  1092. case KeyCode.esc:
  1093. case KeyCode.tab:
  1094. this.toggleDropDownVisible(false);
  1095. break;
  1096. }
  1097. },
  1098. handleDelete: function handleDelete() {
  1099. var inputValue = this.inputValue,
  1100. pressDeleteCount = this.pressDeleteCount,
  1101. presentTags = this.presentTags;
  1102. var lastIndex = presentTags.length - 1;
  1103. var lastTag = presentTags[lastIndex];
  1104. this.pressDeleteCount = inputValue ? 0 : pressDeleteCount + 1;
  1105. if (!lastTag) return;
  1106. if (this.pressDeleteCount) {
  1107. if (lastTag.hitState) {
  1108. this.deleteTag(lastTag);
  1109. } else {
  1110. lastTag.hitState = true;
  1111. }
  1112. }
  1113. },
  1114. handleSuggestionClick: function handleSuggestionClick(index) {
  1115. var multiple = this.multiple;
  1116. var targetNode = this.suggestions[index];
  1117. if (multiple) {
  1118. var checked = targetNode.checked;
  1119. targetNode.doCheck(!checked);
  1120. this.panel.calculateMultiCheckedValue();
  1121. } else {
  1122. this.checkedValue = targetNode.getValueByOption();
  1123. this.toggleDropDownVisible(false);
  1124. }
  1125. },
  1126. deleteTag: function deleteTag(tag) {
  1127. var checkedValue = this.checkedValue;
  1128. var current = tag.node.getValueByOption();
  1129. var val = checkedValue.find(function (n) {
  1130. return Object(util_["isEqual"])(n, current);
  1131. });
  1132. this.checkedValue = checkedValue.filter(function (n) {
  1133. return !Object(util_["isEqual"])(n, current);
  1134. });
  1135. this.$emit('remove-tag', val);
  1136. },
  1137. updateStyle: function updateStyle() {
  1138. var $el = this.$el,
  1139. inputInitialHeight = this.inputInitialHeight;
  1140. if (this.$isServer || !$el) return;
  1141. var suggestionPanel = this.$refs.suggestionPanel;
  1142. var inputInner = $el.querySelector('.el-input__inner');
  1143. if (!inputInner) return;
  1144. var tags = $el.querySelector('.el-cascader__tags');
  1145. var suggestionPanelEl = null;
  1146. if (suggestionPanel && (suggestionPanelEl = suggestionPanel.$el)) {
  1147. var suggestionList = suggestionPanelEl.querySelector('.el-cascader__suggestion-list');
  1148. suggestionList.style.minWidth = inputInner.offsetWidth + 'px';
  1149. }
  1150. if (tags) {
  1151. var offsetHeight = Math.round(tags.getBoundingClientRect().height);
  1152. var height = Math.max(offsetHeight + 6, inputInitialHeight) + 'px';
  1153. inputInner.style.height = height;
  1154. if (this.dropDownVisible) {
  1155. this.updatePopper();
  1156. }
  1157. }
  1158. },
  1159. /**
  1160. * public methods
  1161. */
  1162. getCheckedNodes: function getCheckedNodes(leafOnly) {
  1163. return this.panel.getCheckedNodes(leafOnly);
  1164. }
  1165. }
  1166. });
  1167. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue?vue&type=script&lang=js&
  1168. /* harmony default export */ var src_cascadervue_type_script_lang_js_ = (cascadervue_type_script_lang_js_);
  1169. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1170. var componentNormalizer = __webpack_require__(0);
  1171. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue
  1172. /* normalize component */
  1173. var component = Object(componentNormalizer["a" /* default */])(
  1174. src_cascadervue_type_script_lang_js_,
  1175. render,
  1176. staticRenderFns,
  1177. false,
  1178. null,
  1179. null,
  1180. null
  1181. )
  1182. /* hot reload */
  1183. if (false) { var api; }
  1184. component.options.__file = "packages/cascader/src/cascader.vue"
  1185. /* harmony default export */ var cascader = (component.exports);
  1186. // CONCATENATED MODULE: ./packages/cascader/index.js
  1187. /* istanbul ignore next */
  1188. cascader.install = function (Vue) {
  1189. Vue.component(cascader.name, cascader);
  1190. };
  1191. /* harmony default export */ var packages_cascader = __webpack_exports__["default"] = (cascader);
  1192. /***/ }),
  1193. /***/ 12:
  1194. /***/ (function(module, exports) {
  1195. module.exports = require("element-ui/lib/utils/clickoutside");
  1196. /***/ }),
  1197. /***/ 15:
  1198. /***/ (function(module, exports) {
  1199. module.exports = require("element-ui/lib/scrollbar");
  1200. /***/ }),
  1201. /***/ 16:
  1202. /***/ (function(module, exports) {
  1203. module.exports = require("element-ui/lib/utils/resize-event");
  1204. /***/ }),
  1205. /***/ 17:
  1206. /***/ (function(module, exports) {
  1207. module.exports = require("element-ui/lib/utils/types");
  1208. /***/ }),
  1209. /***/ 19:
  1210. /***/ (function(module, exports) {
  1211. module.exports = require("throttle-debounce/debounce");
  1212. /***/ }),
  1213. /***/ 20:
  1214. /***/ (function(module, exports) {
  1215. module.exports = require("element-ui/lib/locale");
  1216. /***/ }),
  1217. /***/ 21:
  1218. /***/ (function(module, exports) {
  1219. module.exports = require("element-ui/lib/utils/shared");
  1220. /***/ }),
  1221. /***/ 3:
  1222. /***/ (function(module, exports) {
  1223. module.exports = require("element-ui/lib/utils/util");
  1224. /***/ }),
  1225. /***/ 37:
  1226. /***/ (function(module, exports) {
  1227. module.exports = require("element-ui/lib/tag");
  1228. /***/ }),
  1229. /***/ 4:
  1230. /***/ (function(module, exports) {
  1231. module.exports = require("element-ui/lib/mixins/emitter");
  1232. /***/ }),
  1233. /***/ 40:
  1234. /***/ (function(module, exports) {
  1235. module.exports = require("element-ui/lib/utils/aria-utils");
  1236. /***/ }),
  1237. /***/ 5:
  1238. /***/ (function(module, exports) {
  1239. module.exports = require("element-ui/lib/utils/vue-popper");
  1240. /***/ }),
  1241. /***/ 50:
  1242. /***/ (function(module, exports) {
  1243. module.exports = require("element-ui/lib/cascader-panel");
  1244. /***/ }),
  1245. /***/ 6:
  1246. /***/ (function(module, exports) {
  1247. module.exports = require("element-ui/lib/mixins/locale");
  1248. /***/ })
  1249. /******/ });