UNPKG

39.6 kBJavaScriptView Raw
1module.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, {
41/******/ configurable: false,
42/******/ enumerable: true,
43/******/ get: getter
44/******/ });
45/******/ }
46/******/ };
47/******/
48/******/ // getDefaultExport function for compatibility with non-harmony modules
49/******/ __webpack_require__.n = function(module) {
50/******/ var getter = module && module.__esModule ?
51/******/ function getDefault() { return module['default']; } :
52/******/ function getModuleExports() { return module; };
53/******/ __webpack_require__.d(getter, 'a', getter);
54/******/ return getter;
55/******/ };
56/******/
57/******/ // Object.prototype.hasOwnProperty.call
58/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
59/******/
60/******/ // __webpack_public_path__
61/******/ __webpack_require__.p = "/dist/";
62/******/
63/******/ // Load entry module and return exports
64/******/ return __webpack_require__(__webpack_require__.s = 353);
65/******/ })
66/************************************************************************/
67/******/ ({
68
69/***/ 0:
70/***/ (function(module, exports) {
71
72/* globals __VUE_SSR_CONTEXT__ */
73
74// IMPORTANT: Do NOT use ES2015 features in this file.
75// This module is a runtime utility for cleaner component module output and will
76// be included in the final webpack user bundle.
77
78module.exports = function normalizeComponent (
79 rawScriptExports,
80 compiledTemplate,
81 functionalTemplate,
82 injectStyles,
83 scopeId,
84 moduleIdentifier /* server only */
85) {
86 var esModule
87 var scriptExports = rawScriptExports = rawScriptExports || {}
88
89 // ES6 modules interop
90 var type = typeof rawScriptExports.default
91 if (type === 'object' || type === 'function') {
92 esModule = rawScriptExports
93 scriptExports = rawScriptExports.default
94 }
95
96 // Vue.extend constructor export interop
97 var options = typeof scriptExports === 'function'
98 ? scriptExports.options
99 : scriptExports
100
101 // render functions
102 if (compiledTemplate) {
103 options.render = compiledTemplate.render
104 options.staticRenderFns = compiledTemplate.staticRenderFns
105 options._compiled = true
106 }
107
108 // functional template
109 if (functionalTemplate) {
110 options.functional = true
111 }
112
113 // scopedId
114 if (scopeId) {
115 options._scopeId = scopeId
116 }
117
118 var hook
119 if (moduleIdentifier) { // server build
120 hook = function (context) {
121 // 2.3 injection
122 context =
123 context || // cached call
124 (this.$vnode && this.$vnode.ssrContext) || // stateful
125 (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
126 // 2.2 with runInNewContext: true
127 if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
128 context = __VUE_SSR_CONTEXT__
129 }
130 // inject component styles
131 if (injectStyles) {
132 injectStyles.call(this, context)
133 }
134 // register component module identifier for async chunk inferrence
135 if (context && context._registeredComponents) {
136 context._registeredComponents.add(moduleIdentifier)
137 }
138 }
139 // used by ssr in case component is cached and beforeCreate
140 // never gets called
141 options._ssrRegister = hook
142 } else if (injectStyles) {
143 hook = injectStyles
144 }
145
146 if (hook) {
147 var functional = options.functional
148 var existing = functional
149 ? options.render
150 : options.beforeCreate
151
152 if (!functional) {
153 // inject component registration as beforeCreate hook
154 options.beforeCreate = existing
155 ? [].concat(existing, hook)
156 : [hook]
157 } else {
158 // for template-only hot-reload because in that case the render fn doesn't
159 // go through the normalizer
160 options._injectStyles = hook
161 // register for functioal component in vue file
162 options.render = function renderWithStyleInjection (h, context) {
163 hook.call(context)
164 return existing(h, context)
165 }
166 }
167 }
168
169 return {
170 esModule: esModule,
171 exports: scriptExports,
172 options: options
173 }
174}
175
176
177/***/ }),
178
179/***/ 1:
180/***/ (function(module, exports) {
181
182module.exports = require("element-ui/lib/mixins/emitter");
183
184/***/ }),
185
186/***/ 10:
187/***/ (function(module, exports) {
188
189module.exports = require("element-ui/lib/utils/clickoutside");
190
191/***/ }),
192
193/***/ 12:
194/***/ (function(module, exports) {
195
196module.exports = require("element-ui/lib/locale");
197
198/***/ }),
199
200/***/ 14:
201/***/ (function(module, exports) {
202
203module.exports = require("throttle-debounce/debounce");
204
205/***/ }),
206
207/***/ 2:
208/***/ (function(module, exports) {
209
210module.exports = require("element-ui/lib/utils/util");
211
212/***/ }),
213
214/***/ 23:
215/***/ (function(module, exports) {
216
217module.exports = require("element-ui/lib/utils/shared");
218
219/***/ }),
220
221/***/ 26:
222/***/ (function(module, exports) {
223
224module.exports = require("element-ui/lib/utils/scroll-into-view");
225
226/***/ }),
227
228/***/ 353:
229/***/ (function(module, exports, __webpack_require__) {
230
231"use strict";
232
233
234exports.__esModule = true;
235
236var _main = __webpack_require__(354);
237
238var _main2 = _interopRequireDefault(_main);
239
240function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
241
242/* istanbul ignore next */
243_main2.default.install = function (Vue) {
244 Vue.component(_main2.default.name, _main2.default);
245};
246
247exports.default = _main2.default;
248
249/***/ }),
250
251/***/ 354:
252/***/ (function(module, __webpack_exports__, __webpack_require__) {
253
254"use strict";
255Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
256/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue__ = __webpack_require__(355);
257/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue__);
258/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_02ff6464_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__ = __webpack_require__(358);
259var normalizeComponent = __webpack_require__(0)
260/* script */
261
262/* template */
263
264/* template functional */
265 var __vue_template_functional__ = false
266/* styles */
267var __vue_styles__ = null
268/* scopeId */
269var __vue_scopeId__ = null
270/* moduleIdentifier (server only) */
271var __vue_module_identifier__ = null
272var Component = normalizeComponent(
273 __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue___default.a,
274 __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_02ff6464_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__["a" /* default */],
275 __vue_template_functional__,
276 __vue_styles__,
277 __vue_scopeId__,
278 __vue_module_identifier__
279)
280
281/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
282
283
284/***/ }),
285
286/***/ 355:
287/***/ (function(module, exports, __webpack_require__) {
288
289"use strict";
290
291
292exports.__esModule = true;
293
294var _vue = __webpack_require__(4);
295
296var _vue2 = _interopRequireDefault(_vue);
297
298var _menu = __webpack_require__(356);
299
300var _menu2 = _interopRequireDefault(_menu);
301
302var _input = __webpack_require__(6);
303
304var _input2 = _interopRequireDefault(_input);
305
306var _vuePopper = __webpack_require__(7);
307
308var _vuePopper2 = _interopRequireDefault(_vuePopper);
309
310var _clickoutside = __webpack_require__(10);
311
312var _clickoutside2 = _interopRequireDefault(_clickoutside);
313
314var _emitter = __webpack_require__(1);
315
316var _emitter2 = _interopRequireDefault(_emitter);
317
318var _locale = __webpack_require__(5);
319
320var _locale2 = _interopRequireDefault(_locale);
321
322var _locale3 = __webpack_require__(12);
323
324var _debounce = __webpack_require__(14);
325
326var _debounce2 = _interopRequireDefault(_debounce);
327
328var _util = __webpack_require__(2);
329
330function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
331
332//
333//
334//
335//
336//
337//
338//
339//
340//
341//
342//
343//
344//
345//
346//
347//
348//
349//
350//
351//
352//
353//
354//
355//
356//
357//
358//
359//
360//
361//
362//
363//
364//
365//
366//
367//
368//
369//
370//
371//
372//
373//
374//
375//
376//
377//
378//
379//
380//
381//
382//
383//
384//
385//
386//
387//
388//
389//
390//
391//
392//
393//
394//
395
396var popperMixin = {
397 props: {
398 placement: {
399 type: String,
400 default: 'bottom-start'
401 },
402 appendToBody: _vuePopper2.default.props.appendToBody,
403 arrowOffset: _vuePopper2.default.props.arrowOffset,
404 offset: _vuePopper2.default.props.offset,
405 boundariesPadding: _vuePopper2.default.props.boundariesPadding,
406 popperOptions: _vuePopper2.default.props.popperOptions
407 },
408 methods: _vuePopper2.default.methods,
409 data: _vuePopper2.default.data,
410 beforeDestroy: _vuePopper2.default.beforeDestroy
411};
412
413exports.default = {
414 name: 'ElCascader',
415
416 directives: { Clickoutside: _clickoutside2.default },
417
418 mixins: [popperMixin, _emitter2.default, _locale2.default],
419
420 inject: {
421 elForm: {
422 default: ''
423 },
424 elFormItem: {
425 default: ''
426 }
427 },
428
429 components: {
430 ElInput: _input2.default
431 },
432
433 props: {
434 options: {
435 type: Array,
436 required: true
437 },
438 props: {
439 type: Object,
440 default: function _default() {
441 return {
442 children: 'children',
443 label: 'label',
444 value: 'value',
445 disabled: 'disabled'
446 };
447 }
448 },
449 value: {
450 type: Array,
451 default: function _default() {
452 return [];
453 }
454 },
455 separator: {
456 type: String,
457 default: '/'
458 },
459 placeholder: {
460 type: String,
461 default: function _default() {
462 return (0, _locale3.t)('el.cascader.placeholder');
463 }
464 },
465 disabled: Boolean,
466 clearable: {
467 type: Boolean,
468 default: false
469 },
470 changeOnSelect: Boolean,
471 popperClass: String,
472 expandTrigger: {
473 type: String,
474 default: 'click'
475 },
476 filterable: Boolean,
477 size: String,
478 showAllLevels: {
479 type: Boolean,
480 default: true
481 },
482 debounce: {
483 type: Number,
484 default: 300
485 },
486 beforeFilter: {
487 type: Function,
488 default: function _default() {
489 return function () {};
490 }
491 },
492 hoverThreshold: {
493 type: Number,
494 default: 500
495 }
496 },
497
498 data: function data() {
499 return {
500 currentValue: this.value || [],
501 menu: null,
502 debouncedInputChange: function debouncedInputChange() {},
503
504 menuVisible: false,
505 inputHover: false,
506 inputValue: '',
507 flatOptions: null,
508 id: (0, _util.generateId)(),
509 needFocus: true,
510 isOnComposition: false
511 };
512 },
513
514
515 computed: {
516 labelKey: function labelKey() {
517 return this.props.label || 'label';
518 },
519 valueKey: function valueKey() {
520 return this.props.value || 'value';
521 },
522 childrenKey: function childrenKey() {
523 return this.props.children || 'children';
524 },
525 disabledKey: function disabledKey() {
526 return this.props.disabled || 'disabled';
527 },
528 currentLabels: function currentLabels() {
529 var _this = this;
530
531 var options = this.options;
532 var labels = [];
533 this.currentValue.forEach(function (value) {
534 var targetOption = options && options.filter(function (option) {
535 return option[_this.valueKey] === value;
536 })[0];
537 if (targetOption) {
538 labels.push(targetOption[_this.labelKey]);
539 options = targetOption[_this.childrenKey];
540 }
541 });
542 return labels;
543 },
544 _elFormItemSize: function _elFormItemSize() {
545 return (this.elFormItem || {}).elFormItemSize;
546 },
547 cascaderSize: function cascaderSize() {
548 return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
549 },
550 cascaderDisabled: function cascaderDisabled() {
551 return this.disabled || (this.elForm || {}).disabled;
552 },
553 readonly: function readonly() {
554 var isIE = !this.$isServer && !isNaN(Number(document.documentMode));
555 return !this.filterable || !isIE && !this.menuVisible;
556 }
557 },
558
559 watch: {
560 menuVisible: function menuVisible(value) {
561 this.$refs.input.$refs.input.setAttribute('aria-expanded', value);
562 value ? this.showMenu() : this.hideMenu();
563 },
564 value: function value(_value) {
565 this.currentValue = _value;
566 },
567 currentValue: function currentValue(value) {
568 this.dispatch('ElFormItem', 'el.form.change', [value]);
569 },
570 currentLabels: function currentLabels(value) {
571 var inputLabel = this.showAllLevels ? value.join('/') : value[value.length - 1];
572 this.$refs.input.$refs.input.setAttribute('value', inputLabel);
573 },
574
575 options: {
576 deep: true,
577 handler: function handler(value) {
578 if (!this.menu) {
579 this.initMenu();
580 }
581 this.flatOptions = this.flattenOptions(this.options);
582 this.menu.options = value;
583 }
584 }
585 },
586
587 methods: {
588 initMenu: function initMenu() {
589 this.menu = new _vue2.default(_menu2.default).$mount();
590 this.menu.options = this.options;
591 this.menu.props = this.props;
592 this.menu.expandTrigger = this.expandTrigger;
593 this.menu.changeOnSelect = this.changeOnSelect;
594 this.menu.popperClass = this.popperClass;
595 this.menu.hoverThreshold = this.hoverThreshold;
596 this.popperElm = this.menu.$el;
597 this.menu.$refs.menus[0].setAttribute('id', 'cascader-menu-' + this.id);
598 this.menu.$on('pick', this.handlePick);
599 this.menu.$on('activeItemChange', this.handleActiveItemChange);
600 this.menu.$on('menuLeave', this.doDestroy);
601 this.menu.$on('closeInside', this.handleClickoutside);
602 },
603 showMenu: function showMenu() {
604 var _this2 = this;
605
606 if (!this.menu) {
607 this.initMenu();
608 }
609
610 this.menu.value = this.currentValue.slice(0);
611 this.menu.visible = true;
612 this.menu.options = this.options;
613 this.$nextTick(function (_) {
614 _this2.updatePopper();
615 _this2.menu.inputWidth = _this2.$refs.input.$el.offsetWidth - 2;
616 });
617 },
618 hideMenu: function hideMenu() {
619 this.inputValue = '';
620 this.menu.visible = false;
621 if (this.needFocus) {
622 this.$refs.input.focus();
623 } else {
624 this.needFocus = true;
625 }
626 },
627 handleActiveItemChange: function handleActiveItemChange(value) {
628 var _this3 = this;
629
630 this.$nextTick(function (_) {
631 _this3.updatePopper();
632 });
633 this.$emit('active-item-change', value);
634 },
635 handleKeydown: function handleKeydown(e) {
636 var _this4 = this;
637
638 var keyCode = e.keyCode;
639 if (keyCode === 13) {
640 this.handleClick();
641 } else if (keyCode === 40) {
642 // down
643 this.menuVisible = true; // 打开
644 setTimeout(function () {
645 var firstMenu = _this4.popperElm.querySelectorAll('.el-cascader-menu')[0];
646 firstMenu.querySelectorAll("[tabindex='-1']")[0].focus();
647 });
648 e.stopPropagation();
649 e.preventDefault();
650 } else if (keyCode === 27 || keyCode === 9) {
651 // esc tab
652 this.inputValue = '';
653 if (this.menu) this.menu.visible = false;
654 }
655 },
656 handlePick: function handlePick(value) {
657 var close = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
658
659 this.currentValue = value;
660 this.$emit('input', value);
661 this.$emit('change', value);
662
663 if (close) {
664 this.menuVisible = false;
665 } else {
666 this.$nextTick(this.updatePopper);
667 }
668 },
669 handleInputChange: function handleInputChange(value) {
670 var _this5 = this;
671
672 if (!this.menuVisible) return;
673 var flatOptions = this.flatOptions;
674
675 if (!value) {
676 this.menu.options = this.options;
677 this.$nextTick(this.updatePopper);
678 return;
679 }
680
681 var filteredFlatOptions = flatOptions.filter(function (optionsStack) {
682 return optionsStack.some(function (option) {
683 return new RegExp((0, _util.escapeRegexpString)(value), 'i').test(option[_this5.labelKey]);
684 });
685 });
686
687 if (filteredFlatOptions.length > 0) {
688 filteredFlatOptions = filteredFlatOptions.map(function (optionStack) {
689 return {
690 __IS__FLAT__OPTIONS: true,
691 value: optionStack.map(function (item) {
692 return item[_this5.valueKey];
693 }),
694 label: _this5.renderFilteredOptionLabel(value, optionStack),
695 disabled: optionStack.some(function (item) {
696 return item[_this5.disabledKey];
697 })
698 };
699 });
700 } else {
701 filteredFlatOptions = [{
702 __IS__FLAT__OPTIONS: true,
703 label: this.t('el.cascader.noMatch'),
704 value: '',
705 disabled: true
706 }];
707 }
708 this.menu.options = filteredFlatOptions;
709 this.$nextTick(this.updatePopper);
710 },
711 renderFilteredOptionLabel: function renderFilteredOptionLabel(inputValue, optionsStack) {
712 var _this6 = this;
713
714 return optionsStack.map(function (option, index) {
715 var label = option[_this6.labelKey];
716 var keywordIndex = label.toLowerCase().indexOf(inputValue.toLowerCase());
717 var labelPart = label.slice(keywordIndex, inputValue.length + keywordIndex);
718 var node = keywordIndex > -1 ? _this6.highlightKeyword(label, labelPart) : label;
719 return index === 0 ? node : [' / ', node];
720 });
721 },
722 highlightKeyword: function highlightKeyword(label, keyword) {
723 var _this7 = this;
724
725 var h = this._c;
726 return label.split(keyword).map(function (node, index) {
727 return index === 0 ? node : [h('span', { class: { 'el-cascader-menu__item__keyword': true } }, [_this7._v(keyword)]), node];
728 });
729 },
730 flattenOptions: function flattenOptions(options) {
731 var _this8 = this;
732
733 var ancestor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
734
735 var flatOptions = [];
736 options.forEach(function (option) {
737 var optionsStack = ancestor.concat(option);
738 if (!option[_this8.childrenKey]) {
739 flatOptions.push(optionsStack);
740 } else {
741 if (_this8.changeOnSelect) {
742 flatOptions.push(optionsStack);
743 }
744 flatOptions = flatOptions.concat(_this8.flattenOptions(option[_this8.childrenKey], optionsStack));
745 }
746 });
747 return flatOptions;
748 },
749 clearValue: function clearValue(ev) {
750 ev.stopPropagation();
751 this.handlePick([], true);
752 },
753 handleClickoutside: function handleClickoutside() {
754 var pickFinished = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
755
756 if (this.menuVisible && !pickFinished) {
757 this.needFocus = false;
758 }
759 this.menuVisible = false;
760 },
761 handleClick: function handleClick() {
762 if (this.cascaderDisabled) return;
763 this.$refs.input.focus();
764 if (this.filterable) {
765 this.menuVisible = true;
766 return;
767 }
768 this.menuVisible = !this.menuVisible;
769 },
770 handleFocus: function handleFocus(event) {
771 this.$emit('focus', event);
772 },
773 handleBlur: function handleBlur(event) {
774 this.$emit('blur', event);
775 },
776 handleComposition: function handleComposition(event) {
777 this.isOnComposition = event.type !== 'compositionend';
778 }
779 },
780
781 created: function created() {
782 var _this9 = this;
783
784 this.debouncedInputChange = (0, _debounce2.default)(this.debounce, function (value) {
785 var before = _this9.beforeFilter(value);
786
787 if (before && before.then) {
788 _this9.menu.options = [{
789 __IS__FLAT__OPTIONS: true,
790 label: _this9.t('el.cascader.loading'),
791 value: '',
792 disabled: true
793 }];
794 before.then(function () {
795 _this9.$nextTick(function () {
796 _this9.handleInputChange(value);
797 });
798 });
799 } else if (before !== false) {
800 _this9.$nextTick(function () {
801 _this9.handleInputChange(value);
802 });
803 }
804 });
805 },
806 mounted: function mounted() {
807 this.flatOptions = this.flattenOptions(this.options);
808 }
809};
810
811/***/ }),
812
813/***/ 356:
814/***/ (function(module, __webpack_exports__, __webpack_require__) {
815
816"use strict";
817Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
818/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_menu_vue__ = __webpack_require__(357);
819/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_menu_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_menu_vue__);
820var normalizeComponent = __webpack_require__(0)
821/* script */
822
823/* template */
824var __vue_template__ = null
825/* template functional */
826 var __vue_template_functional__ = false
827/* styles */
828var __vue_styles__ = null
829/* scopeId */
830var __vue_scopeId__ = null
831/* moduleIdentifier (server only) */
832var __vue_module_identifier__ = null
833var Component = normalizeComponent(
834 __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_menu_vue___default.a,
835 __vue_template__,
836 __vue_template_functional__,
837 __vue_styles__,
838 __vue_scopeId__,
839 __vue_module_identifier__
840)
841
842/* harmony default export */ __webpack_exports__["default"] = (Component.exports);
843
844
845/***/ }),
846
847/***/ 357:
848/***/ (function(module, exports, __webpack_require__) {
849
850"use strict";
851
852
853exports.__esModule = true;
854
855var _babelHelperVueJsxMergeProps = __webpack_require__(45);
856
857var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);
858
859var _shared = __webpack_require__(23);
860
861var _scrollIntoView = __webpack_require__(26);
862
863var _scrollIntoView2 = _interopRequireDefault(_scrollIntoView);
864
865var _util = __webpack_require__(2);
866
867function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
868
869var copyArray = function copyArray(arr, props) {
870 if (!arr || !Array.isArray(arr) || !props) return arr;
871 var result = [];
872 var configurableProps = ['__IS__FLAT__OPTIONS', 'label', 'value', 'disabled'];
873 var childrenProp = props.children || 'children';
874 arr.forEach(function (item) {
875 var itemCopy = {};
876 configurableProps.forEach(function (prop) {
877 var name = props[prop];
878 var value = item[name];
879 if (value === undefined) {
880 name = prop;
881 value = item[name];
882 }
883 if (value !== undefined) itemCopy[name] = value;
884 });
885 if (Array.isArray(item[childrenProp])) {
886 itemCopy[childrenProp] = copyArray(item[childrenProp], props);
887 }
888 result.push(itemCopy);
889 });
890 return result;
891};
892
893exports.default = {
894 name: 'ElCascaderMenu',
895
896 data: function data() {
897 return {
898 inputWidth: 0,
899 options: [],
900 props: {},
901 visible: false,
902 activeValue: [],
903 value: [],
904 expandTrigger: 'click',
905 changeOnSelect: false,
906 popperClass: '',
907 hoverTimer: 0,
908 clicking: false,
909 id: (0, _util.generateId)()
910 };
911 },
912
913
914 watch: {
915 visible: function visible(value) {
916 if (value) {
917 this.activeValue = this.value;
918 }
919 },
920
921 value: {
922 immediate: true,
923 handler: function handler(value) {
924 this.activeValue = value;
925 }
926 }
927 },
928
929 computed: {
930 activeOptions: {
931 cache: false,
932 get: function get() {
933 var _this = this;
934
935 var activeValue = this.activeValue;
936 var configurableProps = ['label', 'value', 'children', 'disabled'];
937
938 var formatOptions = function formatOptions(options) {
939 options.forEach(function (option) {
940 if (option.__IS__FLAT__OPTIONS) return;
941 configurableProps.forEach(function (prop) {
942 var value = option[_this.props[prop] || prop];
943 if (value !== undefined) option[prop] = value;
944 });
945 if (Array.isArray(option.children)) {
946 formatOptions(option.children);
947 }
948 });
949 };
950
951 var loadActiveOptions = function loadActiveOptions(options) {
952 var activeOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
953
954 var level = activeOptions.length;
955 activeOptions[level] = options;
956 var active = activeValue[level];
957 if ((0, _shared.isDef)(active)) {
958 options = options.filter(function (option) {
959 return option.value === active;
960 })[0];
961 if (options && options.children) {
962 loadActiveOptions(options.children, activeOptions);
963 }
964 }
965 return activeOptions;
966 };
967
968 var optionsCopy = copyArray(this.options, this.props);
969 formatOptions(optionsCopy);
970 return loadActiveOptions(optionsCopy);
971 }
972 }
973 },
974
975 methods: {
976 select: function select(item, menuIndex) {
977 if (item.__IS__FLAT__OPTIONS) {
978 this.activeValue = item.value;
979 } else if (menuIndex) {
980 this.activeValue.splice(menuIndex, this.activeValue.length - 1, item.value);
981 } else {
982 this.activeValue = [item.value];
983 }
984 this.$emit('pick', this.activeValue.slice());
985 },
986 handleMenuLeave: function handleMenuLeave() {
987 this.$emit('menuLeave');
988 },
989 activeItem: function activeItem(item, menuIndex) {
990 var len = this.activeOptions.length;
991 this.activeValue.splice(menuIndex, len, item.value);
992 this.activeOptions.splice(menuIndex + 1, len, item.children);
993 if (this.changeOnSelect) {
994 this.$emit('pick', this.activeValue.slice(), false);
995 } else {
996 this.$emit('activeItemChange', this.activeValue);
997 }
998 },
999 scrollMenu: function scrollMenu(menu) {
1000 (0, _scrollIntoView2.default)(menu, menu.getElementsByClassName('is-active')[0]);
1001 },
1002 handleMenuEnter: function handleMenuEnter() {
1003 var _this2 = this;
1004
1005 this.$nextTick(function () {
1006 return _this2.$refs.menus.forEach(function (menu) {
1007 return _this2.scrollMenu(menu);
1008 });
1009 });
1010 }
1011 },
1012
1013 render: function render(h) {
1014 var _this3 = this;
1015
1016 var activeValue = this.activeValue,
1017 activeOptions = this.activeOptions,
1018 visible = this.visible,
1019 expandTrigger = this.expandTrigger,
1020 popperClass = this.popperClass,
1021 hoverThreshold = this.hoverThreshold;
1022
1023 var itemId = null;
1024 var itemIndex = 0;
1025
1026 var hoverMenuRefs = {};
1027 var hoverMenuHandler = function hoverMenuHandler(e) {
1028 var activeMenu = hoverMenuRefs.activeMenu;
1029 if (!activeMenu) return;
1030 var offsetX = e.offsetX;
1031 var width = activeMenu.offsetWidth;
1032 var height = activeMenu.offsetHeight;
1033
1034 if (e.target === hoverMenuRefs.activeItem) {
1035 clearTimeout(_this3.hoverTimer);
1036 var _hoverMenuRefs = hoverMenuRefs,
1037 activeItem = _hoverMenuRefs.activeItem;
1038
1039 var offsetY_top = activeItem.offsetTop;
1040 var offsetY_Bottom = offsetY_top + activeItem.offsetHeight;
1041
1042 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 ';
1043 } else {
1044 if (!_this3.hoverTimer) {
1045 _this3.hoverTimer = setTimeout(function () {
1046 hoverMenuRefs.hoverZone.innerHTML = '';
1047 }, hoverThreshold);
1048 }
1049 }
1050 };
1051
1052 var menus = this._l(activeOptions, function (menu, menuIndex) {
1053 var isFlat = false;
1054 var menuId = 'menu-' + _this3.id + '-' + menuIndex;
1055 var ownsId = 'menu-' + _this3.id + '-' + (menuIndex + 1);
1056 var items = _this3._l(menu, function (item) {
1057 var events = {
1058 on: {}
1059 };
1060
1061 if (item.__IS__FLAT__OPTIONS) isFlat = true;
1062
1063 if (!item.disabled) {
1064 // keydown up/down/left/right/enter
1065 events.on.keydown = function (ev) {
1066 var keyCode = ev.keyCode;
1067 if ([37, 38, 39, 40, 13, 9, 27].indexOf(keyCode) < 0) {
1068 return;
1069 }
1070 var currentEle = ev.target;
1071 var parentEle = _this3.$refs.menus[menuIndex];
1072 var menuItemList = parentEle.querySelectorAll("[tabindex='-1']");
1073 var currentIndex = Array.prototype.indexOf.call(menuItemList, currentEle); // 当前索引
1074 var nextIndex = void 0,
1075 nextMenu = void 0;
1076 if ([38, 40].indexOf(keyCode) > -1) {
1077 if (keyCode === 38) {
1078 // up键
1079 nextIndex = currentIndex !== 0 ? currentIndex - 1 : currentIndex;
1080 } else if (keyCode === 40) {
1081 // down
1082 nextIndex = currentIndex !== menuItemList.length - 1 ? currentIndex + 1 : currentIndex;
1083 }
1084 menuItemList[nextIndex].focus();
1085 } else if (keyCode === 37) {
1086 // left键
1087 if (menuIndex !== 0) {
1088 var previousMenu = _this3.$refs.menus[menuIndex - 1];
1089 previousMenu.querySelector('[aria-expanded=true]').focus();
1090 }
1091 } else if (keyCode === 39) {
1092 // right
1093 if (item.children) {
1094 // 有子menu 选择子menu的第一个menuitem
1095 nextMenu = _this3.$refs.menus[menuIndex + 1];
1096 nextMenu.querySelectorAll("[tabindex='-1']")[0].focus();
1097 }
1098 } else if (keyCode === 13) {
1099 if (!item.children) {
1100 var id = currentEle.getAttribute('id');
1101 parentEle.setAttribute('aria-activedescendant', id);
1102 _this3.select(item, menuIndex);
1103 _this3.$nextTick(function () {
1104 return _this3.scrollMenu(_this3.$refs.menus[menuIndex]);
1105 });
1106 }
1107 } else if (keyCode === 9 || keyCode === 27) {
1108 // esc tab
1109 _this3.$emit('closeInside');
1110 }
1111 };
1112 if (item.children) {
1113 (function () {
1114 var triggerEvent = {
1115 click: 'click',
1116 hover: 'mouseenter'
1117 }[expandTrigger];
1118 var triggerHandler = function triggerHandler() {
1119 if (_this3.visible) {
1120 _this3.activeItem(item, menuIndex);
1121 _this3.$nextTick(function () {
1122 // adjust self and next level
1123 _this3.scrollMenu(_this3.$refs.menus[menuIndex]);
1124 _this3.scrollMenu(_this3.$refs.menus[menuIndex + 1]);
1125 });
1126 }
1127 };
1128 events.on[triggerEvent] = triggerHandler;
1129 if (triggerEvent === 'mouseenter' && _this3.changeOnSelect) {
1130 events.on.click = function () {
1131 if (_this3.activeValue.indexOf(item.value) !== -1) {
1132 _this3.$emit('closeInside', true);
1133 }
1134 };
1135 }
1136 events.on['mousedown'] = function () {
1137 _this3.clicking = true;
1138 };
1139 events.on['focus'] = function () {
1140 // focus 选中
1141 if (_this3.clicking) {
1142 _this3.clicking = false;
1143 return;
1144 }
1145 triggerHandler();
1146 };
1147 })();
1148 } else {
1149 events.on.click = function () {
1150 _this3.select(item, menuIndex);
1151 _this3.$nextTick(function () {
1152 return _this3.scrollMenu(_this3.$refs.menus[menuIndex]);
1153 });
1154 };
1155 }
1156 }
1157 if (!item.disabled && !item.children) {
1158 // no children set id
1159 itemId = menuId + '-' + itemIndex;
1160 itemIndex++;
1161 }
1162 return h(
1163 'li',
1164 (0, _babelHelperVueJsxMergeProps2.default)([{
1165 'class': {
1166 'el-cascader-menu__item': true,
1167 'el-cascader-menu__item--extensible': item.children,
1168 'is-active': item.value === activeValue[menuIndex],
1169 'is-disabled': item.disabled
1170 },
1171 ref: item.value === activeValue[menuIndex] ? 'activeItem' : null
1172 }, events, {
1173 attrs: {
1174 tabindex: item.disabled ? null : -1,
1175 role: 'menuitem',
1176 'aria-haspopup': !!item.children,
1177 'aria-expanded': item.value === activeValue[menuIndex],
1178 id: itemId,
1179 'aria-owns': !item.children ? null : ownsId
1180 }
1181 }]),
1182 [item.label]
1183 );
1184 });
1185 var menuStyle = {};
1186 if (isFlat) {
1187 menuStyle.minWidth = _this3.inputWidth + 'px';
1188 }
1189
1190 var isHoveredMenu = expandTrigger === 'hover' && activeValue.length - 1 === menuIndex;
1191 var hoverMenuEvent = {
1192 on: {}
1193 };
1194
1195 if (isHoveredMenu) {
1196 hoverMenuEvent.on.mousemove = hoverMenuHandler;
1197 menuStyle.position = 'relative';
1198 }
1199
1200 return h(
1201 'ul',
1202 (0, _babelHelperVueJsxMergeProps2.default)([{
1203 'class': {
1204 'el-cascader-menu': true,
1205 'el-cascader-menu--flexible': isFlat
1206 }
1207 }, hoverMenuEvent, {
1208 style: menuStyle,
1209 refInFor: true,
1210 ref: 'menus',
1211 attrs: { role: 'menu',
1212 id: menuId
1213 }
1214 }]),
1215 [items, isHoveredMenu ? h(
1216 'svg',
1217 {
1218 ref: 'hoverZone',
1219 style: {
1220 position: 'absolute',
1221 top: 0,
1222 height: '100%',
1223 width: '100%',
1224 left: 0,
1225 pointerEvents: 'none'
1226 }
1227 },
1228 []
1229 ) : null]
1230 );
1231 });
1232
1233 if (expandTrigger === 'hover') {
1234 this.$nextTick(function () {
1235 var activeItem = _this3.$refs.activeItem;
1236
1237 if (activeItem) {
1238 var activeMenu = activeItem.parentElement;
1239 var hoverZone = _this3.$refs.hoverZone;
1240
1241 hoverMenuRefs = {
1242 activeMenu: activeMenu,
1243 activeItem: activeItem,
1244 hoverZone: hoverZone
1245 };
1246 } else {
1247 hoverMenuRefs = {};
1248 }
1249 });
1250 }
1251
1252 return h(
1253 'transition',
1254 {
1255 attrs: { name: 'el-zoom-in-top' },
1256 on: {
1257 'before-enter': this.handleMenuEnter,
1258 'after-leave': this.handleMenuLeave
1259 }
1260 },
1261 [h(
1262 'div',
1263 {
1264 directives: [{
1265 name: 'show',
1266 value: visible
1267 }],
1268
1269 'class': ['el-cascader-menus el-popper', popperClass],
1270 ref: 'wrapper'
1271 },
1272 [h(
1273 'div',
1274 {
1275 attrs: { 'x-arrow': true },
1276 'class': 'popper__arrow' },
1277 []
1278 ), menus]
1279 )]
1280 );
1281 }
1282};
1283
1284/***/ }),
1285
1286/***/ 358:
1287/***/ (function(module, __webpack_exports__, __webpack_require__) {
1288
1289"use strict";
1290var 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:[
1291 {
1292 'is-opened': _vm.menuVisible,
1293 'is-disabled': _vm.cascaderDisabled
1294 },
1295 _vm.cascaderSize ? 'el-cascader--' + _vm.cascaderSize : ''
1296 ],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){_vm.handleComposition($event)},"compositionend":function($event){_vm.handleComposition($event)}},model:{value:(_vm.inputValue),callback:function ($$v) {_vm.inputValue=$$v},expression:"inputValue"}},[_c('template',{attrs:{"slot":"suffix"},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)}
1297var staticRenderFns = []
1298var esExports = { render: render, staticRenderFns: staticRenderFns }
1299/* harmony default export */ __webpack_exports__["a"] = (esExports);
1300
1301/***/ }),
1302
1303/***/ 4:
1304/***/ (function(module, exports) {
1305
1306module.exports = require("vue");
1307
1308/***/ }),
1309
1310/***/ 45:
1311/***/ (function(module, exports) {
1312
1313module.exports = require("babel-helper-vue-jsx-merge-props");
1314
1315/***/ }),
1316
1317/***/ 5:
1318/***/ (function(module, exports) {
1319
1320module.exports = require("element-ui/lib/mixins/locale");
1321
1322/***/ }),
1323
1324/***/ 6:
1325/***/ (function(module, exports) {
1326
1327module.exports = require("element-ui/lib/input");
1328
1329/***/ }),
1330
1331/***/ 7:
1332/***/ (function(module, exports) {
1333
1334module.exports = require("element-ui/lib/utils/vue-popper");
1335
1336/***/ })
1337
1338/******/ });
\No newline at end of file