mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-10 07:52:23 +03:00
Merge branch 'feature/custom-filter'
# Conflicts: # dev.html # yarn.lock
This commit is contained in:
+42
-22
@@ -525,21 +525,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback to filter the search result the label text.
|
||||
* @type {Function}
|
||||
* @param {Object || String} option
|
||||
* @param {String} label
|
||||
* @param {String} search
|
||||
* @return {Boolean}
|
||||
*/
|
||||
filterFunction: {
|
||||
type: Function,
|
||||
default(option, label, search) {
|
||||
return (label || '').toLowerCase().indexOf(search.toLowerCase()) > -1
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* An optional callback function that is called each time the selected
|
||||
* value(s) change. When integrating with Vuex, use this callback to trigger
|
||||
@@ -593,6 +578,47 @@
|
||||
default: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback to determine if the provided option should
|
||||
* match the current search text. Used to determine
|
||||
* if the option should be displayed.
|
||||
* @type {Function}
|
||||
* @param {Object || String} option
|
||||
* @param {String} label
|
||||
* @param {String} search
|
||||
* @return {Boolean}
|
||||
*/
|
||||
filterBy: {
|
||||
type: Function,
|
||||
default(option, label, search) {
|
||||
return (label || '').toLowerCase().indexOf(search.toLowerCase()) > -1
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback to filter results when search text
|
||||
* is provided. Default implementation loops
|
||||
* each option, and returns the result of
|
||||
* this.filterBy.
|
||||
* @type {Function}
|
||||
* @param {Array} list of options
|
||||
* @param {String} search text
|
||||
* @param {Object} vSelect instance
|
||||
* @return {Boolean}
|
||||
*/
|
||||
filter: {
|
||||
"type": Function,
|
||||
default(options, search) {
|
||||
return options.filter((option) => {
|
||||
let label = this.getOptionLabel(option)
|
||||
if (typeof label === 'number') {
|
||||
label = label.toString()
|
||||
}
|
||||
return this.filterBy(option, label, search)
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* User defined function for adding Options
|
||||
* @type {Function}
|
||||
@@ -988,13 +1014,7 @@
|
||||
if (!this.filterable && !this.taggable) {
|
||||
return this.mutableOptions.slice()
|
||||
}
|
||||
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)
|
||||
})
|
||||
let options = this.search.length ? this.filter(this.mutableOptions, this.search, this) : this.mutableOptions;
|
||||
if (this.taggable && this.search.length && !this.optionExists(this.search)) {
|
||||
options.unshift(this.search)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user