mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
move slot up one level
This commit is contained in:
+37
-13
@@ -52,19 +52,13 @@
|
|||||||
|
|
||||||
<transition :name="transition">
|
<transition :name="transition">
|
||||||
<ul ref="dropdownMenu" v-if="dropdownOpen" class="vs__dropdown-menu" role="listbox" @mousedown.prevent="onMousedown" @mouseup="onMouseUp">
|
<ul ref="dropdownMenu" v-if="dropdownOpen" class="vs__dropdown-menu" role="listbox" @mousedown.prevent="onMousedown" @mouseup="onMouseUp">
|
||||||
<li
|
<slot name="option" v-for="(option, index) in normalizedFilteredOptions">
|
||||||
role="option"
|
<li
|
||||||
v-for="(option, index) in filteredOptions"
|
role="option"
|
||||||
:key="getOptionKey(option)"
|
v-bind="getDropdownOptionScope(option, index).attributes"
|
||||||
class="vs__dropdown-option"
|
v-on="getDropdownOptionScope(option, index).events"
|
||||||
:class="{ 'vs__dropdown-option--selected': isOptionSelected(option), 'vs__dropdown-option--highlight': index === typeAheadPointer, 'vs__dropdown-option--disabled': !selectable(option) }"
|
>{{ getOptionLabel(option) }}</li>
|
||||||
@mouseover="selectable(option) ? typeAheadPointer = index : null"
|
</slot>
|
||||||
@mousedown.prevent.stop="selectable(option) ? select(option) : null"
|
|
||||||
>
|
|
||||||
<slot name="option" v-bind="normalizeOptionForSlot(option)">
|
|
||||||
{{ getOptionLabel(option) }}
|
|
||||||
</slot>
|
|
||||||
</li>
|
|
||||||
<li v-if="!filteredOptions.length" class="vs__no-options" @mousedown.stop="">
|
<li v-if="!filteredOptions.length" class="vs__no-options" @mousedown.stop="">
|
||||||
<slot name="no-options">Sorry, no matching options.</slot>
|
<slot name="no-options">Sorry, no matching options.</slot>
|
||||||
</li>
|
</li>
|
||||||
@@ -299,6 +293,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDropdownOptionScope: {
|
||||||
|
type: Function,
|
||||||
|
default(option, index) {
|
||||||
|
return {
|
||||||
|
option,
|
||||||
|
attributes: {
|
||||||
|
key: this.getOptionKey(option),
|
||||||
|
class: {
|
||||||
|
'vs__dropdown-option': true,
|
||||||
|
'vs__dropdown-option--selected': this.isOptionSelected(option),
|
||||||
|
'vs__dropdown-option--highlight': index === this.typeAheadPointer,
|
||||||
|
'vs__dropdown-option--disabled': !this.selectable(option),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
events: {
|
||||||
|
'mouseover': () => this.selectable(option) ? this.typeAheadPointer = index : null,
|
||||||
|
'mousedown': e => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
return this.selectable(option) ? this.select(option) : null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the current value if selectOnTab is enabled
|
* Select the current value if selectOnTab is enabled
|
||||||
@@ -1052,6 +1072,10 @@
|
|||||||
return options
|
return options
|
||||||
},
|
},
|
||||||
|
|
||||||
|
normalizedFilteredOptions() {
|
||||||
|
return this.filteredOptions.map(option => this.normalizeOptionForSlot(option));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if there aren't any options selected.
|
* Check if there aren't any options selected.
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
|
|||||||
Reference in New Issue
Block a user