mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-10 07:52:23 +03:00
+35
-16
@@ -154,15 +154,33 @@ export default {
|
||||
|
||||
mixins: [pointerScroll, typeAheadPointer, ajax],
|
||||
|
||||
emits: [
|
||||
'open',
|
||||
'close',
|
||||
'update:modelValue',
|
||||
'search',
|
||||
'search:compositionstart',
|
||||
'search:compositionend',
|
||||
'search:keydown',
|
||||
'search:blur',
|
||||
'search:focus',
|
||||
'search:input',
|
||||
'option:created',
|
||||
'option:selecting',
|
||||
'option:selected',
|
||||
'option:deselecting',
|
||||
'option:deselected',
|
||||
],
|
||||
|
||||
props: {
|
||||
/**
|
||||
* Contains the currently selected value. Very similar to a
|
||||
* `value` attribute on an <input>. You can listen for changes
|
||||
* with the 'input' event.
|
||||
* @type {Object||String||null}
|
||||
* @type {Object|String|Array|null}
|
||||
*/
|
||||
// eslint-disable-next-line vue/require-default-prop,vue/require-prop-types
|
||||
value: {},
|
||||
modelValue: {},
|
||||
|
||||
/**
|
||||
* An object with any custom components that you'd like to overwrite
|
||||
@@ -679,16 +697,17 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
isReducingValues() {
|
||||
return this.$props.reduce !== this.$options.props.reduce.default
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if the component needs to
|
||||
* track the state of values internally.
|
||||
* @return {boolean}
|
||||
*/
|
||||
isTrackingValues() {
|
||||
return (
|
||||
typeof this.value === 'undefined' ||
|
||||
this.$options.propsData.hasOwnProperty('reduce')
|
||||
)
|
||||
return typeof this.modelValue === 'undefined' || this.isReducingValues
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -696,7 +715,7 @@ export default {
|
||||
* @return {Array}
|
||||
*/
|
||||
selectedValue() {
|
||||
let value = this.value
|
||||
let value = this.modelValue
|
||||
if (this.isTrackingValues) {
|
||||
// Vue select has to manage value internally
|
||||
value = this.$data._value
|
||||
@@ -725,7 +744,7 @@ export default {
|
||||
* @returns {HTMLInputElement}
|
||||
*/
|
||||
searchEl() {
|
||||
return !!this.$scopedSlots['search']
|
||||
return !!this.$slots['search']
|
||||
? this.$refs.selectedOptions.querySelector(
|
||||
this.searchInputQuerySelector
|
||||
)
|
||||
@@ -733,7 +752,7 @@ export default {
|
||||
},
|
||||
|
||||
/**
|
||||
* The object to be bound to the $slots.search scoped slot.
|
||||
* The object to be bound to the $slots.search slot.
|
||||
* @returns {Object}
|
||||
*/
|
||||
scope() {
|
||||
@@ -923,8 +942,8 @@ export default {
|
||||
this.clearSelection()
|
||||
}
|
||||
|
||||
if (this.value && this.isTrackingValues) {
|
||||
this.setInternalValueFromOptions(this.value)
|
||||
if (this.modelValue && this.isTrackingValues) {
|
||||
this.setInternalValueFromOptions(this.modelValue)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -932,7 +951,7 @@ export default {
|
||||
* Make sure to update internal
|
||||
* value if prop changes outside
|
||||
*/
|
||||
value: {
|
||||
modelValue: {
|
||||
immediate: true,
|
||||
handler(val) {
|
||||
if (this.isTrackingValues) {
|
||||
@@ -957,8 +976,6 @@ export default {
|
||||
|
||||
created() {
|
||||
this.mutableLoading = this.loading
|
||||
|
||||
this.$on('option:created', this.pushTag)
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -988,7 +1005,9 @@ export default {
|
||||
this.$emit('option:selecting', option)
|
||||
if (!this.isOptionSelected(option)) {
|
||||
if (this.taggable && !this.optionExists(option)) {
|
||||
/* @TODO: could we use v-model instead of push-tags? */
|
||||
this.$emit('option:created', option)
|
||||
this.pushTag(option)
|
||||
}
|
||||
if (this.multiple) {
|
||||
option = this.selectedValue.concat(option)
|
||||
@@ -1052,7 +1071,7 @@ export default {
|
||||
* @param value
|
||||
*/
|
||||
updateValue(value) {
|
||||
if (typeof this.value === 'undefined') {
|
||||
if (typeof this.modelValue === 'undefined') {
|
||||
// Vue select has to manage value
|
||||
this.$data._value = value
|
||||
}
|
||||
@@ -1065,7 +1084,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
this.$emit('input', value)
|
||||
this.$emit('update:modelValue', value)
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user