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 = 114);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 0:
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  93. /* globals __VUE_SSR_CONTEXT__ */
  94. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  95. // This module is a runtime utility for cleaner component module output and will
  96. // be included in the final webpack user bundle.
  97. function normalizeComponent (
  98. scriptExports,
  99. render,
  100. staticRenderFns,
  101. functionalTemplate,
  102. injectStyles,
  103. scopeId,
  104. moduleIdentifier, /* server only */
  105. shadowMode /* vue-cli only */
  106. ) {
  107. // Vue.extend constructor export interop
  108. var options = typeof scriptExports === 'function'
  109. ? scriptExports.options
  110. : scriptExports
  111. // render functions
  112. if (render) {
  113. options.render = render
  114. options.staticRenderFns = staticRenderFns
  115. options._compiled = true
  116. }
  117. // functional template
  118. if (functionalTemplate) {
  119. options.functional = true
  120. }
  121. // scopedId
  122. if (scopeId) {
  123. options._scopeId = 'data-v-' + scopeId
  124. }
  125. var hook
  126. if (moduleIdentifier) { // server build
  127. hook = function (context) {
  128. // 2.3 injection
  129. context =
  130. context || // cached call
  131. (this.$vnode && this.$vnode.ssrContext) || // stateful
  132. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  133. // 2.2 with runInNewContext: true
  134. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  135. context = __VUE_SSR_CONTEXT__
  136. }
  137. // inject component styles
  138. if (injectStyles) {
  139. injectStyles.call(this, context)
  140. }
  141. // register component module identifier for async chunk inferrence
  142. if (context && context._registeredComponents) {
  143. context._registeredComponents.add(moduleIdentifier)
  144. }
  145. }
  146. // used by ssr in case component is cached and beforeCreate
  147. // never gets called
  148. options._ssrRegister = hook
  149. } else if (injectStyles) {
  150. hook = shadowMode
  151. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  152. : injectStyles
  153. }
  154. if (hook) {
  155. if (options.functional) {
  156. // for template-only hot-reload because in that case the render fn doesn't
  157. // go through the normalizer
  158. options._injectStyles = hook
  159. // register for functioal component in vue file
  160. var originalRender = options.render
  161. options.render = function renderWithStyleInjection (h, context) {
  162. hook.call(context)
  163. return originalRender(h, context)
  164. }
  165. } else {
  166. // inject component registration as beforeCreate hook
  167. var existing = options.beforeCreate
  168. options.beforeCreate = existing
  169. ? [].concat(existing, hook)
  170. : [hook]
  171. }
  172. }
  173. return {
  174. exports: scriptExports,
  175. options: options
  176. }
  177. }
  178. /***/ }),
  179. /***/ 10:
  180. /***/ (function(module, exports) {
  181. module.exports = require("element-ui/lib/input");
  182. /***/ }),
  183. /***/ 11:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/mixins/migrating");
  186. /***/ }),
  187. /***/ 114:
  188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  189. "use strict";
  190. __webpack_require__.r(__webpack_exports__);
  191. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader/src/cascader.vue?vue&type=template&id=032537a6&
  192. var render = function() {
  193. var _vm = this
  194. var _h = _vm.$createElement
  195. var _c = _vm._self._c || _h
  196. return _c(
  197. "div",
  198. {
  199. directives: [
  200. {
  201. name: "clickoutside",
  202. rawName: "v-clickoutside",
  203. value: function() {
  204. return _vm.toggleDropDownVisible(false)
  205. },
  206. expression: "() => toggleDropDownVisible(false)"
  207. }
  208. ],
  209. ref: "reference",
  210. class: [
  211. "el-cascader",
  212. _vm.realSize && "el-cascader--" + _vm.realSize,
  213. { "is-disabled": _vm.isDisabled }
  214. ],
  215. on: {
  216. mouseenter: function($event) {
  217. _vm.inputHover = true
  218. },
  219. mouseleave: function($event) {
  220. _vm.inputHover = false
  221. },
  222. click: function() {
  223. return _vm.toggleDropDownVisible(_vm.readonly ? undefined : true)
  224. },
  225. keydown: _vm.handleKeyDown
  226. }
  227. },
  228. [
  229. _c(
  230. "el-input",
  231. {
  232. ref: "input",
  233. class: { "is-focus": _vm.dropDownVisible },
  234. attrs: {
  235. size: _vm.realSize,
  236. placeholder: _vm.placeholder,
  237. readonly: _vm.readonly,
  238. disabled: _vm.isDisabled,
  239. "validate-event": false
  240. },
  241. on: {
  242. focus: _vm.handleFocus,
  243. blur: _vm.handleBlur,
  244. input: _vm.handleInput
  245. },
  246. model: {
  247. value: _vm.multiple ? _vm.presentText : _vm.inputValue,
  248. callback: function($$v) {
  249. _vm.multiple ? _vm.presentText : (_vm.inputValue = $$v)
  250. },
  251. expression: "multiple ? presentText : inputValue"
  252. }
  253. },
  254. [
  255. _c("template", { slot: "suffix" }, [
  256. _vm.clearBtnVisible
  257. ? _c("i", {
  258. key: "clear",
  259. staticClass: "el-input__icon el-icon-circle-close",
  260. on: {
  261. click: function($event) {
  262. $event.stopPropagation()
  263. return _vm.handleClear($event)
  264. }
  265. }
  266. })
  267. : _c("i", {
  268. key: "arrow-down",
  269. class: [
  270. "el-input__icon",
  271. "el-icon-arrow-down",
  272. _vm.dropDownVisible && "is-reverse"
  273. ],
  274. on: {
  275. click: function($event) {
  276. $event.stopPropagation()
  277. _vm.toggleDropDownVisible()
  278. }
  279. }
  280. })
  281. ])
  282. ],
  283. 2
  284. ),
  285. _vm.multiple
  286. ? _c(
  287. "div",
  288. { staticClass: "el-cascader__tags" },
  289. [
  290. _vm._l(_vm.presentTags, function(tag) {
  291. return _c(
  292. "el-tag",
  293. {
  294. key: tag.key,
  295. attrs: {
  296. type: "info",
  297. size: _vm.tagSize,
  298. hit: tag.hitState,
  299. closable: tag.closable,
  300. "disable-transitions": ""
  301. },
  302. on: {
  303. close: function($event) {
  304. _vm.deleteTag(tag)
  305. }
  306. }
  307. },
  308. [_c("span", [_vm._v(_vm._s(tag.text))])]
  309. )
  310. }),
  311. _vm.filterable && !_vm.isDisabled
  312. ? _c("input", {
  313. directives: [
  314. {
  315. name: "model",
  316. rawName: "v-model.trim",
  317. value: _vm.inputValue,
  318. expression: "inputValue",
  319. modifiers: { trim: true }
  320. }
  321. ],
  322. staticClass: "el-cascader__search-input",
  323. attrs: {
  324. type: "text",
  325. placeholder: _vm.presentTags.length ? "" : _vm.placeholder
  326. },
  327. domProps: { value: _vm.inputValue },
  328. on: {
  329. input: [
  330. function($event) {
  331. if ($event.target.composing) {
  332. return
  333. }
  334. _vm.inputValue = $event.target.value.trim()
  335. },
  336. function(e) {
  337. return _vm.handleInput(_vm.inputValue, e)
  338. }
  339. ],
  340. click: function($event) {
  341. $event.stopPropagation()
  342. _vm.toggleDropDownVisible(true)
  343. },
  344. keydown: function($event) {
  345. if (
  346. !("button" in $event) &&
  347. _vm._k(
  348. $event.keyCode,
  349. "delete",
  350. [8, 46],
  351. $event.key,
  352. ["Backspace", "Delete", "Del"]
  353. )
  354. ) {
  355. return null
  356. }
  357. return _vm.handleDelete($event)
  358. },
  359. blur: function($event) {
  360. _vm.$forceUpdate()
  361. }
  362. }
  363. })
  364. : _vm._e()
  365. ],
  366. 2
  367. )
  368. : _vm._e(),
  369. _c(
  370. "transition",
  371. {
  372. attrs: { name: "el-zoom-in-top" },
  373. on: { "after-leave": _vm.handleDropdownLeave }
  374. },
  375. [
  376. _c(
  377. "div",
  378. {
  379. directives: [
  380. {
  381. name: "show",
  382. rawName: "v-show",
  383. value: _vm.dropDownVisible,
  384. expression: "dropDownVisible"
  385. }
  386. ],
  387. ref: "popper",
  388. class: ["el-popper", "el-cascader__dropdown", _vm.popperClass]
  389. },
  390. [
  391. _c("el-cascader-panel", {
  392. directives: [
  393. {
  394. name: "show",
  395. rawName: "v-show",
  396. value: !_vm.filtering,
  397. expression: "!filtering"
  398. }
  399. ],
  400. ref: "panel",
  401. attrs: {
  402. options: _vm.options,
  403. props: _vm.config,
  404. border: false,
  405. "render-label": _vm.$scopedSlots.default
  406. },
  407. on: {
  408. "expand-change": _vm.handleExpandChange,
  409. close: function($event) {
  410. _vm.toggleDropDownVisible(false)
  411. }
  412. },
  413. model: {
  414. value: _vm.checkedValue,
  415. callback: function($$v) {
  416. _vm.checkedValue = $$v
  417. },
  418. expression: "checkedValue"
  419. }
  420. }),
  421. _vm.filterable
  422. ? _c(
  423. "el-scrollbar",
  424. {
  425. directives: [
  426. {
  427. name: "show",
  428. rawName: "v-show",
  429. value: _vm.filtering,
  430. expression: "filtering"
  431. }
  432. ],
  433. ref: "suggestionPanel",
  434. staticClass: "el-cascader__suggestion-panel",
  435. attrs: {
  436. tag: "ul",
  437. "view-class": "el-cascader__suggestion-list"
  438. },
  439. nativeOn: {
  440. keydown: function($event) {
  441. return _vm.handleSuggestionKeyDown($event)
  442. }
  443. }
  444. },
  445. [
  446. _vm.suggestions.length
  447. ? _vm._l(_vm.suggestions, function(item, index) {
  448. return _c(
  449. "li",
  450. {
  451. key: item.uid,
  452. class: [
  453. "el-cascader__suggestion-item",
  454. item.checked && "is-checked"
  455. ],
  456. attrs: { tabindex: -1 },
  457. on: {
  458. click: function($event) {
  459. _vm.handleSuggestionClick(index)
  460. }
  461. }
  462. },
  463. [
  464. _c("span", [_vm._v(_vm._s(item.text))]),
  465. item.checked
  466. ? _c("i", { staticClass: "el-icon-check" })
  467. : _vm._e()
  468. ]
  469. )
  470. })
  471. : _vm._t("empty", [
  472. _c(
  473. "li",
  474. { staticClass: "el-cascader__empty-text" },
  475. [_vm._v(_vm._s(_vm.t("el.cascader.noMatch")))]
  476. )
  477. ])
  478. ],
  479. 2
  480. )
  481. : _vm._e()
  482. ],
  483. 1
  484. )
  485. ]
  486. )
  487. ],
  488. 1
  489. )
  490. }
  491. var staticRenderFns = []
  492. render._withStripped = true
  493. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue?vue&type=template&id=032537a6&
  494. // EXTERNAL MODULE: external "element-ui/lib/utils/vue-popper"
  495. var vue_popper_ = __webpack_require__(5);
  496. var vue_popper_default = /*#__PURE__*/__webpack_require__.n(vue_popper_);
  497. // EXTERNAL MODULE: external "element-ui/lib/utils/clickoutside"
  498. var clickoutside_ = __webpack_require__(12);
  499. var clickoutside_default = /*#__PURE__*/__webpack_require__.n(clickoutside_);
  500. // EXTERNAL MODULE: external "element-ui/lib/mixins/emitter"
  501. var emitter_ = __webpack_require__(4);
  502. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  503. // EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
  504. var locale_ = __webpack_require__(6);
  505. var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
  506. // EXTERNAL MODULE: external "element-ui/lib/mixins/migrating"
  507. var migrating_ = __webpack_require__(11);
  508. var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
  509. // EXTERNAL MODULE: external "element-ui/lib/input"
  510. var input_ = __webpack_require__(10);
  511. var input_default = /*#__PURE__*/__webpack_require__.n(input_);
  512. // EXTERNAL MODULE: external "element-ui/lib/tag"
  513. var tag_ = __webpack_require__(37);
  514. var tag_default = /*#__PURE__*/__webpack_require__.n(tag_);
  515. // EXTERNAL MODULE: external "element-ui/lib/scrollbar"
  516. var scrollbar_ = __webpack_require__(15);
  517. var scrollbar_default = /*#__PURE__*/__webpack_require__.n(scrollbar_);
  518. // EXTERNAL MODULE: external "element-ui/lib/cascader-panel"
  519. var cascader_panel_ = __webpack_require__(50);
  520. var cascader_panel_default = /*#__PURE__*/__webpack_require__.n(cascader_panel_);
  521. // EXTERNAL MODULE: external "element-ui/lib/utils/aria-utils"
  522. var aria_utils_ = __webpack_require__(40);
  523. var aria_utils_default = /*#__PURE__*/__webpack_require__.n(aria_utils_);
  524. // EXTERNAL MODULE: external "element-ui/lib/locale"
  525. var lib_locale_ = __webpack_require__(20);
  526. // EXTERNAL MODULE: external "element-ui/lib/utils/util"
  527. var util_ = __webpack_require__(3);
  528. // EXTERNAL MODULE: external "element-ui/lib/utils/types"
  529. var types_ = __webpack_require__(17);
  530. // EXTERNAL MODULE: external "element-ui/lib/utils/shared"
  531. var shared_ = __webpack_require__(21);
  532. // EXTERNAL MODULE: external "element-ui/lib/utils/resize-event"
  533. var resize_event_ = __webpack_require__(16);
  534. // EXTERNAL MODULE: external "throttle-debounce/debounce"
  535. var debounce_ = __webpack_require__(18);
  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,
  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 (!this.isEmptyValue(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. this.doDestroy();
  918. },
  919. handleKeyDown: function handleKeyDown(event) {
  920. switch (event.keyCode) {
  921. case KeyCode.enter:
  922. this.toggleDropDownVisible();
  923. break;
  924. case KeyCode.down:
  925. this.toggleDropDownVisible(true);
  926. this.focusFirstNode();
  927. event.preventDefault();
  928. break;
  929. case KeyCode.esc:
  930. case KeyCode.tab:
  931. this.toggleDropDownVisible(false);
  932. break;
  933. }
  934. },
  935. handleFocus: function handleFocus(e) {
  936. this.$emit('focus', e);
  937. },
  938. handleBlur: function handleBlur(e) {
  939. this.$emit('blur', e);
  940. },
  941. handleInput: function handleInput(val, event) {
  942. !this.dropDownVisible && this.toggleDropDownVisible(true);
  943. if (event && event.isComposing) return;
  944. if (val) {
  945. this.filterHandler();
  946. } else {
  947. this.filtering = false;
  948. }
  949. },
  950. handleClear: function handleClear() {
  951. this.presentText = '';
  952. this.panel.clearCheckedNodes();
  953. },
  954. handleExpandChange: function handleExpandChange(value) {
  955. this.$nextTick(this.updatePopper.bind(this));
  956. this.$emit('expand-change', value);
  957. this.$emit('active-item-change', value); // Deprecated
  958. },
  959. focusFirstNode: function focusFirstNode() {
  960. var _this3 = this;
  961. this.$nextTick(function () {
  962. var filtering = _this3.filtering;
  963. var _$refs = _this3.$refs,
  964. popper = _$refs.popper,
  965. suggestionPanel = _$refs.suggestionPanel;
  966. var firstNode = null;
  967. if (filtering && suggestionPanel) {
  968. firstNode = suggestionPanel.$el.querySelector('.el-cascader__suggestion-item');
  969. } else {
  970. var firstMenu = popper.querySelector('.el-cascader-menu');
  971. firstNode = firstMenu.querySelector('.el-cascader-node[tabindex="-1"]');
  972. }
  973. if (firstNode) {
  974. firstNode.focus();
  975. !filtering && firstNode.click();
  976. }
  977. });
  978. },
  979. computePresentContent: function computePresentContent() {
  980. var _this4 = this;
  981. // nextTick is required, because checked nodes may not change right now
  982. this.$nextTick(function () {
  983. if (_this4.config.multiple) {
  984. _this4.computePresentTags();
  985. _this4.presentText = _this4.presentTags.length ? ' ' : null;
  986. } else {
  987. _this4.computePresentText();
  988. }
  989. });
  990. },
  991. isEmptyValue: function isEmptyValue(val) {
  992. var multiple = this.multiple;
  993. var emitPath = this.panel.config.emitPath;
  994. if (multiple || emitPath) {
  995. return Object(util_["isEmpty"])(val);
  996. }
  997. return false;
  998. },
  999. computePresentText: function computePresentText() {
  1000. var checkedValue = this.checkedValue,
  1001. config = this.config;
  1002. if (!this.isEmptyValue(checkedValue)) {
  1003. var node = this.panel.getNodeByValue(checkedValue);
  1004. if (node && (config.checkStrictly || node.isLeaf)) {
  1005. this.presentText = node.getText(this.showAllLevels, this.separator);
  1006. return;
  1007. }
  1008. }
  1009. this.presentText = null;
  1010. },
  1011. computePresentTags: function computePresentTags() {
  1012. var isDisabled = this.isDisabled,
  1013. leafOnly = this.leafOnly,
  1014. showAllLevels = this.showAllLevels,
  1015. separator = this.separator,
  1016. collapseTags = this.collapseTags;
  1017. var checkedNodes = this.getCheckedNodes(leafOnly);
  1018. var tags = [];
  1019. var genTag = function genTag(node) {
  1020. return {
  1021. node: node,
  1022. key: node.uid,
  1023. text: node.getText(showAllLevels, separator),
  1024. hitState: false,
  1025. closable: !isDisabled && !node.isDisabled
  1026. };
  1027. };
  1028. if (checkedNodes.length) {
  1029. var first = checkedNodes[0],
  1030. rest = checkedNodes.slice(1);
  1031. var restCount = rest.length;
  1032. tags.push(genTag(first));
  1033. if (restCount) {
  1034. if (collapseTags) {
  1035. tags.push({
  1036. key: -1,
  1037. text: '+ ' + restCount,
  1038. closable: false
  1039. });
  1040. } else {
  1041. rest.forEach(function (node) {
  1042. return tags.push(genTag(node));
  1043. });
  1044. }
  1045. }
  1046. }
  1047. this.checkedNodes = checkedNodes;
  1048. this.presentTags = tags;
  1049. },
  1050. getSuggestions: function getSuggestions() {
  1051. var _this5 = this;
  1052. var filterMethod = this.filterMethod;
  1053. if (!Object(types_["isFunction"])(filterMethod)) {
  1054. filterMethod = function filterMethod(node, keyword) {
  1055. return node.text.includes(keyword);
  1056. };
  1057. }
  1058. var suggestions = this.panel.getFlattedNodes(this.leafOnly).filter(function (node) {
  1059. if (node.isDisabled) return false;
  1060. node.text = node.getText(_this5.showAllLevels, _this5.separator) || '';
  1061. return filterMethod(node, _this5.inputValue);
  1062. });
  1063. if (this.multiple) {
  1064. this.presentTags.forEach(function (tag) {
  1065. tag.hitState = false;
  1066. });
  1067. } else {
  1068. suggestions.forEach(function (node) {
  1069. node.checked = Object(util_["isEqual"])(_this5.checkedValue, node.getValueByOption());
  1070. });
  1071. }
  1072. this.filtering = true;
  1073. this.suggestions = suggestions;
  1074. this.$nextTick(this.updatePopper);
  1075. },
  1076. handleSuggestionKeyDown: function handleSuggestionKeyDown(event) {
  1077. var keyCode = event.keyCode,
  1078. target = event.target;
  1079. switch (keyCode) {
  1080. case KeyCode.enter:
  1081. target.click();
  1082. break;
  1083. case KeyCode.up:
  1084. var prev = target.previousElementSibling;
  1085. prev && prev.focus();
  1086. break;
  1087. case KeyCode.down:
  1088. var next = target.nextElementSibling;
  1089. next && next.focus();
  1090. break;
  1091. case KeyCode.esc:
  1092. case KeyCode.tab:
  1093. this.toggleDropDownVisible(false);
  1094. break;
  1095. }
  1096. },
  1097. handleDelete: function handleDelete() {
  1098. var inputValue = this.inputValue,
  1099. pressDeleteCount = this.pressDeleteCount,
  1100. presentTags = this.presentTags;
  1101. var lastIndex = presentTags.length - 1;
  1102. var lastTag = presentTags[lastIndex];
  1103. this.pressDeleteCount = inputValue ? 0 : pressDeleteCount + 1;
  1104. if (!lastTag) return;
  1105. if (this.pressDeleteCount) {
  1106. if (lastTag.hitState) {
  1107. this.deleteTag(lastTag);
  1108. } else {
  1109. lastTag.hitState = true;
  1110. }
  1111. }
  1112. },
  1113. handleSuggestionClick: function handleSuggestionClick(index) {
  1114. var multiple = this.multiple;
  1115. var targetNode = this.suggestions[index];
  1116. if (multiple) {
  1117. var checked = targetNode.checked;
  1118. targetNode.doCheck(!checked);
  1119. this.panel.calculateMultiCheckedValue();
  1120. } else {
  1121. this.checkedValue = targetNode.getValueByOption();
  1122. this.toggleDropDownVisible(false);
  1123. }
  1124. },
  1125. deleteTag: function deleteTag(tag) {
  1126. var checkedValue = this.checkedValue;
  1127. var current = tag.node.getValueByOption();
  1128. var val = checkedValue.find(function (n) {
  1129. return Object(util_["isEqual"])(n, current);
  1130. });
  1131. this.checkedValue = checkedValue.filter(function (n) {
  1132. return !Object(util_["isEqual"])(n, current);
  1133. });
  1134. this.$emit('remove-tag', val);
  1135. },
  1136. updateStyle: function updateStyle() {
  1137. var $el = this.$el,
  1138. inputInitialHeight = this.inputInitialHeight;
  1139. if (this.$isServer || !$el) return;
  1140. var suggestionPanel = this.$refs.suggestionPanel;
  1141. var inputInner = $el.querySelector('.el-input__inner');
  1142. if (!inputInner) return;
  1143. var tags = $el.querySelector('.el-cascader__tags');
  1144. var suggestionPanelEl = null;
  1145. if (suggestionPanel && (suggestionPanelEl = suggestionPanel.$el)) {
  1146. var suggestionList = suggestionPanelEl.querySelector('.el-cascader__suggestion-list');
  1147. suggestionList.style.minWidth = inputInner.offsetWidth + 'px';
  1148. }
  1149. if (tags) {
  1150. var offsetHeight = Math.round(tags.getBoundingClientRect().height);
  1151. var height = Math.max(offsetHeight + 6, inputInitialHeight) + 'px';
  1152. inputInner.style.height = height;
  1153. if (this.dropDownVisible) {
  1154. this.updatePopper();
  1155. }
  1156. }
  1157. },
  1158. /**
  1159. * public methods
  1160. */
  1161. getCheckedNodes: function getCheckedNodes(leafOnly) {
  1162. return this.panel.getCheckedNodes(leafOnly);
  1163. }
  1164. }
  1165. });
  1166. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue?vue&type=script&lang=js&
  1167. /* harmony default export */ var src_cascadervue_type_script_lang_js_ = (cascadervue_type_script_lang_js_);
  1168. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  1169. var componentNormalizer = __webpack_require__(0);
  1170. // CONCATENATED MODULE: ./packages/cascader/src/cascader.vue
  1171. /* normalize component */
  1172. var component = Object(componentNormalizer["a" /* default */])(
  1173. src_cascadervue_type_script_lang_js_,
  1174. render,
  1175. staticRenderFns,
  1176. false,
  1177. null,
  1178. null,
  1179. null
  1180. )
  1181. /* hot reload */
  1182. if (false) { var api; }
  1183. component.options.__file = "packages/cascader/src/cascader.vue"
  1184. /* harmony default export */ var cascader = (component.exports);
  1185. // CONCATENATED MODULE: ./packages/cascader/index.js
  1186. /* istanbul ignore next */
  1187. cascader.install = function (Vue) {
  1188. Vue.component(cascader.name, cascader);
  1189. };
  1190. /* harmony default export */ var packages_cascader = __webpack_exports__["default"] = (cascader);
  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. /******/ });