2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-16 09:10:33 +03:00

add filter prop allowing full customization of filtering

This commit is contained in:
Jeff
2018-01-12 18:23:46 -08:00
parent 47750233ba
commit aca7b5a248
6 changed files with 5915 additions and 32 deletions
+15 -8
View File
@@ -499,6 +499,19 @@
}
},
filter: {
"type": Function,
default(vm) {
return vm.mutableOptions.filter((option) => {
let label = vm.getOptionLabel(option)
if (typeof label === 'number') {
label = label.toString()
}
return this.filterFunction(option, label, vm.search)
});
}
},
/**
* An optional callback function that is called each time the selected
* value(s) change. When integrating with Vuex, use this callback to trigger
@@ -916,14 +929,8 @@
* @return {array}
*/
filteredOptions() {
let options = this.mutableOptions.filter((option) => {
let label = this.getOptionLabel(option)
if (typeof label === 'number') {
label = label.toString()
}
return this.filterFunction(option, label, this.search)
})
if (this.taggable && this.search.length && !this.optionExists(this.search)) {
let options = this.search.length ? this.filter(this) : this.mutableOptions;
if (this.taggable && !this.optionExists(this.search)) {
options.unshift(this.search)
}
return options