1.2.10 • Published 11 months ago
@andreazorzi/selectsearch v1.2.10
SelectSearch
Lightweight plugin to easily filter and search across a select's options.
Install
npm i @andreazorzi/selectsearchUsage
app.js
// SelectSearch
import SelectSearch from "@andreazorzi/selectsearch";
window.SelectSearch = SelectSearch;
// Locales
import selectsearch_it from "@andreazorzi/selectsearch/locale/it";
window.selectsearch_it = selectsearch_it;app.css
@import "@andreazorzi/selectsearch/select-search.css";HTML
<select id="select-search">
	<option value="1">Car</option>
	<option value="2">Bike</option>
	<option value="3">Bus</option>
	<option value="4">Plane</option>
</select>
<script>
    let select_search = new SelectSearch("#select-search", options)
</script>Options List
{
    lang: default_lang // an array of translated texts, default locale: it
    min_length: 0, // the minimum length to perform the search 
	list_limit: -1, // the limit of the items list
	custom_class: { // custom classes attached to the main elements
		placeholder: "",
		search_input: "",
		list_item: ""
	},
	render: (element) => { 
		return element.textContent
	},
	onSelect(element, value, text){
		
	}
}Methods
// Update the list (html is a lis of options)
updateOptionsList(html, value = null)
// Open the modal
open()
// Close the modal
close()
// Get the current value
getValue()
// Set value
setValue(value)1.2.9
11 months ago
1.2.10
11 months ago
1.2.8
1 year ago
1.2.7
1 year ago
1.2.6
1 year ago
1.2.5
1 year ago
1.2.4
1 year ago
1.2.3
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago