cascader.js 38 KB

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