0.0.7 • Published 4 years ago

@optix/vue-select v0.0.7

Weekly downloads
12
License
MIT
Repository
-
Last release
4 years ago

Vue Select

Enhanced select component for Vue.js, unlike other select components Vue Select will not manipulate the options you provide to it, instead we emit events allowing you to perform all the filtering, loading or whatever else you might want to do yourself.

Features

  • No dependencies
  • v-model support
  • Single select
  • Multiple select
  • Infinite loading on scroll with throttling
  • Searchable with debounce
  • Configurable
  • Themeable

Install

yarn add @optix/vue-select

Setup

import Vue from 'vue';
import VueSelect from '@optix/vue-select';

import '@optix/vue-select/dist/vue-select.min.css';

Vue.use(VueSelect, /* { options } */);

Basic usage

<template>
    <vue-select
        v-model="value"
        :options="options"
    />
</template>

<script>
export default {
    data() {
        return {
            value: null,

            options: [
                {
                    value: 1,
                    label: 'Option One',
                },
                {
                    value: 2,
                    label: 'Option Two',
                    disabled: true,
                }
                // ...
            ],
        };
    };
};
</script>

Options

Props

NameTypeDefault ValueDescription
valueArray\|\|Number\|\|StringnullSelects the given options
optionsArray[]An array of objects
option-identifierString'value'Name of the identifier used within the options Object
option-labelString'label'Name of the label used within the options Object, this will be visible in the dropdown
idStringnullApplied to the underlying input
loadingBooleanfalseShow / hide the loading indicator
loading-moreBooleanfalseShow / hide loading indicator when scrolled to bottom of options list
multipleBooleanfalseAllows multiple options to be selected
searchableBooleantrueShow / hide search input
placeholderString'Please select...'Default placeholder text on select element
disabledBooleanfalseEnable / disable select
open-directionString'auto'Fix opening direction, options: 'auto'\|\|'down'\|\|'up'
close-on-selectBooleannullEnable opening / closing after selecting an option
search-debounce-delayNumber150Delay in milliseconds after user finishes typing and @search-change is fired
scroll-throttle-delayNumber150Delay in milliseconds between firing scroll events
load-more-thresholdNumber60Distance in px from bottom of options dropdown before @load-more is fired.
no-options-messageString'No options found.'Message shown when no options are provided

Events

EventPayloadDescription
@input(options)Fires when the value changes
@changenullFires when an option is selected or deselected
@select(option)Fires when an option is selected
@deselect(option)Fires when an option is deselected
@search-change(searchQuery)Fires when the search query changes
@load-morenullFires when the load-more-threshold of the dropdown has been scrolled past

Slots

Dropdown Option

Name: dropdown-option Description: Custom option template

Slot-scope:

  • option - Object of the current option
  • classes - Object containing 3 classes
{
    focused: false,
    selected: false,
    disabled: false,
}
<template #dropdown-option="{ option, classes }">
    <div class="vs-dropdown-option" :class="classes">
        {{ option.label }}
    </div>
</template>

Dropdown Loader

Name: dropdown-loader Description: Shows when no options are passed into the select

Default: Loading...

<template #dropdown-loader>
    <div class="vs-dropdown-loader">
        Loading...
    </div>
</template>

TODOs

  • Write tests
  • Working examples
  • Example on styling
  • Ability to add new options via component

License

The MIT License (MIT). Please see License File for more information.

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago