cascader.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  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 = 112);
  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/mixins/migrating");
  182. /***/ }),
  183. /***/ 11:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/input");
  186. /***/ }),
  187. /***/ 112:
  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, index) {
  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(index)
  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__(10);
  508. var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
  509. // EXTERNAL MODULE: external "element-ui/lib/input"
  510. var input_ = __webpack_require__(11);
  511. var input_default = /*#__PURE__*/__webpack_require__.n(input_);
  512. // EXTERNAL MODULE: external "element-ui/lib/tag"
  513. var tag_ = __webpack_require__(36);
  514. var tag_default = /*#__PURE__*/__webpack_require__.n(tag_);
  515. // EXTERNAL MODULE: external "element-ui/lib/scrollbar"
  516. var scrollbar_ = __webpack_require__(13);
  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__(39);
  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__(19);
  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__(15);
  534. // EXTERNAL MODULE: external "throttle-debounce/debounce"
  535. var debounce_ = __webpack_require__(16);
  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. },
  682. methods: vue_popper_default.a.methods,
  683. data: vue_popper_default.a.data,
  684. beforeDestroy: vue_popper_default.a.beforeDestroy
  685. };
  686. var InputSizeMap = {
  687. medium: 36,
  688. small: 32,
  689. mini: 28
  690. };
  691. /* harmony default export */ var cascadervue_type_script_lang_js_ = ({
  692. name: 'ElCascader',
  693. directives: { Clickoutside: clickoutside_default.a },
  694. mixins: [PopperMixin, emitter_default.a, locale_default.a, migrating_default.a],
  695. inject: {
  696. elForm: {
  697. default: ''
  698. },
  699. elFormItem: {
  700. default: ''
  701. }
  702. },
  703. components: {
  704. ElInput: input_default.a,
  705. ElTag: tag_default.a,
  706. ElScrollbar: scrollbar_default.a,
  707. ElCascaderPanel: cascader_panel_default.a
  708. },
  709. props: {
  710. value: {},
  711. options: Array,
  712. props: Object,
  713. size: String,
  714. placeholder: {
  715. type: String,
  716. default: function _default() {
  717. return Object(lib_locale_["t"])('el.cascader.placeholder');
  718. }
  719. },
  720. disabled: Boolean,
  721. clearable: Boolean,
  722. filterable: Boolean,
  723. filterMethod: Function,
  724. separator: {
  725. type: String,
  726. default: ' / '
  727. },
  728. showAllLevels: {
  729. type: Boolean,
  730. default: true
  731. },
  732. collapseTags: Boolean,
  733. debounce: {
  734. type: Number,
  735. default: 300
  736. },
  737. beforeFilter: {
  738. type: Function,
  739. default: function _default() {
  740. return function () {};
  741. }
  742. },
  743. popperClass: String
  744. },
  745. data: function data() {
  746. return {
  747. dropDownVisible: false,
  748. checkedValue: this.value || null,
  749. inputHover: false,
  750. inputValue: null,
  751. presentText: null,
  752. presentTags: [],
  753. checkedNodes: [],
  754. filtering: false,
  755. suggestions: [],
  756. inputInitialHeight: 0,
  757. pressDeleteCount: 0
  758. };
  759. },
  760. computed: {
  761. realSize: function realSize() {
  762. var _elFormItemSize = (this.elFormItem || {}).elFormItemSize;
  763. return this.size || _elFormItemSize || (this.$ELEMENT || {}).size;
  764. },
  765. tagSize: function tagSize() {
  766. return ['small', 'mini'].indexOf(this.realSize) > -1 ? 'mini' : 'small';
  767. },
  768. isDisabled: function isDisabled() {
  769. return this.disabled || (this.elForm || {}).disabled;
  770. },
  771. config: function config() {
  772. var config = this.props || {};
  773. var $attrs = this.$attrs;
  774. Object.keys(MigratingProps).forEach(function (oldProp) {
  775. var _MigratingProps$oldPr = MigratingProps[oldProp],
  776. newProp = _MigratingProps$oldPr.newProp,
  777. type = _MigratingProps$oldPr.type;
  778. var oldValue = $attrs[oldProp] || $attrs[Object(util_["kebabCase"])(oldProp)];
  779. if (Object(shared_["isDef"])(oldProp) && !Object(shared_["isDef"])(config[newProp])) {
  780. if (type === Boolean && oldValue === '') {
  781. oldValue = true;
  782. }
  783. config[newProp] = oldValue;
  784. }
  785. });
  786. return config;
  787. },
  788. multiple: function multiple() {
  789. return this.config.multiple;
  790. },
  791. leafOnly: function leafOnly() {
  792. return !this.config.checkStrictly;
  793. },
  794. readonly: function readonly() {
  795. return !this.filterable || this.multiple;
  796. },
  797. clearBtnVisible: function clearBtnVisible() {
  798. if (!this.clearable || this.isDisabled || this.filtering || !this.inputHover) {
  799. return false;
  800. }
  801. return this.multiple ? !!this.checkedNodes.filter(function (node) {
  802. return !node.isDisabled;
  803. }).length : !!this.presentText;
  804. },
  805. panel: function panel() {
  806. return this.$refs.panel;
  807. }
  808. },
  809. watch: {
  810. disabled: function disabled() {
  811. this.computePresentContent();
  812. },
  813. value: function value(val) {
  814. if (!Object(util_["isEqual"])(val, this.checkedValue)) {
  815. this.checkedValue = val;
  816. this.computePresentContent();
  817. }
  818. },
  819. checkedValue: function checkedValue(val) {
  820. var value = this.value,
  821. dropDownVisible = this.dropDownVisible;
  822. var _config = this.config,
  823. checkStrictly = _config.checkStrictly,
  824. multiple = _config.multiple;
  825. if (!Object(util_["isEqual"])(val, value) || Object(types_["isUndefined"])(value)) {
  826. this.computePresentContent();
  827. // hide dropdown when single mode
  828. if (!multiple && !checkStrictly && dropDownVisible) {
  829. this.toggleDropDownVisible(false);
  830. }
  831. this.$emit('input', val);
  832. this.$emit('change', val);
  833. this.dispatch('ElFormItem', 'el.form.change', [val]);
  834. }
  835. },
  836. options: {
  837. handler: function handler() {
  838. this.$nextTick(this.computePresentContent);
  839. },
  840. deep: true
  841. },
  842. presentText: function presentText(val) {
  843. this.inputValue = val;
  844. },
  845. presentTags: function presentTags(val, oldVal) {
  846. if (this.multiple && (val.length || oldVal.length)) {
  847. this.$nextTick(this.updateStyle);
  848. }
  849. },
  850. filtering: function filtering(val) {
  851. this.$nextTick(this.updatePopper);
  852. }
  853. },
  854. mounted: function mounted() {
  855. var _this = this;
  856. var input = this.$refs.input;
  857. if (input && input.$el) {
  858. this.inputInitialHeight = input.$el.offsetHeight || InputSizeMap[this.realSize] || 40;
  859. }
  860. if (!Object(util_["isEmpty"])(this.value)) {
  861. this.computePresentContent();
  862. }
  863. this.filterHandler = debounce_default()(this.debounce, function () {
  864. var inputValue = _this.inputValue;
  865. if (!inputValue) {
  866. _this.filtering = false;
  867. return;
  868. }
  869. var before = _this.beforeFilter(inputValue);
  870. if (before && before.then) {
  871. before.then(_this.getSuggestions);
  872. } else if (before !== false) {
  873. _this.getSuggestions();
  874. } else {
  875. _this.filtering = false;
  876. }
  877. });
  878. Object(resize_event_["addResizeListener"])(this.$el, this.updateStyle);
  879. },
  880. beforeDestroy: function beforeDestroy() {
  881. Object(resize_event_["removeResizeListener"])(this.$el, this.updateStyle);
  882. },
  883. methods: {
  884. getMigratingConfig: function getMigratingConfig() {
  885. return {
  886. props: {
  887. 'expand-trigger': 'expand-trigger is removed, use `props.expandTrigger` instead.',
  888. 'change-on-select': 'change-on-select is removed, use `props.checkStrictly` instead.',
  889. 'hover-threshold': 'hover-threshold is removed, use `props.hoverThreshold` instead'
  890. },
  891. events: {
  892. 'active-item-change': 'active-item-change is renamed to expand-change'
  893. }
  894. };
  895. },
  896. toggleDropDownVisible: function toggleDropDownVisible(visible) {
  897. var _this2 = this;
  898. if (this.isDisabled) return;
  899. var dropDownVisible = this.dropDownVisible;
  900. var input = this.$refs.input;
  901. visible = Object(shared_["isDef"])(visible) ? visible : !dropDownVisible;
  902. if (visible !== dropDownVisible) {
  903. this.dropDownVisible = visible;
  904. if (visible) {
  905. this.$nextTick(function () {
  906. _this2.updatePopper();
  907. _this2.panel.scrollIntoView();
  908. });
  909. }
  910. input.$refs.input.setAttribute('aria-expanded', visible);
  911. this.$emit('visible-change', visible);
  912. }
  913. },
  914. handleDropdownLeave: function handleDropdownLeave() {
  915. this.filtering = false;
  916. this.inputValue = this.presentText;
  917. },
  918. handleKeyDown: function handleKeyDown(event) {
  919. switch (event.keyCode) {
  920. case KeyCode.enter:
  921. this.toggleDropDownVisible();
  922. break;
  923. case KeyCode.down:
  924. this.toggleDropDownVisible(true);
  925. this.focusFirstNode();
  926. event.preventDefault();
  927. break;
  928. case KeyCode.esc:
  929. case KeyCode.tab:
  930. this.toggleDropDownVisible(false);
  931. break;
  932. }
  933. },
  934. handleFocus: function handleFocus(e) {
  935. this.$emit('focus', e);
  936. },
  937. handleBlur: function handleBlur(e) {
  938. this.$emit('blur', e);
  939. },
  940. handleInput: function handleInput(val, event) {
  941. !this.dropDownVisible && this.toggleDropDownVisible(true);
  942. if (event && event.isComposing) return;
  943. if (val) {
  944. this.filterHandler();
  945. } else {
  946. this.filtering = false;
  947. }
  948. },
  949. handleClear: function handleClear() {
  950. this.presentText = '';
  951. this.panel.clearCheckedNodes();
  952. },
  953. handleExpandChange: function handleExpandChange(value) {
  954. this.$nextTick(this.updatePopper.bind(this));
  955. this.$emit('expand-change', value);
  956. this.$emit('active-item-change', value); // Deprecated
  957. },
  958. focusFirstNode: function focusFirstNode() {
  959. var _this3 = this;
  960. this.$nextTick(function () {
  961. var filtering = _this3.filtering;
  962. var _$refs = _this3.$refs,
  963. popper = _$refs.popper,
  964. suggestionPanel = _$refs.suggestionPanel;
  965. var firstNode = null;
  966. if (filtering && suggestionPanel) {
  967. firstNode = suggestionPanel.$el.querySelector('.el-cascader__suggestion-item');
  968. } else {
  969. var firstMenu = popper.querySelector('.el-cascader-menu');
  970. firstNode = firstMenu.querySelector('.el-cascader-node[tabindex="-1"]');
  971. }
  972. if (firstNode) {
  973. firstNode.focus();
  974. !filtering && firstNode.click();
  975. }
  976. });
  977. },
  978. computePresentContent: function computePresentContent() {
  979. var _this4 = this;
  980. // nextTick is required, because checked nodes may not change right now
  981. this.$nextTick(function () {
  982. if (_this4.config.multiple) {
  983. _this4.computePresentTags();
  984. _this4.presentText = _this4.presentTags.length ? ' ' : null;
  985. } else {
  986. _this4.computePresentText();
  987. }
  988. });
  989. },
  990. computePresentText: function computePresentText() {
  991. var checkedValue = this.checkedValue,
  992. config = this.config;
  993. if (!Object(util_["isEmpty"])(checkedValue)) {
  994. var node = this.panel.getNodeByValue(checkedValue);
  995. if (node && (config.checkStrictly || node.isLeaf)) {
  996. this.presentText = node.getText(this.showAllLevels, this.separator);
  997. return;
  998. }
  999. }
  1000. this.presentText = null;
  1001. },
  1002. computePresentTags: function computePresentTags() {
  1003. var isDisabled = this.isDisabled,
  1004. leafOnly = this.leafOnly,
  1005. showAllLevels = this.showAllLevels,
  1006. separator = this.separator,
  1007. collapseTags = this.collapseTags;
  1008. var checkedNodes = this.getCheckedNodes(leafOnly);
  1009. var tags = [];
  1010. var genTag = function genTag(node) {
  1011. return {
  1012. node: node,
  1013. key: node.uid,
  1014. text: node.getText(showAllLevels, separator),
  1015. hitState: false,
  1016. closable: !isDisabled && !node.isDisabled
  1017. };
  1018. };
  1019. if (checkedNodes.length) {
  1020. var first = checkedNodes[0],
  1021. rest = checkedNodes.slice(1);
  1022. var restCount = rest.length;
  1023. tags.push(genTag(first));
  1024. if (restCount) {
  1025. if (collapseTags) {
  1026. tags.push({
  1027. key: -1,
  1028. text: '+ ' + restCount,
  1029. closable: false
  1030. });
  1031. } else {
  1032. rest.forEach(function (node) {
  1033. return tags.push(genTag(node));
  1034. });
  1035. }
  1036. }
  1037. }
  1038. this.checkedNodes = checkedNodes;
  1039. this.presentTags = tags;
  1040. },
  1041. getSuggestions: function getSuggestions() {
  1042. var _this5 = this;
  1043. var filterMethod = this.filterMethod;
  1044. if (!Object(types_["isFunction"])(filterMethod)) {
  1045. filterMethod = function filterMethod(node, keyword) {
  1046. return node.text.includes(keyword);
  1047. };
  1048. }
  1049. var suggestions = this.panel.getFlattedNodes(this.leafOnly).filter(function (node) {
  1050. if (node.isDisabled) return false;
  1051. node.text = node.getText(_this5.showAllLevels, _this5.separator) || '';
  1052. return filterMethod(node, _this5.inputValue);
  1053. });
  1054. if (this.multiple) {
  1055. this.presentTags.forEach(function (tag) {
  1056. tag.hitState = false;
  1057. });
  1058. } else {
  1059. suggestions.forEach(function (node) {
  1060. node.checked = Object(util_["isEqual"])(_this5.checkedValue, node.getValueByOption());
  1061. });
  1062. }
  1063. this.filtering = true;
  1064. this.suggestions = suggestions;
  1065. this.$nextTick(this.updatePopper);
  1066. },
  1067. handleSuggestionKeyDown: function handleSuggestionKeyDown(event) {
  1068. var keyCode = event.keyCode,
  1069. target = event.target;
  1070. switch (keyCode) {
  1071. case KeyCode.enter:
  1072. target.click();
  1073. break;
  1074. case KeyCode.up:
  1075. var prev = target.previousElementSibling;
  1076. prev && prev.focus();
  1077. break;
  1078. case KeyCode.down:
  1079. var next = target.nextElementSibling;
  1080. next && next.focus();
  1081. break;
  1082. case KeyCode.esc:
  1083. case KeyCode.tab:
  1084. this.toggleDropDownVisible(false);
  1085. break;
  1086. }
  1087. },
  1088. handleDelete: function handleDelete() {
  1089. var inputValue = this.inputValue,
  1090. pressDeleteCount = this.pressDeleteCount,
  1091. presentTags = this.presentTags;
  1092. var lastIndex = presentTags.length - 1;
  1093. var lastTag = presentTags[lastIndex];
  1094. this.pressDeleteCount = inputValue ? 0 : pressDeleteCount + 1;
  1095. if (!lastTag) return;
  1096. if (this.pressDeleteCount) {
  1097. if (lastTag.hitState) {
  1098. this.deleteTag(lastIndex);
  1099. } else {
  1100. lastTag.hitState = true;
  1101. }
  1102. }
  1103. },
  1104. handleSuggestionClick: function handleSuggestionClick(index) {
  1105. var multiple = this.multiple;
  1106. var targetNode = this.suggestions[index];
  1107. if (multiple) {
  1108. var checked = targetNode.checked;
  1109. targetNode.doCheck(!checked);
  1110. this.panel.calculateMultiCheckedValue();
  1111. } else {
  1112. this.checkedValue = targetNode.getValueByOption();
  1113. this.toggleDropDownVisible(false);
  1114. }
  1115. },
  1116. deleteTag: function deleteTag(index) {
  1117. var checkedValue = this.checkedValue;
  1118. var val = checkedValue[index];
  1119. this.checkedValue = checkedValue.filter(function (n, i) {
  1120. return i !== index;
  1121. });
  1122. this.$emit('remove-tag', val);
  1123. },
  1124. updateStyle: function updateStyle() {
  1125. var $el = this.$el,
  1126. inputInitialHeight = this.inputInitialHeight;
  1127. if (this.$isServer || !$el) return;
  1128. var suggestionPanel = this.$refs.suggestionPanel;
  1129. var inputInner = $el.querySelector('.el-input__inner');
  1130. if (!inputInner) return;
  1131. var tags = $el.querySelector('.el-cascader__tags');
  1132. var suggestionPanelEl = null;
  1133. if (suggestionPanel && (suggestionPanelEl = suggestionPanel.$el)) {
  1134. var suggestionList = suggestionPanelEl.querySelector('.el-cascader__suggestion-list');
  1135. suggestionList.style.minWidth = inputInner.offsetWidth + 'px';
  1136. }
  1137. if (tags) {
  1138. var offsetHeight = tags.offsetHeight;
  1139. var height = Math.max(offsetHeight + 6, inputInitialHeight) + 'px';
  1140. inputInner.style.height = height;
  1141. this.updatePopper();
  1142. }
  1143. },
  1144. /**
  1145. * public methods
  1146. */
  1147. getCheckedNodes: function getCheckedNodes(leafOnly) {
  1148. return this.panel.getCheckedNodes(leafOnly);
  1149. }
  1150. }
  1151. });
  1152. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue?vue&type=script&lang=js&
  1153. /* harmony default export */ var src_cascadervue_type_script_lang_js_ = (cascadervue_type_script_lang_js_);
  1154. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1155. var componentNormalizer = __webpack_require__(0);
  1156. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue
  1157. /* normalize component */
  1158. var component = Object(componentNormalizer["a" /* default */])(
  1159. src_cascadervue_type_script_lang_js_,
  1160. render,
  1161. staticRenderFns,
  1162. false,
  1163. null,
  1164. null,
  1165. null
  1166. )
  1167. /* hot reload */
  1168. if (false) { var api; }
  1169. component.options.__file = "packages/cascader/src/cascader.vue"
  1170. /* harmony default export */ var cascader = (component.exports);
  1171. // CONCATENATED MODULE: ./packages/cascader/index.js
  1172. /* istanbul ignore next */
  1173. cascader.install = function (Vue) {
  1174. Vue.component(cascader.name, cascader);
  1175. };
  1176. /* harmony default export */ var packages_cascader = __webpack_exports__["default"] = (cascader);
  1177. /***/ }),
  1178. /***/ 12:
  1179. /***/ (function(module, exports) {
  1180. module.exports = require("element-ui/lib/utils/clickoutside");
  1181. /***/ }),
  1182. /***/ 13:
  1183. /***/ (function(module, exports) {
  1184. module.exports = require("element-ui/lib/scrollbar");
  1185. /***/ }),
  1186. /***/ 15:
  1187. /***/ (function(module, exports) {
  1188. module.exports = require("element-ui/lib/utils/resize-event");
  1189. /***/ }),
  1190. /***/ 16:
  1191. /***/ (function(module, exports) {
  1192. module.exports = require("throttle-debounce/debounce");
  1193. /***/ }),
  1194. /***/ 19:
  1195. /***/ (function(module, exports) {
  1196. module.exports = require("element-ui/lib/utils/types");
  1197. /***/ }),
  1198. /***/ 20:
  1199. /***/ (function(module, exports) {
  1200. module.exports = require("element-ui/lib/locale");
  1201. /***/ }),
  1202. /***/ 21:
  1203. /***/ (function(module, exports) {
  1204. module.exports = require("element-ui/lib/utils/shared");
  1205. /***/ }),
  1206. /***/ 3:
  1207. /***/ (function(module, exports) {
  1208. module.exports = require("element-ui/lib/utils/util");
  1209. /***/ }),
  1210. /***/ 36:
  1211. /***/ (function(module, exports) {
  1212. module.exports = require("element-ui/lib/tag");
  1213. /***/ }),
  1214. /***/ 39:
  1215. /***/ (function(module, exports) {
  1216. module.exports = require("element-ui/lib/utils/aria-utils");
  1217. /***/ }),
  1218. /***/ 4:
  1219. /***/ (function(module, exports) {
  1220. module.exports = require("element-ui/lib/mixins/emitter");
  1221. /***/ }),
  1222. /***/ 5:
  1223. /***/ (function(module, exports) {
  1224. module.exports = require("element-ui/lib/utils/vue-popper");
  1225. /***/ }),
  1226. /***/ 50:
  1227. /***/ (function(module, exports) {
  1228. module.exports = require("element-ui/lib/cascader-panel");
  1229. /***/ }),
  1230. /***/ 6:
  1231. /***/ (function(module, exports) {
  1232. module.exports = require("element-ui/lib/mixins/locale");
  1233. /***/ })
  1234. /******/ });