cascader.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  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. this.doDestroy();
  914. },
  915. handleKeyDown: function handleKeyDown(event) {
  916. switch (event.keyCode) {
  917. case KeyCode.enter:
  918. this.toggleDropDownVisible();
  919. break;
  920. case KeyCode.down:
  921. this.toggleDropDownVisible(true);
  922. this.focusFirstNode();
  923. event.preventDefault();
  924. break;
  925. case KeyCode.esc:
  926. case KeyCode.tab:
  927. this.toggleDropDownVisible(false);
  928. break;
  929. }
  930. },
  931. handleFocus: function handleFocus(e) {
  932. this.$emit('focus', e);
  933. },
  934. handleBlur: function handleBlur(e) {
  935. this.$emit('blur', e);
  936. },
  937. handleInput: function handleInput(val, event) {
  938. !this.dropDownVisible && this.toggleDropDownVisible(true);
  939. if (event && event.isComposing) return;
  940. if (val) {
  941. this.filterHandler();
  942. } else {
  943. this.filtering = false;
  944. }
  945. },
  946. handleClear: function handleClear() {
  947. this.presentText = '';
  948. this.panel.clearCheckedNodes();
  949. },
  950. handleExpandChange: function handleExpandChange(value) {
  951. this.$nextTick(this.updatePopper.bind(this));
  952. this.$emit('expand-change', value);
  953. this.$emit('active-item-change', value); // Deprecated
  954. },
  955. focusFirstNode: function focusFirstNode() {
  956. var _this3 = this;
  957. this.$nextTick(function () {
  958. var filtering = _this3.filtering;
  959. var _$refs = _this3.$refs,
  960. popper = _$refs.popper,
  961. suggestionPanel = _$refs.suggestionPanel;
  962. var firstNode = null;
  963. if (filtering && suggestionPanel) {
  964. firstNode = suggestionPanel.$el.querySelector('.el-cascader__suggestion-item');
  965. } else {
  966. var firstMenu = popper.querySelector('.el-cascader-menu');
  967. firstNode = firstMenu.querySelector('.el-cascader-node[tabindex="-1"]');
  968. }
  969. if (firstNode) {
  970. firstNode.focus();
  971. !filtering && firstNode.click();
  972. }
  973. });
  974. },
  975. computePresentContent: function computePresentContent() {
  976. var _this4 = this;
  977. // nextTick is required, because checked nodes may not change right now
  978. this.$nextTick(function () {
  979. if (_this4.config.multiple) {
  980. _this4.computePresentTags();
  981. _this4.presentText = _this4.presentTags.length ? ' ' : null;
  982. } else {
  983. _this4.computePresentText();
  984. }
  985. });
  986. },
  987. isEmptyValue: function isEmptyValue(val) {
  988. var multiple = this.multiple;
  989. var emitPath = this.panel.config.emitPath;
  990. if (multiple || emitPath) {
  991. return Object(util_["isEmpty"])(val);
  992. }
  993. return false;
  994. },
  995. computePresentText: function computePresentText() {
  996. var checkedValue = this.checkedValue,
  997. config = this.config;
  998. if (!this.isEmptyValue(checkedValue)) {
  999. var node = this.panel.getNodeByValue(checkedValue);
  1000. if (node && (config.checkStrictly || node.isLeaf)) {
  1001. this.presentText = node.getText(this.showAllLevels, this.separator);
  1002. return;
  1003. }
  1004. }
  1005. this.presentText = null;
  1006. },
  1007. computePresentTags: function computePresentTags() {
  1008. var isDisabled = this.isDisabled,
  1009. leafOnly = this.leafOnly,
  1010. showAllLevels = this.showAllLevels,
  1011. separator = this.separator,
  1012. collapseTags = this.collapseTags;
  1013. var checkedNodes = this.getCheckedNodes(leafOnly);
  1014. var tags = [];
  1015. var genTag = function genTag(node) {
  1016. return {
  1017. node: node,
  1018. key: node.uid,
  1019. text: node.getText(showAllLevels, separator),
  1020. hitState: false,
  1021. closable: !isDisabled && !node.isDisabled
  1022. };
  1023. };
  1024. if (checkedNodes.length) {
  1025. var first = checkedNodes[0],
  1026. rest = checkedNodes.slice(1);
  1027. var restCount = rest.length;
  1028. tags.push(genTag(first));
  1029. if (restCount) {
  1030. if (collapseTags) {
  1031. tags.push({
  1032. key: -1,
  1033. text: '+ ' + restCount,
  1034. closable: false
  1035. });
  1036. } else {
  1037. rest.forEach(function (node) {
  1038. return tags.push(genTag(node));
  1039. });
  1040. }
  1041. }
  1042. }
  1043. this.checkedNodes = checkedNodes;
  1044. this.presentTags = tags;
  1045. },
  1046. getSuggestions: function getSuggestions() {
  1047. var _this5 = this;
  1048. var filterMethod = this.filterMethod;
  1049. if (!Object(types_["isFunction"])(filterMethod)) {
  1050. filterMethod = function filterMethod(node, keyword) {
  1051. return node.text.includes(keyword);
  1052. };
  1053. }
  1054. var suggestions = this.panel.getFlattedNodes(this.leafOnly).filter(function (node) {
  1055. if (node.isDisabled) return false;
  1056. node.text = node.getText(_this5.showAllLevels, _this5.separator) || '';
  1057. return filterMethod(node, _this5.inputValue);
  1058. });
  1059. if (this.multiple) {
  1060. this.presentTags.forEach(function (tag) {
  1061. tag.hitState = false;
  1062. });
  1063. } else {
  1064. suggestions.forEach(function (node) {
  1065. node.checked = Object(util_["isEqual"])(_this5.checkedValue, node.getValueByOption());
  1066. });
  1067. }
  1068. this.filtering = true;
  1069. this.suggestions = suggestions;
  1070. this.$nextTick(this.updatePopper);
  1071. },
  1072. handleSuggestionKeyDown: function handleSuggestionKeyDown(event) {
  1073. var keyCode = event.keyCode,
  1074. target = event.target;
  1075. switch (keyCode) {
  1076. case KeyCode.enter:
  1077. target.click();
  1078. break;
  1079. case KeyCode.up:
  1080. var prev = target.previousElementSibling;
  1081. prev && prev.focus();
  1082. break;
  1083. case KeyCode.down:
  1084. var next = target.nextElementSibling;
  1085. next && next.focus();
  1086. break;
  1087. case KeyCode.esc:
  1088. case KeyCode.tab:
  1089. this.toggleDropDownVisible(false);
  1090. break;
  1091. }
  1092. },
  1093. handleDelete: function handleDelete() {
  1094. var inputValue = this.inputValue,
  1095. pressDeleteCount = this.pressDeleteCount,
  1096. presentTags = this.presentTags;
  1097. var lastIndex = presentTags.length - 1;
  1098. var lastTag = presentTags[lastIndex];
  1099. this.pressDeleteCount = inputValue ? 0 : pressDeleteCount + 1;
  1100. if (!lastTag) return;
  1101. if (this.pressDeleteCount) {
  1102. if (lastTag.hitState) {
  1103. this.deleteTag(lastTag);
  1104. } else {
  1105. lastTag.hitState = true;
  1106. }
  1107. }
  1108. },
  1109. handleSuggestionClick: function handleSuggestionClick(index) {
  1110. var multiple = this.multiple;
  1111. var targetNode = this.suggestions[index];
  1112. if (multiple) {
  1113. var checked = targetNode.checked;
  1114. targetNode.doCheck(!checked);
  1115. this.panel.calculateMultiCheckedValue();
  1116. } else {
  1117. this.checkedValue = targetNode.getValueByOption();
  1118. this.toggleDropDownVisible(false);
  1119. }
  1120. },
  1121. deleteTag: function deleteTag(tag) {
  1122. var checkedValue = this.checkedValue;
  1123. var current = tag.node.getValueByOption();
  1124. var val = checkedValue.find(function (n) {
  1125. return Object(util_["isEqual"])(n, current);
  1126. });
  1127. this.checkedValue = checkedValue.filter(function (n) {
  1128. return !Object(util_["isEqual"])(n, current);
  1129. });
  1130. this.$emit('remove-tag', val);
  1131. },
  1132. updateStyle: function updateStyle() {
  1133. var $el = this.$el,
  1134. inputInitialHeight = this.inputInitialHeight;
  1135. if (this.$isServer || !$el) return;
  1136. var suggestionPanel = this.$refs.suggestionPanel;
  1137. var inputInner = $el.querySelector('.el-input__inner');
  1138. if (!inputInner) return;
  1139. var tags = $el.querySelector('.el-cascader__tags');
  1140. var suggestionPanelEl = null;
  1141. if (suggestionPanel && (suggestionPanelEl = suggestionPanel.$el)) {
  1142. var suggestionList = suggestionPanelEl.querySelector('.el-cascader__suggestion-list');
  1143. suggestionList.style.minWidth = inputInner.offsetWidth + 'px';
  1144. }
  1145. if (tags) {
  1146. var offsetHeight = Math.round(tags.getBoundingClientRect().height);
  1147. var height = Math.max(offsetHeight + 6, inputInitialHeight) + 'px';
  1148. inputInner.style.height = height;
  1149. if (this.dropDownVisible) {
  1150. this.updatePopper();
  1151. }
  1152. }
  1153. },
  1154. /**
  1155. * public methods
  1156. */
  1157. getCheckedNodes: function getCheckedNodes(leafOnly) {
  1158. return this.panel.getCheckedNodes(leafOnly);
  1159. }
  1160. }
  1161. });
  1162. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue?vue&type=script&lang=js&
  1163. /* harmony default export */ var src_cascadervue_type_script_lang_js_ = (cascadervue_type_script_lang_js_);
  1164. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1165. var componentNormalizer = __webpack_require__(0);
  1166. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue
  1167. /* normalize component */
  1168. var component = Object(componentNormalizer["a" /* default */])(
  1169. src_cascadervue_type_script_lang_js_,
  1170. render,
  1171. staticRenderFns,
  1172. false,
  1173. null,
  1174. null,
  1175. null
  1176. )
  1177. /* hot reload */
  1178. if (false) { var api; }
  1179. component.options.__file = "packages/cascader/src/cascader.vue"
  1180. /* harmony default export */ var cascader = (component.exports);
  1181. // CONCATENATED MODULE: ./packages/cascader/index.js
  1182. /* istanbul ignore next */
  1183. cascader.install = function (Vue) {
  1184. Vue.component(cascader.name, cascader);
  1185. };
  1186. /* harmony default export */ var packages_cascader = __webpack_exports__["default"] = (cascader);
  1187. /***/ }),
  1188. /***/ 11:
  1189. /***/ (function(module, exports) {
  1190. module.exports = require("element-ui/lib/mixins/migrating");
  1191. /***/ }),
  1192. /***/ 12:
  1193. /***/ (function(module, exports) {
  1194. module.exports = require("element-ui/lib/utils/clickoutside");
  1195. /***/ }),
  1196. /***/ 15:
  1197. /***/ (function(module, exports) {
  1198. module.exports = require("element-ui/lib/scrollbar");
  1199. /***/ }),
  1200. /***/ 16:
  1201. /***/ (function(module, exports) {
  1202. module.exports = require("element-ui/lib/utils/resize-event");
  1203. /***/ }),
  1204. /***/ 17:
  1205. /***/ (function(module, exports) {
  1206. module.exports = require("element-ui/lib/utils/types");
  1207. /***/ }),
  1208. /***/ 18:
  1209. /***/ (function(module, exports) {
  1210. module.exports = require("throttle-debounce/debounce");
  1211. /***/ }),
  1212. /***/ 20:
  1213. /***/ (function(module, exports) {
  1214. module.exports = require("element-ui/lib/locale");
  1215. /***/ }),
  1216. /***/ 21:
  1217. /***/ (function(module, exports) {
  1218. module.exports = require("element-ui/lib/utils/shared");
  1219. /***/ }),
  1220. /***/ 3:
  1221. /***/ (function(module, exports) {
  1222. module.exports = require("element-ui/lib/utils/util");
  1223. /***/ }),
  1224. /***/ 37:
  1225. /***/ (function(module, exports) {
  1226. module.exports = require("element-ui/lib/tag");
  1227. /***/ }),
  1228. /***/ 4:
  1229. /***/ (function(module, exports) {
  1230. module.exports = require("element-ui/lib/mixins/emitter");
  1231. /***/ }),
  1232. /***/ 40:
  1233. /***/ (function(module, exports) {
  1234. module.exports = require("element-ui/lib/utils/aria-utils");
  1235. /***/ }),
  1236. /***/ 5:
  1237. /***/ (function(module, exports) {
  1238. module.exports = require("element-ui/lib/utils/vue-popper");
  1239. /***/ }),
  1240. /***/ 50:
  1241. /***/ (function(module, exports) {
  1242. module.exports = require("element-ui/lib/cascader-panel");
  1243. /***/ }),
  1244. /***/ 6:
  1245. /***/ (function(module, exports) {
  1246. module.exports = require("element-ui/lib/mixins/locale");
  1247. /***/ })
  1248. /******/ });