cascader.js 38 KB

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