1.2.3 • Published 2 months ago

@andreazorzi/selectsearch v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

SelectSearch

Lightweight plugin to easily filter and search across a select's options.

Install

npm i @andreazorzi/selectsearch

Usage

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.3

2 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.0.8

4 months ago

1.0.7

5 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago