1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429 |
- module.exports =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/dist/";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 59);
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ 0:
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
- /* globals __VUE_SSR_CONTEXT__ */
- // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
- // This module is a runtime utility for cleaner component module output and will
- // be included in the final webpack user bundle.
- function normalizeComponent (
- scriptExports,
- render,
- staticRenderFns,
- functionalTemplate,
- injectStyles,
- scopeId,
- moduleIdentifier, /* server only */
- shadowMode /* vue-cli only */
- ) {
- // Vue.extend constructor export interop
- var options = typeof scriptExports === 'function'
- ? scriptExports.options
- : scriptExports
- // render functions
- if (render) {
- options.render = render
- options.staticRenderFns = staticRenderFns
- options._compiled = true
- }
- // functional template
- if (functionalTemplate) {
- options.functional = true
- }
- // scopedId
- if (scopeId) {
- options._scopeId = 'data-v-' + scopeId
- }
- var hook
- if (moduleIdentifier) { // server build
- hook = function (context) {
- // 2.3 injection
- context =
- context || // cached call
- (this.$vnode && this.$vnode.ssrContext) || // stateful
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
- // 2.2 with runInNewContext: true
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
- context = __VUE_SSR_CONTEXT__
- }
- // inject component styles
- if (injectStyles) {
- injectStyles.call(this, context)
- }
- // register component module identifier for async chunk inferrence
- if (context && context._registeredComponents) {
- context._registeredComponents.add(moduleIdentifier)
- }
- }
- // used by ssr in case component is cached and beforeCreate
- // never gets called
- options._ssrRegister = hook
- } else if (injectStyles) {
- hook = shadowMode
- ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
- : injectStyles
- }
- if (hook) {
- if (options.functional) {
- // for template-only hot-reload because in that case the render fn doesn't
- // go through the normalizer
- options._injectStyles = hook
- // register for functioal component in vue file
- var originalRender = options.render
- options.render = function renderWithStyleInjection (h, context) {
- hook.call(context)
- return originalRender(h, context)
- }
- } else {
- // inject component registration as beforeCreate hook
- var existing = options.beforeCreate
- options.beforeCreate = existing
- ? [].concat(existing, hook)
- : [hook]
- }
- }
- return {
- exports: scriptExports,
- options: options
- }
- }
- /***/ }),
- /***/ 11:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/utils/clickoutside");
- /***/ }),
- /***/ 13:
- /***/ (function(module, exports) {
- module.exports = require("throttle-debounce/debounce");
- /***/ }),
- /***/ 18:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/locale");
- /***/ }),
- /***/ 27:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/utils/scroll-into-view");
- /***/ }),
- /***/ 3:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/mixins/emitter");
- /***/ }),
- /***/ 32:
- /***/ (function(module, exports) {
- module.exports = require("babel-helper-vue-jsx-merge-props");
- /***/ }),
- /***/ 35:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/utils/shared");
- /***/ }),
- /***/ 4:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/utils/util");
- /***/ }),
- /***/ 5:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/utils/vue-popper");
- /***/ }),
- /***/ 59:
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader/src/main.vue?vue&type=template&id=2e869fa1&
- var mainvue_type_template_id_2e869fa1_render = function() {
- var _vm = this
- var _h = _vm.$createElement
- var _c = _vm._self._c || _h
- return _c(
- "span",
- {
- directives: [
- {
- name: "clickoutside",
- rawName: "v-clickoutside",
- value: _vm.handleClickoutside,
- expression: "handleClickoutside"
- }
- ],
- ref: "reference",
- staticClass: "el-cascader",
- class: [
- {
- "is-opened": _vm.menuVisible,
- "is-disabled": _vm.cascaderDisabled
- },
- _vm.cascaderSize ? "el-cascader--" + _vm.cascaderSize : ""
- ],
- on: {
- click: _vm.handleClick,
- mouseenter: function($event) {
- _vm.inputHover = true
- },
- focus: function($event) {
- _vm.inputHover = true
- },
- mouseleave: function($event) {
- _vm.inputHover = false
- },
- blur: function($event) {
- _vm.inputHover = false
- },
- keydown: _vm.handleKeydown
- }
- },
- [
- _c(
- "el-input",
- {
- ref: "input",
- class: { "is-focus": _vm.menuVisible },
- attrs: {
- readonly: _vm.readonly,
- placeholder: _vm.currentLabels.length ? undefined : _vm.placeholder,
- "validate-event": false,
- size: _vm.size,
- disabled: _vm.cascaderDisabled
- },
- on: {
- input: _vm.debouncedInputChange,
- focus: _vm.handleFocus,
- blur: _vm.handleBlur
- },
- nativeOn: {
- compositionstart: function($event) {
- return _vm.handleComposition($event)
- },
- compositionend: function($event) {
- return _vm.handleComposition($event)
- }
- },
- model: {
- value: _vm.inputValue,
- callback: function($$v) {
- _vm.inputValue = $$v
- },
- expression: "inputValue"
- }
- },
- [
- _c("template", { slot: "suffix" }, [
- _vm.clearable && _vm.inputHover && _vm.currentLabels.length
- ? _c("i", {
- key: "1",
- staticClass:
- "el-input__icon el-icon-circle-close el-cascader__clearIcon",
- on: { click: _vm.clearValue }
- })
- : _c("i", {
- key: "2",
- staticClass: "el-input__icon el-icon-arrow-down",
- class: { "is-reverse": _vm.menuVisible }
- })
- ])
- ],
- 2
- ),
- _c(
- "span",
- {
- directives: [
- {
- name: "show",
- rawName: "v-show",
- value: _vm.inputValue === "" && !_vm.isOnComposition,
- expression: "inputValue === '' && !isOnComposition"
- }
- ],
- staticClass: "el-cascader__label"
- },
- [
- _vm.showAllLevels
- ? [
- _vm._l(_vm.currentLabels, function(label, index) {
- return [
- _vm._v("\n " + _vm._s(label) + "\n "),
- index < _vm.currentLabels.length - 1
- ? _c("span", { key: index }, [
- _vm._v(" " + _vm._s(_vm.separator) + " ")
- ])
- : _vm._e()
- ]
- })
- ]
- : [
- _vm._v(
- "\n " +
- _vm._s(_vm.currentLabels[_vm.currentLabels.length - 1]) +
- "\n "
- )
- ]
- ],
- 2
- )
- ],
- 1
- )
- }
- var staticRenderFns = []
- mainvue_type_template_id_2e869fa1_render._withStripped = true
- // CONCATENATED MODULE: ./packages/cascader/src/main.vue?vue&type=template&id=2e869fa1&
- // EXTERNAL MODULE: external "vue"
- var external_vue_ = __webpack_require__(6);
- var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
- // EXTERNAL MODULE: external "babel-helper-vue-jsx-merge-props"
- var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(32);
- var external_babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(external_babel_helper_vue_jsx_merge_props_);
- // EXTERNAL MODULE: external "element-ui/lib/utils/shared"
- var shared_ = __webpack_require__(35);
- // EXTERNAL MODULE: external "element-ui/lib/utils/scroll-into-view"
- var scroll_into_view_ = __webpack_require__(27);
- var scroll_into_view_default = /*#__PURE__*/__webpack_require__.n(scroll_into_view_);
- // EXTERNAL MODULE: external "element-ui/lib/utils/util"
- var util_ = __webpack_require__(4);
- // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader/src/menu.vue?vue&type=script&lang=js&
- var copyArray = function copyArray(arr, props) {
- if (!arr || !Array.isArray(arr) || !props) return arr;
- var result = [];
- var configurableProps = ['__IS__FLAT__OPTIONS', 'label', 'value', 'disabled'];
- var childrenProp = props.children || 'children';
- arr.forEach(function (item) {
- var itemCopy = {};
- configurableProps.forEach(function (prop) {
- var name = props[prop];
- var value = item[name];
- if (value === undefined) {
- name = prop;
- value = item[name];
- }
- if (value !== undefined) itemCopy[name] = value;
- });
- if (Array.isArray(item[childrenProp])) {
- itemCopy[childrenProp] = copyArray(item[childrenProp], props);
- }
- result.push(itemCopy);
- });
- return result;
- };
- /* harmony default export */ var menuvue_type_script_lang_js_ = ({
- name: 'ElCascaderMenu',
- data: function data() {
- return {
- inputWidth: 0,
- options: [],
- props: {},
- visible: false,
- activeValue: [],
- value: [],
- expandTrigger: 'click',
- changeOnSelect: false,
- popperClass: '',
- hoverTimer: 0,
- clicking: false,
- id: Object(util_["generateId"])()
- };
- },
- watch: {
- visible: function visible(value) {
- if (value) {
- this.activeValue = this.value;
- }
- },
- value: {
- immediate: true,
- handler: function handler(value) {
- this.activeValue = value;
- }
- }
- },
- computed: {
- activeOptions: {
- get: function get() {
- var _this = this;
- var activeValue = this.activeValue;
- var configurableProps = ['label', 'value', 'children', 'disabled'];
- var formatOptions = function formatOptions(options) {
- options.forEach(function (option) {
- if (option.__IS__FLAT__OPTIONS) return;
- configurableProps.forEach(function (prop) {
- var value = option[_this.props[prop] || prop];
- if (value !== undefined) option[prop] = value;
- });
- if (Array.isArray(option.children)) {
- formatOptions(option.children);
- }
- });
- };
- var loadActiveOptions = function loadActiveOptions(options) {
- var activeOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- var level = activeOptions.length;
- activeOptions[level] = options;
- var active = activeValue[level];
- if (Object(shared_["isDef"])(active)) {
- options = options.filter(function (option) {
- return option.value === active;
- })[0];
- if (options && options.children) {
- loadActiveOptions(options.children, activeOptions);
- }
- }
- return activeOptions;
- };
- var optionsCopy = copyArray(this.options, this.props);
- formatOptions(optionsCopy);
- return loadActiveOptions(optionsCopy);
- }
- }
- },
- methods: {
- select: function select(item, menuIndex) {
- if (item.__IS__FLAT__OPTIONS) {
- this.activeValue = item.value;
- } else if (menuIndex) {
- this.activeValue.splice(menuIndex, this.activeValue.length - 1, item.value);
- } else {
- this.activeValue = [item.value];
- }
- this.$emit('pick', this.activeValue.slice());
- },
- handleMenuLeave: function handleMenuLeave() {
- this.$emit('menuLeave');
- },
- activeItem: function activeItem(item, menuIndex) {
- var len = this.activeOptions.length;
- this.activeValue.splice(menuIndex, len, item.value);
- this.activeOptions.splice(menuIndex + 1, len, item.children);
- if (this.changeOnSelect) {
- this.$emit('pick', this.activeValue.slice(), false);
- } else {
- this.$emit('activeItemChange', this.activeValue);
- }
- },
- scrollMenu: function scrollMenu(menu) {
- scroll_into_view_default()(menu, menu.getElementsByClassName('is-active')[0]);
- },
- handleMenuEnter: function handleMenuEnter() {
- var _this2 = this;
- this.$nextTick(function () {
- return _this2.$refs.menus.forEach(function (menu) {
- return _this2.scrollMenu(menu);
- });
- });
- }
- },
- render: function render(h) {
- var _this3 = this;
- var activeValue = this.activeValue,
- activeOptions = this.activeOptions,
- visible = this.visible,
- expandTrigger = this.expandTrigger,
- popperClass = this.popperClass,
- hoverThreshold = this.hoverThreshold;
- var itemId = null;
- var itemIndex = 0;
- var hoverMenuRefs = {};
- var hoverMenuHandler = function hoverMenuHandler(e) {
- var activeMenu = hoverMenuRefs.activeMenu;
- if (!activeMenu) return;
- var offsetX = e.offsetX;
- var width = activeMenu.offsetWidth;
- var height = activeMenu.offsetHeight;
- if (e.target === hoverMenuRefs.activeItem) {
- clearTimeout(_this3.hoverTimer);
- var _hoverMenuRefs = hoverMenuRefs,
- activeItem = _hoverMenuRefs.activeItem;
- var offsetY_top = activeItem.offsetTop;
- var offsetY_Bottom = offsetY_top + activeItem.offsetHeight;
- hoverMenuRefs.hoverZone.innerHTML = '\n <path style="pointer-events: auto;" fill="transparent" d="M' + offsetX + ' ' + offsetY_top + ' L' + width + ' 0 V' + offsetY_top + ' Z" />\n <path style="pointer-events: auto;" fill="transparent" d="M' + offsetX + ' ' + offsetY_Bottom + ' L' + width + ' ' + height + ' V' + offsetY_Bottom + ' Z" />\n ';
- } else {
- if (!_this3.hoverTimer) {
- _this3.hoverTimer = setTimeout(function () {
- hoverMenuRefs.hoverZone.innerHTML = '';
- }, hoverThreshold);
- }
- }
- };
- var menus = this._l(activeOptions, function (menu, menuIndex) {
- var isFlat = false;
- var menuId = 'menu-' + _this3.id + '-' + menuIndex;
- var ownsId = 'menu-' + _this3.id + '-' + (menuIndex + 1);
- var items = _this3._l(menu, function (item) {
- var events = {
- on: {}
- };
- if (item.__IS__FLAT__OPTIONS) isFlat = true;
- if (!item.disabled) {
- // keydown up/down/left/right/enter
- events.on.keydown = function (ev) {
- var keyCode = ev.keyCode;
- if ([37, 38, 39, 40, 13, 9, 27].indexOf(keyCode) < 0) {
- return;
- }
- var currentEle = ev.target;
- var parentEle = _this3.$refs.menus[menuIndex];
- var menuItemList = parentEle.querySelectorAll("[tabindex='-1']");
- var currentIndex = Array.prototype.indexOf.call(menuItemList, currentEle); // 当前索引
- var nextIndex = void 0,
- nextMenu = void 0;
- if ([38, 40].indexOf(keyCode) > -1) {
- if (keyCode === 38) {
- // up键
- nextIndex = currentIndex !== 0 ? currentIndex - 1 : currentIndex;
- } else if (keyCode === 40) {
- // down
- nextIndex = currentIndex !== menuItemList.length - 1 ? currentIndex + 1 : currentIndex;
- }
- menuItemList[nextIndex].focus();
- } else if (keyCode === 37) {
- // left键
- if (menuIndex !== 0) {
- var previousMenu = _this3.$refs.menus[menuIndex - 1];
- previousMenu.querySelector('[aria-expanded=true]').focus();
- }
- } else if (keyCode === 39) {
- // right
- if (item.children) {
- // 有子menu 选择子menu的第一个menuitem
- nextMenu = _this3.$refs.menus[menuIndex + 1];
- nextMenu.querySelectorAll("[tabindex='-1']")[0].focus();
- }
- } else if (keyCode === 13) {
- if (!item.children) {
- var id = currentEle.getAttribute('id');
- parentEle.setAttribute('aria-activedescendant', id);
- _this3.select(item, menuIndex);
- _this3.$nextTick(function () {
- return _this3.scrollMenu(_this3.$refs.menus[menuIndex]);
- });
- }
- } else if (keyCode === 9 || keyCode === 27) {
- // esc tab
- _this3.$emit('closeInside');
- }
- };
- if (item.children) {
- var triggerEvent = {
- click: 'click',
- hover: 'mouseenter'
- }[expandTrigger];
- var triggerHandler = function triggerHandler() {
- if (_this3.visible) {
- _this3.activeItem(item, menuIndex);
- _this3.$nextTick(function () {
- // adjust self and next level
- _this3.scrollMenu(_this3.$refs.menus[menuIndex]);
- _this3.scrollMenu(_this3.$refs.menus[menuIndex + 1]);
- });
- }
- };
- events.on[triggerEvent] = triggerHandler;
- if (triggerEvent === 'mouseenter' && _this3.changeOnSelect) {
- events.on.click = function () {
- if (_this3.activeValue.indexOf(item.value) !== -1) {
- _this3.$emit('closeInside', true);
- }
- };
- }
- events.on['mousedown'] = function () {
- _this3.clicking = true;
- };
- events.on['focus'] = function () {
- // focus 选中
- if (_this3.clicking) {
- _this3.clicking = false;
- return;
- }
- triggerHandler();
- };
- } else {
- events.on.click = function () {
- _this3.select(item, menuIndex);
- _this3.$nextTick(function () {
- return _this3.scrollMenu(_this3.$refs.menus[menuIndex]);
- });
- };
- }
- }
- if (!item.disabled && !item.children) {
- // no children set id
- itemId = menuId + '-' + itemIndex;
- itemIndex++;
- }
- return h(
- 'li',
- external_babel_helper_vue_jsx_merge_props_default()([{
- 'class': {
- 'el-cascader-menu__item': true,
- 'el-cascader-menu__item--extensible': item.children,
- 'is-active': item.value === activeValue[menuIndex],
- 'is-disabled': item.disabled
- },
- ref: item.value === activeValue[menuIndex] ? 'activeItem' : null
- }, events, {
- attrs: {
- tabindex: item.disabled ? null : -1,
- role: 'menuitem',
- 'aria-haspopup': !!item.children,
- 'aria-expanded': item.value === activeValue[menuIndex],
- id: itemId,
- 'aria-owns': !item.children ? null : ownsId
- }
- }]),
- [h('span', [item.label])]
- );
- });
- var menuStyle = {};
- if (isFlat) {
- menuStyle.minWidth = _this3.inputWidth + 'px';
- }
- var isHoveredMenu = expandTrigger === 'hover' && activeValue.length - 1 === menuIndex;
- var hoverMenuEvent = {
- on: {}
- };
- if (isHoveredMenu) {
- hoverMenuEvent.on.mousemove = hoverMenuHandler;
- menuStyle.position = 'relative';
- }
- return h(
- 'ul',
- external_babel_helper_vue_jsx_merge_props_default()([{
- 'class': {
- 'el-cascader-menu': true,
- 'el-cascader-menu--flexible': isFlat
- }
- }, hoverMenuEvent, {
- style: menuStyle,
- refInFor: true,
- ref: 'menus',
- attrs: { role: 'menu',
- id: menuId
- }
- }]),
- [items, isHoveredMenu ? h('svg', {
- ref: 'hoverZone',
- style: {
- position: 'absolute',
- top: 0,
- height: '100%',
- width: '100%',
- left: 0,
- pointerEvents: 'none'
- }
- }) : null]
- );
- });
- if (expandTrigger === 'hover') {
- this.$nextTick(function () {
- var activeItem = _this3.$refs.activeItem;
- if (activeItem) {
- var activeMenu = activeItem.parentElement;
- var hoverZone = _this3.$refs.hoverZone;
- hoverMenuRefs = {
- activeMenu: activeMenu,
- activeItem: activeItem,
- hoverZone: hoverZone
- };
- } else {
- hoverMenuRefs = {};
- }
- });
- }
- return h(
- 'transition',
- {
- attrs: { name: 'el-zoom-in-top' },
- on: {
- 'before-enter': this.handleMenuEnter,
- 'after-leave': this.handleMenuLeave
- }
- },
- [h(
- 'div',
- {
- directives: [{
- name: 'show',
- value: visible
- }],
- 'class': ['el-cascader-menus el-popper', popperClass],
- ref: 'wrapper'
- },
- [h('div', {
- attrs: { 'x-arrow': true },
- 'class': 'popper__arrow' }), menus]
- )]
- );
- }
- });
- // CONCATENATED MODULE: ./packages/cascader/src/menu.vue?vue&type=script&lang=js&
- /* harmony default export */ var src_menuvue_type_script_lang_js_ = (menuvue_type_script_lang_js_);
- // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
- var componentNormalizer = __webpack_require__(0);
- // CONCATENATED MODULE: ./packages/cascader/src/menu.vue
- var menu_render, menu_staticRenderFns
- /* normalize component */
- var component = Object(componentNormalizer["a" /* default */])(
- src_menuvue_type_script_lang_js_,
- menu_render,
- menu_staticRenderFns,
- false,
- null,
- null,
- null
-
- )
- /* hot reload */
- if (false) { var api; }
- component.options.__file = "packages/cascader/src/menu.vue"
- /* harmony default export */ var src_menu = (component.exports);
- // EXTERNAL MODULE: external "element-ui/lib/input"
- var input_ = __webpack_require__(9);
- var input_default = /*#__PURE__*/__webpack_require__.n(input_);
- // EXTERNAL MODULE: external "element-ui/lib/utils/vue-popper"
- var vue_popper_ = __webpack_require__(5);
- var vue_popper_default = /*#__PURE__*/__webpack_require__.n(vue_popper_);
- // EXTERNAL MODULE: external "element-ui/lib/utils/clickoutside"
- var clickoutside_ = __webpack_require__(11);
- var clickoutside_default = /*#__PURE__*/__webpack_require__.n(clickoutside_);
- // EXTERNAL MODULE: external "element-ui/lib/mixins/emitter"
- var emitter_ = __webpack_require__(3);
- var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
- // EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
- var locale_ = __webpack_require__(7);
- var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
- // EXTERNAL MODULE: external "element-ui/lib/locale"
- var lib_locale_ = __webpack_require__(18);
- // EXTERNAL MODULE: external "throttle-debounce/debounce"
- var debounce_ = __webpack_require__(13);
- var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_);
- // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/cascader/src/main.vue?vue&type=script&lang=js&
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- var popperMixin = {
- props: {
- placement: {
- type: String,
- default: 'bottom-start'
- },
- appendToBody: vue_popper_default.a.props.appendToBody,
- arrowOffset: vue_popper_default.a.props.arrowOffset,
- offset: vue_popper_default.a.props.offset,
- boundariesPadding: vue_popper_default.a.props.boundariesPadding,
- popperOptions: vue_popper_default.a.props.popperOptions
- },
- methods: vue_popper_default.a.methods,
- data: vue_popper_default.a.data,
- beforeDestroy: vue_popper_default.a.beforeDestroy
- };
- /* harmony default export */ var mainvue_type_script_lang_js_ = ({
- name: 'ElCascader',
- directives: { Clickoutside: clickoutside_default.a },
- mixins: [popperMixin, emitter_default.a, locale_default.a],
- inject: {
- elForm: {
- default: ''
- },
- elFormItem: {
- default: ''
- }
- },
- components: {
- ElInput: input_default.a
- },
- props: {
- options: {
- type: Array,
- required: true
- },
- props: {
- type: Object,
- default: function _default() {
- return {
- children: 'children',
- label: 'label',
- value: 'value',
- disabled: 'disabled'
- };
- }
- },
- value: {
- type: Array,
- default: function _default() {
- return [];
- }
- },
- separator: {
- type: String,
- default: '/'
- },
- placeholder: {
- type: String,
- default: function _default() {
- return Object(lib_locale_["t"])('el.cascader.placeholder');
- }
- },
- disabled: Boolean,
- clearable: {
- type: Boolean,
- default: false
- },
- changeOnSelect: Boolean,
- popperClass: String,
- expandTrigger: {
- type: String,
- default: 'click'
- },
- filterable: Boolean,
- size: String,
- showAllLevels: {
- type: Boolean,
- default: true
- },
- debounce: {
- type: Number,
- default: 300
- },
- beforeFilter: {
- type: Function,
- default: function _default() {
- return function () {};
- }
- },
- hoverThreshold: {
- type: Number,
- default: 500
- }
- },
- data: function data() {
- return {
- currentValue: this.value || [],
- menu: null,
- debouncedInputChange: function debouncedInputChange() {},
- menuVisible: false,
- inputHover: false,
- inputValue: '',
- flatOptions: null,
- id: Object(util_["generateId"])(),
- needFocus: true,
- isOnComposition: false
- };
- },
- computed: {
- labelKey: function labelKey() {
- return this.props.label || 'label';
- },
- valueKey: function valueKey() {
- return this.props.value || 'value';
- },
- childrenKey: function childrenKey() {
- return this.props.children || 'children';
- },
- disabledKey: function disabledKey() {
- return this.props.disabled || 'disabled';
- },
- currentLabels: function currentLabels() {
- var _this = this;
- var options = this.options;
- var labels = [];
- this.currentValue.forEach(function (value) {
- var targetOption = options && options.filter(function (option) {
- return option[_this.valueKey] === value;
- })[0];
- if (targetOption) {
- labels.push(targetOption[_this.labelKey]);
- options = targetOption[_this.childrenKey];
- }
- });
- return labels;
- },
- _elFormItemSize: function _elFormItemSize() {
- return (this.elFormItem || {}).elFormItemSize;
- },
- cascaderSize: function cascaderSize() {
- return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
- },
- cascaderDisabled: function cascaderDisabled() {
- return this.disabled || (this.elForm || {}).disabled;
- },
- readonly: function readonly() {
- return !this.filterable || !Object(util_["isIE"])() && !Object(util_["isEdge"])() && !this.menuVisible;
- }
- },
- watch: {
- menuVisible: function menuVisible(value) {
- this.$refs.input.$refs.input.setAttribute('aria-expanded', value);
- value ? this.showMenu() : this.hideMenu();
- this.$emit('visible-change', value);
- },
- value: function value(_value) {
- this.currentValue = _value;
- },
- currentValue: function currentValue(value) {
- this.dispatch('ElFormItem', 'el.form.change', [value]);
- },
- options: {
- deep: true,
- handler: function handler(value) {
- if (!this.menu) {
- this.initMenu();
- }
- this.flatOptions = this.flattenOptions(this.options);
- this.menu.options = value;
- }
- }
- },
- methods: {
- initMenu: function initMenu() {
- this.menu = new external_vue_default.a(src_menu).$mount();
- this.menu.options = this.options;
- this.menu.props = this.props;
- this.menu.expandTrigger = this.expandTrigger;
- this.menu.changeOnSelect = this.changeOnSelect;
- this.menu.popperClass = this.popperClass;
- this.menu.hoverThreshold = this.hoverThreshold;
- this.popperElm = this.menu.$el;
- this.menu.$refs.menus[0].setAttribute('id', 'cascader-menu-' + this.id);
- this.menu.$on('pick', this.handlePick);
- this.menu.$on('activeItemChange', this.handleActiveItemChange);
- this.menu.$on('menuLeave', this.doDestroy);
- this.menu.$on('closeInside', this.handleClickoutside);
- },
- showMenu: function showMenu() {
- var _this2 = this;
- if (!this.menu) {
- this.initMenu();
- }
- this.menu.value = this.currentValue.slice(0);
- this.menu.visible = true;
- this.menu.options = this.options;
- this.$nextTick(function (_) {
- _this2.updatePopper();
- _this2.menu.inputWidth = _this2.$refs.input.$el.offsetWidth - 2;
- });
- },
- hideMenu: function hideMenu() {
- this.inputValue = '';
- this.menu.visible = false;
- if (this.needFocus) {
- this.$refs.input.focus();
- } else {
- this.needFocus = true;
- }
- },
- handleActiveItemChange: function handleActiveItemChange(value) {
- var _this3 = this;
- this.$nextTick(function (_) {
- _this3.updatePopper();
- });
- this.$emit('active-item-change', value);
- },
- handleKeydown: function handleKeydown(e) {
- var _this4 = this;
- var keyCode = e.keyCode;
- if (keyCode === 13) {
- this.handleClick();
- } else if (keyCode === 40) {
- // down
- this.menuVisible = true; // 打开
- setTimeout(function () {
- var firstMenu = _this4.popperElm.querySelectorAll('.el-cascader-menu')[0];
- firstMenu.querySelectorAll("[tabindex='-1']")[0].focus();
- });
- e.stopPropagation();
- e.preventDefault();
- } else if (keyCode === 27 || keyCode === 9) {
- // esc tab
- this.inputValue = '';
- if (this.menu) this.menu.visible = false;
- }
- },
- handlePick: function handlePick(value) {
- var close = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- this.currentValue = value;
- this.$emit('input', value);
- this.$emit('change', value);
- if (close) {
- this.menuVisible = false;
- } else {
- this.$nextTick(this.updatePopper);
- }
- },
- handleInputChange: function handleInputChange(value) {
- var _this5 = this;
- if (!this.menuVisible) return;
- var flatOptions = this.flatOptions;
- if (!value) {
- this.menu.options = this.options;
- this.$nextTick(this.updatePopper);
- return;
- }
- var filteredFlatOptions = flatOptions.filter(function (optionsStack) {
- return optionsStack.some(function (option) {
- return new RegExp(Object(util_["escapeRegexpString"])(value), 'i').test(option[_this5.labelKey]);
- });
- });
- if (filteredFlatOptions.length > 0) {
- filteredFlatOptions = filteredFlatOptions.map(function (optionStack) {
- return {
- __IS__FLAT__OPTIONS: true,
- value: optionStack.map(function (item) {
- return item[_this5.valueKey];
- }),
- label: _this5.renderFilteredOptionLabel(value, optionStack),
- disabled: optionStack.some(function (item) {
- return item[_this5.disabledKey];
- })
- };
- });
- } else {
- filteredFlatOptions = [{
- __IS__FLAT__OPTIONS: true,
- label: this.t('el.cascader.noMatch'),
- value: '',
- disabled: true
- }];
- }
- this.menu.options = filteredFlatOptions;
- this.$nextTick(this.updatePopper);
- },
- renderFilteredOptionLabel: function renderFilteredOptionLabel(inputValue, optionsStack) {
- var _this6 = this;
- return optionsStack.map(function (option, index) {
- var label = option[_this6.labelKey];
- var keywordIndex = label.toLowerCase().indexOf(inputValue.toLowerCase());
- var labelPart = label.slice(keywordIndex, inputValue.length + keywordIndex);
- var node = keywordIndex > -1 ? _this6.highlightKeyword(label, labelPart) : label;
- return index === 0 ? node : [' ' + _this6.separator + ' ', node];
- });
- },
- highlightKeyword: function highlightKeyword(label, keyword) {
- var _this7 = this;
- var h = this._c;
- return label.split(keyword).map(function (node, index) {
- return index === 0 ? node : [h('span', { class: { 'el-cascader-menu__item__keyword': true } }, [_this7._v(keyword)]), node];
- });
- },
- flattenOptions: function flattenOptions(options) {
- var _this8 = this;
- var ancestor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- var flatOptions = [];
- options.forEach(function (option) {
- var optionsStack = ancestor.concat(option);
- if (!option[_this8.childrenKey]) {
- flatOptions.push(optionsStack);
- } else {
- if (_this8.changeOnSelect) {
- flatOptions.push(optionsStack);
- }
- flatOptions = flatOptions.concat(_this8.flattenOptions(option[_this8.childrenKey], optionsStack));
- }
- });
- return flatOptions;
- },
- clearValue: function clearValue(ev) {
- ev.stopPropagation();
- this.handlePick([], true);
- },
- handleClickoutside: function handleClickoutside() {
- var pickFinished = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- if (this.menuVisible && !pickFinished) {
- this.needFocus = false;
- }
- this.menuVisible = false;
- },
- handleClick: function handleClick() {
- if (this.cascaderDisabled) return;
- this.$refs.input.focus();
- if (this.filterable) {
- this.menuVisible = true;
- return;
- }
- this.menuVisible = !this.menuVisible;
- },
- handleFocus: function handleFocus(event) {
- this.$emit('focus', event);
- },
- handleBlur: function handleBlur(event) {
- this.$emit('blur', event);
- },
- handleComposition: function handleComposition(event) {
- this.isOnComposition = event.type !== 'compositionend';
- }
- },
- created: function created() {
- var _this9 = this;
- this.debouncedInputChange = debounce_default()(this.debounce, function (value) {
- var before = _this9.beforeFilter(value);
- if (before && before.then) {
- _this9.menu.options = [{
- __IS__FLAT__OPTIONS: true,
- label: _this9.t('el.cascader.loading'),
- value: '',
- disabled: true
- }];
- before.then(function () {
- _this9.$nextTick(function () {
- _this9.handleInputChange(value);
- });
- });
- } else if (before !== false) {
- _this9.$nextTick(function () {
- _this9.handleInputChange(value);
- });
- }
- });
- },
- mounted: function mounted() {
- this.flatOptions = this.flattenOptions(this.options);
- }
- });
- // CONCATENATED MODULE: ./packages/cascader/src/main.vue?vue&type=script&lang=js&
- /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
- // CONCATENATED MODULE: ./packages/cascader/src/main.vue
- /* normalize component */
- var main_component = Object(componentNormalizer["a" /* default */])(
- src_mainvue_type_script_lang_js_,
- mainvue_type_template_id_2e869fa1_render,
- staticRenderFns,
- false,
- null,
- null,
- null
-
- )
- /* hot reload */
- if (false) { var main_api; }
- main_component.options.__file = "packages/cascader/src/main.vue"
- /* harmony default export */ var main = (main_component.exports);
- // CONCATENATED MODULE: ./packages/cascader/index.js
- /* istanbul ignore next */
- main.install = function (Vue) {
- Vue.component(main.name, main);
- };
- /* harmony default export */ var cascader = __webpack_exports__["default"] = (main);
- /***/ }),
- /***/ 6:
- /***/ (function(module, exports) {
- module.exports = require("vue");
- /***/ }),
- /***/ 7:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/mixins/locale");
- /***/ }),
- /***/ 9:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/input");
- /***/ })
- /******/ });
|