1.0.25 • Published 4 years ago

vanilla-select v1.0.25

Weekly downloads
85
License
MIT
Repository
github
Last release
4 years ago

vanilla-select npm version

A vanilla, lightweight (~2.5kb gzipped), configurable select box component.

Demo Page

Advantages

  • Lightweight
  • No Dependencies
  • Elegant API - inspiration taken from React.Component
  • Fast search

Installation

With NPM:

npm install vanilla-select --save-dev

With Bower:

bower install vanilla-select --save-dev

Or include directly:

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

Setup

  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

OptionDefinition
placeholderType: String Default: '' Placeholder text
datasetType: Array Default: [] Equivelant to the element within a select
searchType: Boolean Default: false Whether a user should be allowed to search
noResultsType: String Default: '' The text that is shown when search has returned no results
selectedType: Object Default: null Default selected option
onSelectedArguments: item 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 to enable support for ES5 browsers.

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

Gulp tasks

TaskUsage
gulp buildBuild JS an CSS
gulp serveFire up local server for development

Roadmap

  • Keyboard navigation

License

MIT License

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago