# vanilla-select

> Standalone replacement for select boxes

Latest version **1.0.25** (published 2020-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install vanilla-select
pnpm add vanilla-select
yarn add vanilla-select
bun add vanilla-select
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.25 |
| Published | 2020-10-30 |
| First published | 2017-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 41.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Kateryna Vorotina |
| Maintainers | kolbasik, vorotina, foripepe, otomeskhy |
| Keywords | vanilla, select, dropdown, js |

## Links

- npm: https://www.npmjs.com/package/vanilla-select
- Repository: https://github.com/vorotina/vanilla-select
- Homepage: https://github.com/vorotina/vanilla-select#readme
- Issues: https://github.com/vorotina/vanilla-select/issues
- npm.io page: https://npm.io/package/vanilla-select

## Dependencies (1)

- [element-closest](https://npm.io/package/element-closest.md) ^2.0.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.25 (latest) — 2020-10-30
- 1.0.24 — 2020-10-30
- 1.0.23 — 2020-10-30
- 1.0.22 — 2020-10-27
- 1.0.21 — 2020-10-27
- 1.0.20 — 2020-10-27
- 1.0.18 — 2020-10-27
- 1.0.17 — 2020-04-02
- 1.0.16 — 2020-03-25
- 1.0.15 — 2020-03-24
- 1.0.14 — 2020-03-24
- 1.0.13 — 2018-07-03
- 1.0.12 — 2017-11-16
- 1.0.11 — 2017-07-21
- 1.0.10 — 2017-06-19
- … 10 more at https://npm.io/package/vanilla-select/versions

## README

# vanilla-select [![npm version](https://badge.fury.io/js/vanilla-select.svg)](https://www.npmjs.com/package/vanilla-select)
A vanilla, lightweight (~2.5kb gzipped), configurable select box component. 

[Demo Page](https://vorotina.github.io/vanilla-select/)

## Advantages
* Lightweight
* No Dependencies
* Elegant API - inspiration taken from [React.Component](https://facebook.github.io/react/docs/react-component.html) 
* Fast search


## Installation
With [NPM](https://www.npmjs.com/package/vanilla-select):
```zsh
npm install vanilla-select --save-dev
```

With [Bower](https://bower.io/):
```zsh
bower install vanilla-select --save-dev
```

Or include directly:

```html
<!-- Include CSS -->
<link rel="stylesheet" href="dist/vanilla-select.min.css">
<!-- Include JavaScript -->
<script src="/dist/vanilla-select.min.js"></script>
```
## Setup	

```js
  const source = [{
        icon: 'fa-font',
        value: 'Amatic SC'
    }];
  		
  const select = new Select({
            placeholder: 'Select Font',
            dataset: source,
            search: true,
            noResults: 'No results found',
            onSelected: item => callback(item)
        }).componentMount({
            el: document.querySelector('[ref="select"]')
        });
```

## Configuration 
| Option       | Definition |
| ------------ | ---------- |
| placeholder  | Type: String <br />Default: '' <br />Placeholder text |
| dataset      | Type: Array <br />Default: [] <br />Equivelant to the <option></option> element within a select   |
| search       | Type: Boolean <br />Default: false <br />Whether a user should be allowed to search |
| noResults    | Type: String <br />Default: '' <br />The text that is shown when search has returned no results |
| selected     | Type: Object <br />Default: null <br/>Default selected option 
| onSelected   | Arguments: item </br>Callback, invoked each time the item is selected, regardless if it changes the value 

## Development
To setup a local environment: clone this repo, navigate into it's directory in a terminal window and run the following command:

```npm install```

## Browser compatibility
vanilla-select is compiled using [Closure Compiler](https://developers.google.com/closure/compiler/) to enable support for [ES5 browsers](http://caniuse.com/#feat=es5). 

### Browsers
Edge 15+
Chrome 41+
FireFox 35+
Opera 28+
Safari 9+

If you need to support IE11 and IE Edge14 - use vanilla-select-ie.min.js bundle. 
It includes [element-closest](https://github.com/jonathantneal/closest/blob/master/element-closest.js) polyfill.


### Gulp tasks
| Task                | Usage                                                        |
| ------------------- | ------------------------------------------------------------ |
| `gulp build`         | Build JS an CSS                                              |
| `gulp serve`         | Fire up local server for development                         |

### Roadmap
* Keyboard navigation


## License
MIT License

---
_Source: https://npm.io/package/vanilla-select · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
