1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423 |
- 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] = {
- /******/ exports: {},
- /******/ id: moduleId,
- /******/ loaded: false
- /******/ };
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/ // Flag the module as loaded
- /******/ module.loaded = 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;
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/dist/";
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(0);
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ 0:
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(260);
- /***/ },
- /***/ 3:
- /***/ function(module, exports) {
- module.exports = function normalizeComponent (
- rawScriptExports,
- compiledTemplate,
- scopeId,
- cssModules
- ) {
- var esModule
- var scriptExports = rawScriptExports = rawScriptExports || {}
- // ES6 modules interop
- var type = typeof rawScriptExports.default
- if (type === 'object' || type === 'function') {
- esModule = rawScriptExports
- scriptExports = rawScriptExports.default
- }
- // Vue.extend constructor export interop
- var options = typeof scriptExports === 'function'
- ? scriptExports.options
- : scriptExports
- // render functions
- if (compiledTemplate) {
- options.render = compiledTemplate.render
- options.staticRenderFns = compiledTemplate.staticRenderFns
- }
- // scopedId
- if (scopeId) {
- options._scopeId = scopeId
- }
- // inject cssModules
- if (cssModules) {
- var computed = options.computed || (options.computed = {})
- Object.keys(cssModules).forEach(function (key) {
- var module = cssModules[key]
- computed[key] = function () { return module }
- })
- }
- return {
- esModule: esModule,
- exports: scriptExports,
- options: options
- }
- }
- /***/ },
- /***/ 9:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/input");
- /***/ },
- /***/ 10:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/utils/clickoutside");
- /***/ },
- /***/ 13:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/utils/vue-popper");
- /***/ },
- /***/ 14:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/mixins/emitter");
- /***/ },
- /***/ 15:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/scrollbar");
- /***/ },
- /***/ 46:
- /***/ function(module, exports) {
- module.exports = require("throttle-debounce/debounce");
- /***/ },
- /***/ 47:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/utils/resize-event");
- /***/ },
- /***/ 60:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/mixins/locale");
- /***/ },
- /***/ 61:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/locale");
- /***/ },
- /***/ 117:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/utils/dom");
- /***/ },
- /***/ 211:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(212),
- /* template */
- __webpack_require__(213),
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 212:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _emitter = __webpack_require__(14);
- var _emitter2 = _interopRequireDefault(_emitter);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- exports.default = {
- mixins: [_emitter2.default],
- name: 'ElOption',
- componentName: 'ElOption',
- props: {
- value: {
- required: true
- },
- label: [String, Number],
- created: Boolean,
- disabled: {
- type: Boolean,
- default: false
- }
- },
- data: function data() {
- return {
- index: -1,
- groupDisabled: false,
- visible: true,
- hitState: false
- };
- },
- computed: {
- currentLabel: function currentLabel() {
- return this.label || (typeof this.value === 'string' || typeof this.value === 'number' ? this.value : '');
- },
- currentValue: function currentValue() {
- return this.value || this.label || '';
- },
- parent: function parent() {
- var result = this.$parent;
- while (!result.isSelect) {
- result = result.$parent;
- }
- return result;
- },
- itemSelected: function itemSelected() {
- if (!this.parent.multiple) {
- return this.value === this.parent.value;
- } else {
- return this.parent.value.indexOf(this.value) > -1;
- }
- },
- limitReached: function limitReached() {
- if (this.parent.multiple) {
- return !this.itemSelected && this.parent.value.length >= this.parent.multipleLimit && this.parent.multipleLimit > 0;
- } else {
- return false;
- }
- }
- },
- watch: {
- currentLabel: function currentLabel() {
- if (!this.created && !this.parent.remote) this.dispatch('ElSelect', 'setSelected');
- },
- value: function value() {
- if (!this.created && !this.parent.remote) this.dispatch('ElSelect', 'setSelected');
- }
- },
- methods: {
- handleGroupDisabled: function handleGroupDisabled(val) {
- this.groupDisabled = val;
- },
- hoverItem: function hoverItem() {
- if (!this.disabled && !this.groupDisabled) {
- this.parent.hoverIndex = this.parent.options.indexOf(this);
- }
- },
- selectOptionClick: function selectOptionClick() {
- if (this.disabled !== true && this.groupDisabled !== true) {
- this.dispatch('ElSelect', 'handleOptionClick', this);
- }
- },
- queryChange: function queryChange(query) {
- // query 里如果有正则中的特殊字符,需要先将这些字符转义
- var parsedQuery = String(query).replace(/(\^|\(|\)|\[|\]|\$|\*|\+|\.|\?|\\|\{|\}|\|)/g, '\\$1');
- this.visible = new RegExp(parsedQuery, 'i').test(this.currentLabel) || this.created;
- if (!this.visible) {
- this.parent.filteredOptionsCount--;
- }
- },
- resetIndex: function resetIndex() {
- var _this = this;
- this.$nextTick(function () {
- _this.index = _this.parent.options.indexOf(_this);
- });
- }
- },
- created: function created() {
- this.parent.options.push(this);
- this.parent.cachedOptions.push(this);
- this.parent.optionsCount++;
- this.parent.filteredOptionsCount++;
- this.index = this.parent.options.indexOf(this);
- this.$on('queryChange', this.queryChange);
- this.$on('handleGroupDisabled', this.handleGroupDisabled);
- this.$on('resetIndex', this.resetIndex);
- },
- beforeDestroy: function beforeDestroy() {
- this.dispatch('ElSelect', 'onOptionDestroy', this);
- }
- }; //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- /***/ },
- /***/ 213:
- /***/ function(module, exports) {
- module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
- return _c('li', {
- directives: [{
- name: "show",
- rawName: "v-show",
- value: (_vm.visible),
- expression: "visible"
- }],
- staticClass: "el-select-dropdown__item",
- class: {
- 'selected': _vm.itemSelected,
- 'is-disabled': _vm.disabled || _vm.groupDisabled || _vm.limitReached,
- 'hover': _vm.parent.hoverIndex === _vm.index
- },
- on: {
- "mouseenter": _vm.hoverItem,
- "click": function($event) {
- $event.stopPropagation();
- _vm.selectOptionClick($event)
- }
- }
- }, [_vm._t("default", [_c('span', [_vm._v(_vm._s(_vm.currentLabel))])])], 2)
- },staticRenderFns: []}
- /***/ },
- /***/ 260:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _select = __webpack_require__(261);
- var _select2 = _interopRequireDefault(_select);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- /* istanbul ignore next */
- _select2.default.install = function (Vue) {
- Vue.component(_select2.default.name, _select2.default);
- };
- exports.default = _select2.default;
- /***/ },
- /***/ 261:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(262),
- /* template */
- __webpack_require__(267),
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 262:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _emitter = __webpack_require__(14);
- var _emitter2 = _interopRequireDefault(_emitter);
- var _locale = __webpack_require__(60);
- var _locale2 = _interopRequireDefault(_locale);
- var _input = __webpack_require__(9);
- var _input2 = _interopRequireDefault(_input);
- var _selectDropdown = __webpack_require__(263);
- var _selectDropdown2 = _interopRequireDefault(_selectDropdown);
- var _option = __webpack_require__(211);
- var _option2 = _interopRequireDefault(_option);
- var _tag = __webpack_require__(266);
- var _tag2 = _interopRequireDefault(_tag);
- var _scrollbar = __webpack_require__(15);
- var _scrollbar2 = _interopRequireDefault(_scrollbar);
- var _debounce = __webpack_require__(46);
- var _debounce2 = _interopRequireDefault(_debounce);
- var _clickoutside = __webpack_require__(10);
- var _clickoutside2 = _interopRequireDefault(_clickoutside);
- var _dom = __webpack_require__(117);
- var _resizeEvent = __webpack_require__(47);
- var _locale3 = __webpack_require__(61);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- var sizeMap = {
- 'large': 42,
- 'small': 30,
- 'mini': 22
- };
- exports.default = {
- mixins: [_emitter2.default, _locale2.default],
- name: 'ElSelect',
- componentName: 'ElSelect',
- computed: {
- iconClass: function iconClass() {
- var criteria = this.clearable && !this.disabled && this.inputHovering && !this.multiple && this.value !== undefined && this.value !== '';
- return criteria ? 'circle-close is-show-close' : this.remote && this.filterable ? '' : 'caret-top';
- },
- debounce: function debounce() {
- return this.remote ? 300 : 0;
- },
- emptyText: function emptyText() {
- if (this.loading) {
- return this.loadingText || this.t('el.select.loading');
- } else {
- if (this.remote && this.query === '' && this.options.length === 0) return false;
- if (this.filterable && this.options.length > 0 && this.filteredOptionsCount === 0) {
- return this.noMatchText || this.t('el.select.noMatch');
- }
- if (this.options.length === 0) {
- return this.noDataText || this.t('el.select.noData');
- }
- }
- return null;
- },
- showNewOption: function showNewOption() {
- var _this = this;
- var hasExistingOption = this.options.filter(function (option) {
- return !option.created;
- }).some(function (option) {
- return option.currentLabel === _this.query;
- });
- return this.filterable && this.allowCreate && this.query !== '' && !hasExistingOption;
- }
- },
- components: {
- ElInput: _input2.default,
- ElSelectMenu: _selectDropdown2.default,
- ElOption: _option2.default,
- ElTag: _tag2.default,
- ElScrollbar: _scrollbar2.default
- },
- directives: { Clickoutside: _clickoutside2.default },
- props: {
- name: String,
- value: {},
- size: String,
- disabled: Boolean,
- clearable: Boolean,
- filterable: Boolean,
- allowCreate: Boolean,
- loading: Boolean,
- popperClass: String,
- remote: Boolean,
- loadingText: String,
- noMatchText: String,
- noDataText: String,
- remoteMethod: Function,
- filterMethod: Function,
- multiple: Boolean,
- multipleLimit: {
- type: Number,
- default: 0
- },
- placeholder: {
- type: String,
- default: function _default() {
- return (0, _locale3.t)('el.select.placeholder');
- }
- }
- },
- data: function data() {
- return {
- options: [],
- cachedOptions: [],
- createdLabel: null,
- createdSelected: false,
- selected: this.multiple ? [] : {},
- isSelect: true,
- inputLength: 20,
- inputWidth: 0,
- cachedPlaceHolder: '',
- optionsCount: 0,
- filteredOptionsCount: 0,
- dropdownUl: null,
- visible: false,
- selectedLabel: '',
- hoverIndex: -1,
- query: '',
- bottomOverflow: 0,
- topOverflow: 0,
- optionsAllDisabled: false,
- inputHovering: false,
- currentPlaceholder: ''
- };
- },
- watch: {
- placeholder: function placeholder(val) {
- this.cachedPlaceHolder = this.currentPlaceholder = val;
- },
- value: function value(val) {
- if (this.multiple) {
- this.resetInputHeight();
- if (val.length > 0 || this.$refs.input && this.query !== '') {
- this.currentPlaceholder = '';
- } else {
- this.currentPlaceholder = this.cachedPlaceHolder;
- }
- }
- this.setSelected();
- if (this.filterable && !this.multiple) {
- this.inputLength = 20;
- }
- this.$emit('change', val);
- this.dispatch('ElFormItem', 'el.form.change', val);
- },
- query: function query(val) {
- var _this2 = this;
- this.$nextTick(function () {
- if (_this2.visible) _this2.broadcast('ElSelectDropdown', 'updatePopper');
- });
- this.hoverIndex = -1;
- if (this.multiple && this.filterable) {
- this.inputLength = this.$refs.input.value.length * 15 + 20;
- this.managePlaceholder();
- this.resetInputHeight();
- }
- if (this.remote && typeof this.remoteMethod === 'function') {
- this.hoverIndex = -1;
- this.remoteMethod(val);
- this.broadcast('ElOption', 'resetIndex');
- } else if (typeof this.filterMethod === 'function') {
- this.filterMethod(val);
- this.broadcast('ElOptionGroup', 'queryChange');
- } else {
- this.filteredOptionsCount = this.optionsCount;
- this.broadcast('ElOption', 'queryChange', val);
- this.broadcast('ElOptionGroup', 'queryChange');
- }
- },
- visible: function visible(val) {
- var _this3 = this;
- if (!val) {
- this.$refs.reference.$el.querySelector('input').blur();
- this.handleIconHide();
- this.broadcast('ElSelectDropdown', 'destroyPopper');
- if (this.$refs.input) {
- this.$refs.input.blur();
- }
- this.query = '';
- this.selectedLabel = '';
- this.inputLength = 20;
- this.resetHoverIndex();
- this.$nextTick(function () {
- if (_this3.$refs.input && _this3.$refs.input.value === '' && _this3.selected.length === 0) {
- _this3.currentPlaceholder = _this3.cachedPlaceHolder;
- }
- });
- if (!this.multiple) {
- this.getOverflows();
- if (this.selected) {
- if (this.filterable && this.allowCreate && this.createdSelected && this.createdOption) {
- this.selectedLabel = this.createdLabel;
- } else {
- this.selectedLabel = this.selected.currentLabel;
- }
- if (this.filterable) this.query = this.selectedLabel;
- }
- }
- } else {
- this.handleIconShow();
- this.broadcast('ElSelectDropdown', 'updatePopper');
- if (this.filterable) {
- this.query = this.selectedLabel;
- if (this.multiple) {
- this.$refs.input.focus();
- } else {
- if (!this.remote) {
- this.broadcast('ElOption', 'queryChange', '');
- this.broadcast('ElOptionGroup', 'queryChange');
- }
- this.broadcast('ElInput', 'inputSelect');
- }
- }
- }
- this.$emit('visible-change', val);
- },
- options: function options(val) {
- if (this.$isServer) return;
- this.optionsAllDisabled = val.length === val.filter(function (item) {
- return item.disabled === true;
- }).length;
- if (this.multiple) {
- this.resetInputHeight();
- }
- var inputs = this.$el.querySelectorAll('input');
- if ([].indexOf.call(inputs, document.activeElement) === -1) {
- this.setSelected();
- }
- }
- },
- methods: {
- handleIconHide: function handleIconHide() {
- var icon = this.$el.querySelector('.el-input__icon');
- if (icon) {
- (0, _dom.removeClass)(icon, 'is-reverse');
- }
- },
- handleIconShow: function handleIconShow() {
- var icon = this.$el.querySelector('.el-input__icon');
- if (icon && !(0, _dom.hasClass)(icon, 'el-icon-circle-close')) {
- (0, _dom.addClass)(icon, 'is-reverse');
- }
- },
- handleMenuEnter: function handleMenuEnter() {
- if (!this.dropdownUl) {
- this.dropdownUl = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
- this.getOverflows();
- }
- if (!this.multiple && this.dropdownUl) {
- this.resetMenuScroll();
- }
- },
- getOverflows: function getOverflows() {
- if (this.dropdownUl && this.selected && this.selected.$el) {
- var selectedRect = this.selected.$el.getBoundingClientRect();
- var popperRect = this.$refs.popper.$el.getBoundingClientRect();
- this.bottomOverflow = selectedRect.bottom - popperRect.bottom;
- this.topOverflow = selectedRect.top - popperRect.top;
- }
- },
- resetMenuScroll: function resetMenuScroll() {
- if (this.bottomOverflow > 0) {
- this.dropdownUl.scrollTop += this.bottomOverflow;
- } else if (this.topOverflow < 0) {
- this.dropdownUl.scrollTop += this.topOverflow;
- }
- },
- getOption: function getOption(value) {
- var option = void 0;
- for (var i = this.cachedOptions.length - 1; i >= 0; i--) {
- var cachedOption = this.cachedOptions[i];
- if (cachedOption.value === value) {
- option = cachedOption;
- break;
- }
- }
- if (option) return option;
- var label = typeof value === 'string' || typeof value === 'number' ? value : '';
- var newOption = {
- value: value,
- currentLabel: label
- };
- if (this.multiple) {
- newOption.hitState = false;
- }
- return newOption;
- },
- setSelected: function setSelected() {
- var _this4 = this;
- if (!this.multiple) {
- var option = this.getOption(this.value);
- if (option.created) {
- this.createdLabel = option.currentLabel;
- this.createdSelected = true;
- } else {
- this.createdSelected = false;
- }
- this.selectedLabel = option.currentLabel;
- this.selected = option;
- if (this.filterable) this.query = this.selectedLabel;
- return;
- }
- var result = [];
- if (Array.isArray(this.value)) {
- this.value.forEach(function (value) {
- result.push(_this4.getOption(value));
- });
- }
- this.selected = result;
- this.$nextTick(function () {
- _this4.resetInputHeight();
- });
- },
- handleFocus: function handleFocus() {
- this.visible = true;
- },
- handleIconClick: function handleIconClick(event) {
- if (this.iconClass.indexOf('circle-close') > -1) {
- this.deleteSelected(event);
- } else {
- this.toggleMenu();
- }
- },
- handleMouseDown: function handleMouseDown(event) {
- if (event.target.tagName !== 'INPUT') return;
- if (this.visible) {
- this.handleClose();
- event.preventDefault();
- }
- },
- doDestroy: function doDestroy() {
- this.$refs.popper && this.$refs.popper.doDestroy();
- },
- handleClose: function handleClose() {
- this.visible = false;
- },
- toggleLastOptionHitState: function toggleLastOptionHitState(hit) {
- if (!Array.isArray(this.selected)) return;
- var option = this.selected[this.selected.length - 1];
- if (!option) return;
- if (hit === true || hit === false) {
- option.hitState = hit;
- return hit;
- }
- option.hitState = !option.hitState;
- return option.hitState;
- },
- deletePrevTag: function deletePrevTag(e) {
- if (e.target.value.length <= 0 && !this.toggleLastOptionHitState()) {
- this.value.pop();
- }
- },
- managePlaceholder: function managePlaceholder() {
- if (this.currentPlaceholder !== '') {
- this.currentPlaceholder = this.$refs.input.value ? '' : this.cachedPlaceHolder;
- }
- },
- resetInputState: function resetInputState(e) {
- if (e.keyCode !== 8) this.toggleLastOptionHitState(false);
- this.inputLength = this.$refs.input.value.length * 15 + 20;
- this.resetInputHeight();
- },
- resetInputHeight: function resetInputHeight() {
- var _this5 = this;
- this.$nextTick(function () {
- if (!_this5.$refs.reference) return;
- var inputChildNodes = _this5.$refs.reference.$el.childNodes;
- var input = [].filter.call(inputChildNodes, function (item) {
- return item.tagName === 'INPUT';
- })[0];
- input.style.height = Math.max(_this5.$refs.tags.clientHeight + 6, sizeMap[_this5.size] || 36) + 'px';
- if (_this5.visible && _this5.emptyText !== false) {
- _this5.broadcast('ElSelectDropdown', 'updatePopper');
- }
- });
- },
- resetHoverIndex: function resetHoverIndex() {
- var _this6 = this;
- setTimeout(function () {
- if (!_this6.multiple) {
- _this6.hoverIndex = _this6.options.indexOf(_this6.selected);
- } else {
- if (_this6.selected.length > 0) {
- _this6.hoverIndex = Math.min.apply(null, _this6.selected.map(function (item) {
- return _this6.options.indexOf(item);
- }));
- } else {
- _this6.hoverIndex = -1;
- }
- }
- }, 300);
- },
- handleOptionSelect: function handleOptionSelect(option) {
- if (!this.multiple) {
- this.$emit('input', option.value);
- this.visible = false;
- } else {
- var optionIndex = -1;
- this.value.forEach(function (item, index) {
- if (item === option.value) {
- optionIndex = index;
- }
- });
- if (optionIndex > -1) {
- this.value.splice(optionIndex, 1);
- } else if (this.multipleLimit <= 0 || this.value.length < this.multipleLimit) {
- this.value.push(option.value);
- }
- if (option.created) {
- this.query = '';
- this.inputLength = 20;
- }
- if (this.filterable) this.$refs.input.focus();
- }
- },
- toggleMenu: function toggleMenu() {
- if (this.filterable && this.query === '' && this.visible) {
- return;
- }
- if (!this.disabled) {
- this.visible = !this.visible;
- }
- },
- navigateOptions: function navigateOptions(direction) {
- if (!this.visible) {
- this.visible = true;
- return;
- }
- if (this.options.length === 0 || this.filteredOptionsCount === 0) return;
- if (!this.optionsAllDisabled) {
- if (direction === 'next') {
- this.hoverIndex++;
- if (this.hoverIndex === this.options.length) {
- this.hoverIndex = 0;
- }
- this.resetScrollTop();
- if (this.options[this.hoverIndex].disabled === true || this.options[this.hoverIndex].groupDisabled === true || !this.options[this.hoverIndex].visible) {
- this.navigateOptions('next');
- }
- }
- if (direction === 'prev') {
- this.hoverIndex--;
- if (this.hoverIndex < 0) {
- this.hoverIndex = this.options.length - 1;
- }
- this.resetScrollTop();
- if (this.options[this.hoverIndex].disabled === true || this.options[this.hoverIndex].groupDisabled === true || !this.options[this.hoverIndex].visible) {
- this.navigateOptions('prev');
- }
- }
- }
- },
- resetScrollTop: function resetScrollTop() {
- var bottomOverflowDistance = this.options[this.hoverIndex].$el.getBoundingClientRect().bottom - this.$refs.popper.$el.getBoundingClientRect().bottom;
- var topOverflowDistance = this.options[this.hoverIndex].$el.getBoundingClientRect().top - this.$refs.popper.$el.getBoundingClientRect().top;
- if (bottomOverflowDistance > 0) {
- this.dropdownUl.scrollTop += bottomOverflowDistance;
- }
- if (topOverflowDistance < 0) {
- this.dropdownUl.scrollTop += topOverflowDistance;
- }
- },
- selectOption: function selectOption() {
- if (this.options[this.hoverIndex]) {
- this.handleOptionSelect(this.options[this.hoverIndex]);
- }
- },
- deleteSelected: function deleteSelected(event) {
- event.stopPropagation();
- this.$emit('input', '');
- this.visible = false;
- },
- deleteTag: function deleteTag(event, tag) {
- var index = this.selected.indexOf(tag);
- if (index > -1 && !this.disabled) {
- this.value.splice(index, 1);
- this.$emit('remove-tag', tag);
- }
- event.stopPropagation();
- },
- onInputChange: function onInputChange() {
- if (this.filterable) {
- this.query = this.selectedLabel;
- }
- },
- onOptionDestroy: function onOptionDestroy(option) {
- this.optionsCount--;
- this.filteredOptionsCount--;
- var index = this.options.indexOf(option);
- if (index > -1) {
- this.options.splice(index, 1);
- }
- this.broadcast('ElOption', 'resetIndex');
- },
- resetInputWidth: function resetInputWidth() {
- this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;
- },
- handleResize: function handleResize() {
- this.resetInputWidth();
- if (this.multiple) this.resetInputHeight();
- }
- },
- created: function created() {
- var _this7 = this;
- this.cachedPlaceHolder = this.currentPlaceholder = this.placeholder;
- if (this.multiple && !Array.isArray(this.value)) {
- this.$emit('input', []);
- }
- if (!this.multiple && Array.isArray(this.value)) {
- this.$emit('input', '');
- }
- this.setSelected();
- this.debouncedOnInputChange = (0, _debounce2.default)(this.debounce, function () {
- _this7.onInputChange();
- });
- this.$on('handleOptionClick', this.handleOptionSelect);
- this.$on('onOptionDestroy', this.onOptionDestroy);
- this.$on('setSelected', this.setSelected);
- },
- mounted: function mounted() {
- var _this8 = this;
- if (this.multiple && Array.isArray(this.value) && this.value.length > 0) {
- this.currentPlaceholder = '';
- }
- (0, _resizeEvent.addResizeListener)(this.$el, this.handleResize);
- if (this.remote && this.multiple) {
- this.resetInputHeight();
- }
- this.$nextTick(function () {
- if (_this8.$refs.reference && _this8.$refs.reference.$el) {
- _this8.inputWidth = _this8.$refs.reference.$el.getBoundingClientRect().width;
- }
- });
- },
- beforeDestroy: function beforeDestroy() {
- if (this.$el && this.handleResize) (0, _resizeEvent.removeResizeListener)(this.$el, this.handleResize);
- }
- };
- /***/ },
- /***/ 263:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(264),
- /* template */
- __webpack_require__(265),
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 264:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _vuePopper = __webpack_require__(13);
- var _vuePopper2 = _interopRequireDefault(_vuePopper);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- exports.default = {
- name: 'ElSelectDropdown',
- componentName: 'ElSelectDropdown',
- mixins: [_vuePopper2.default],
- props: {
- placement: {
- default: 'bottom-start'
- },
- boundariesPadding: {
- default: 0
- },
- popperOptions: {
- default: function _default() {
- return {
- forceAbsolute: true,
- gpuAcceleration: false
- };
- }
- }
- },
- data: function data() {
- return {
- minWidth: ''
- };
- },
- computed: {
- popperClass: function popperClass() {
- return this.$parent.popperClass;
- }
- },
- watch: {
- '$parent.inputWidth': function $parentInputWidth() {
- this.minWidth = this.$parent.$el.getBoundingClientRect().width + 'px';
- }
- },
- mounted: function mounted() {
- this.referenceElm = this.$parent.$refs.reference.$el;
- this.$parent.popperElm = this.popperElm = this.$el;
- this.$on('updatePopper', this.updatePopper);
- this.$on('destroyPopper', this.destroyPopper);
- }
- }; //
- //
- //
- //
- //
- //
- //
- //
- //
- /***/ },
- /***/ 265:
- /***/ function(module, exports) {
- module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
- return _c('div', {
- staticClass: "el-select-dropdown",
- class: [{
- 'is-multiple': _vm.$parent.multiple
- }, _vm.popperClass],
- style: ({
- minWidth: _vm.minWidth
- })
- }, [_vm._t("default")], 2)
- },staticRenderFns: []}
- /***/ },
- /***/ 266:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/tag");
- /***/ },
- /***/ 267:
- /***/ function(module, exports) {
- module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
- return _c('div', {
- directives: [{
- name: "clickoutside",
- rawName: "v-clickoutside",
- value: (_vm.handleClose),
- expression: "handleClose"
- }],
- staticClass: "el-select"
- }, [(_vm.multiple) ? _c('div', {
- ref: "tags",
- staticClass: "el-select__tags",
- style: ({
- 'max-width': _vm.inputWidth - 32 + 'px'
- }),
- on: {
- "click": function($event) {
- $event.stopPropagation();
- _vm.toggleMenu($event)
- }
- }
- }, [_c('transition-group', {
- on: {
- "after-leave": _vm.resetInputHeight
- }
- }, _vm._l((_vm.selected), function(item) {
- return _c('el-tag', {
- key: item.value,
- attrs: {
- "closable": "",
- "hit": item.hitState,
- "type": "primary",
- "close-transition": ""
- },
- on: {
- "close": function($event) {
- _vm.deleteTag($event, item)
- }
- }
- }, [_c('span', {
- staticClass: "el-select__tags-text"
- }, [_vm._v(_vm._s(item.currentLabel))])])
- })), (_vm.filterable) ? _c('input', {
- directives: [{
- name: "model",
- rawName: "v-model",
- value: (_vm.query),
- expression: "query"
- }],
- ref: "input",
- staticClass: "el-select__input",
- class: ("is-" + _vm.size),
- style: ({
- width: _vm.inputLength + 'px',
- 'max-width': _vm.inputWidth - 42 + 'px'
- }),
- attrs: {
- "type": "text",
- "disabled": _vm.disabled,
- "debounce": _vm.remote ? 300 : 0
- },
- domProps: {
- "value": _vm._s(_vm.query)
- },
- on: {
- "focus": function($event) {
- _vm.visible = true
- },
- "keyup": _vm.managePlaceholder,
- "keydown": [_vm.resetInputState, function($event) {
- if (_vm._k($event.keyCode, "down", 40)) { return; }
- $event.preventDefault();
- _vm.navigateOptions('next')
- }, function($event) {
- if (_vm._k($event.keyCode, "up", 38)) { return; }
- $event.preventDefault();
- _vm.navigateOptions('prev')
- }, function($event) {
- if (_vm._k($event.keyCode, "enter", 13)) { return; }
- $event.preventDefault();
- _vm.selectOption($event)
- }, function($event) {
- if (_vm._k($event.keyCode, "esc", 27)) { return; }
- $event.preventDefault();
- _vm.visible = false
- }, function($event) {
- if (_vm._k($event.keyCode, "delete", [8, 46])) { return; }
- _vm.deletePrevTag($event)
- }],
- "input": function($event) {
- if ($event.target.composing) { return; }
- _vm.query = $event.target.value
- }
- }
- }) : _vm._e()], 1) : _vm._e(), _c('el-input', {
- directives: [{
- name: "model",
- rawName: "v-model",
- value: (_vm.selectedLabel),
- expression: "selectedLabel"
- }],
- ref: "reference",
- attrs: {
- "type": "text",
- "placeholder": _vm.currentPlaceholder,
- "name": _vm.name,
- "size": _vm.size,
- "disabled": _vm.disabled,
- "readonly": !_vm.filterable || _vm.multiple,
- "validate-event": false,
- "icon": _vm.iconClass
- },
- domProps: {
- "value": (_vm.selectedLabel)
- },
- on: {
- "focus": _vm.handleFocus,
- "click": _vm.handleIconClick,
- "input": function($event) {
- _vm.selectedLabel = $event
- }
- },
- nativeOn: {
- "mousedown": function($event) {
- _vm.handleMouseDown($event)
- },
- "keyup": function($event) {
- _vm.debouncedOnInputChange($event)
- },
- "keydown": [function($event) {
- if (_vm._k($event.keyCode, "down", 40)) { return; }
- $event.preventDefault();
- _vm.navigateOptions('next')
- }, function($event) {
- if (_vm._k($event.keyCode, "up", 38)) { return; }
- $event.preventDefault();
- _vm.navigateOptions('prev')
- }, function($event) {
- if (_vm._k($event.keyCode, "enter", 13)) { return; }
- $event.preventDefault();
- _vm.selectOption($event)
- }, function($event) {
- if (_vm._k($event.keyCode, "esc", 27)) { return; }
- $event.preventDefault();
- _vm.visible = false
- }, function($event) {
- if (_vm._k($event.keyCode, "tab", 9)) { return; }
- _vm.visible = false
- }],
- "paste": function($event) {
- _vm.debouncedOnInputChange($event)
- },
- "mouseenter": function($event) {
- _vm.inputHovering = true
- },
- "mouseleave": function($event) {
- _vm.inputHovering = false
- }
- }
- }), _c('transition', {
- attrs: {
- "name": "el-zoom-in-top"
- },
- on: {
- "after-leave": _vm.doDestroy,
- "after-enter": _vm.handleMenuEnter
- }
- }, [_c('el-select-menu', {
- directives: [{
- name: "show",
- rawName: "v-show",
- value: (_vm.visible && _vm.emptyText !== false),
- expression: "visible && emptyText !== false"
- }],
- ref: "popper"
- }, [_c('el-scrollbar', {
- directives: [{
- name: "show",
- rawName: "v-show",
- value: (_vm.options.length > 0 && !_vm.loading),
- expression: "options.length > 0 && !loading"
- }],
- class: {
- 'is-empty': !_vm.allowCreate && _vm.filteredOptionsCount === 0
- },
- attrs: {
- "tag": "ul",
- "wrap-class": "el-select-dropdown__wrap",
- "view-class": "el-select-dropdown__list"
- }
- }, [(_vm.showNewOption) ? _c('el-option', {
- attrs: {
- "value": _vm.query,
- "created": ""
- }
- }) : _vm._e(), _vm._t("default")], 2), (_vm.emptyText && !_vm.allowCreate) ? _c('p', {
- staticClass: "el-select-dropdown__empty"
- }, [_vm._v(_vm._s(_vm.emptyText))]) : _vm._e()], 1)], 1)], 1)
- },staticRenderFns: []}
- /***/ }
- /******/ });
|