1.7.2 • Published 10 months ago

vs-autocomplete v1.7.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

Vs Autocomplete Dropdown

Nested-Autocomplete-Multiselect-Dropdown for Vue 3, refer GitHub branch v2 for usage and installation in Vue 2

  • Ability to single/multi-select
  • Ability to select same option from different groups/parents
  • A11y compliant

:film_projector: Demo for Vue3.

:film_projector: Demo for Vue2.

:rocket: Usage

<vs-autocomplete
  label="Select option(s)"
  :options="options"
  :multiple="true"
  placeholder="Search options"
  :maxSelectableCount="4"
  :searchInputText="searchInputText"
  :searchOptionMatcher="optionMatcher"
  :keepMenuOpenOnRender="false"
  :compact="false"
  noSearchResultsText="No results found"
  labelHint="Select up to 4 options"
  v-model="selectedOptions"
  @open="onOpen"
  @close="onClose"
/>

:paperclip: Install

npm
 npm install vs-autocomplete@latest
yarn
 yarn add vs-autocomplete@latest
UMD
<script src="https://cdn.jsdelivr.net/npm/vs-autocomplete@latest/dist/vs-autocomplete.umd.min.js"></script>
OR
<script src="https://unpkg.com/vs-autocomplete@latest/dist/vs-autocomplete.umd.js"></script>

In Vue 2, UMD component is auto-registered globally.

In Vue 3, you need to either register the component globally by calling

app.component('vs-autocomplete', window.VsAutocomplete);

/* app is the Vue application instance(<App>). */

or

use it locally by registering it in the component.

components: {
  VsAutocomplete: window.VsAutocomplete,
}

:gear: Props

NameTypeDefaultRequiredDescription
optionsArray<option>[]trueOptions to be displayed in the dropdown
labelString-falseLabel of the option
multipleBooleanfalsefalseWhether to allow multiple selection
placeholderString''falsePlaceholder text to display when no option is selected
searchInputTextString''falseSearch input text to filter options
keepMenuOpenOnRenderBooleanfalsefalseWhether to keep the menu open on render
compactBooleanfalsefalseWhether to render the dropdown in compact mode
maxSelectableCountNumber0falseMaximum number of options that can be selected
noSearchResultsTextStringNo results foundfalseText to display when no search results are found
labelHintString-falseHint text to display below the label
searchOptionMatcher(searchInputText, option) => boolean() => {}falseCustom search option matcher function compares searchInputText against each option. If defined, it must return a boolean indicating match; otherwise, defaults to matching option labels.

:link: Events

NameTypeDescriptionPayload
v-modelArray<option>Emits the selected option(s)Selected options
open(HTMLDivElement, HTMLUListElement) => {}Emits when the dropdown-menu opensDropdown element & Menu element
close(HTMLDivElement, HTMLUListElement) => {}Emits when the dropdown-menu closesDropdown element & Menu element
:nut_and_bolt: Type option
NameTypeRequiredDescription
labelStringtrueLabel of the option
idAnyfalseUnique identifier for the option
valueAnyfalseValue of the option
disabledBooleanfalseWhether the option is disabled
selectedBooleanfalseWhether the option is selected initially
childrenArray<option>falseNested options
:nail_care: CSS Variables for Styling
Variable NameDescription
--primary-colorPrimary border color on the combobox
--background-colorBackground color of the option when focused or hovered
--hint-colorHint text color
--v-dropdown-widthWidth of the combobox
--max-widthMax width of the combobox
--box-shadowBox shadow of the combobox
--bezier-curveMenu toggle transition
--animation-delayTransition delay
:clipboard: options prop example
[
  {
    id: 1,
    label: 'Option 1',
    value: 'option1',
    children: [
      {
        id: 1.1,
        label: 'Option 1.1',
        value: 'option1.1',
        selected: true,
      },
      {
        id: 1.2,
        label: 'Option 1.2',
        value: 'option1.2',
      },
      {
        id: 1.3,
        label: 'Option 1.3',
        value: 'option1.3',
        children: [
          {
            id: 1.31,
            label: 'Option 1.3.1',
            value: 'option1.3.1',
          },
          {
            id: 1.32,
            label: 'Option 1.3.2',
            value: 'option1.3.2',
          },
        ],
      },
      {
        id: 1234,
        label: 'Option 1.4',
        value: 'option1.4',
      },
    ],
  },
  {
    id: 2,
    label: 'A long label. Should be truncated. Check in demo.(Option 2)',
    value: 'option2',
    selected: true,
    disabled: true,
  },
  {
    id: 3,
    label: 'A long label. Should be truncated. Check in demo.(Option 3)',
    value: 'option3',
    disabled: true,
    children: [
      {
        id: 3.1,
        label: 'Option 3.1',
        value: 'option3.1',
      },
      {
        id: 3.2,
        label: 'Option 3.2',
        value: 'option3.2',
      },
      {
        id: 3.3,
        label: 'Option 3.3',
        value: 'option3.3',
        children: [
          {
            id: 3.31,
            label: 'Option 3.3.1',
            value: 'option3.3.1',
          },
          {
            id: 3.32,
            label: 'Option 3.3.2',
            value: 'option3.3.2',
          },
        ],
      },
      {
        id: 4,
        label: 'Option 4.1',
        value: 'option4.1',
      },
    ],
  },
];

:bug: Feedback

If you find any issues, please create an issue here.

1.7.2

10 months ago

1.7.1

10 months ago

1.7.0

10 months ago

1.6.23

10 months ago

1.6.20

1 year ago

1.6.22

1 year ago

1.6.21

1 year ago

1.6.17

1 year ago

1.6.16

1 year ago

1.6.19

1 year ago

1.6.18

1 year ago

1.6.9

1 year ago

1.6.11

1 year ago

1.6.10

1 year ago

1.6.13

1 year ago

1.6.12

1 year ago

1.6.15

1 year ago

1.6.14

1 year ago

1.6.8

1 year ago

1.6.7

1 year ago

1.6.6

1 year ago

1.6.4

1 year ago

1.6.5

1 year ago

1.6.3

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.5

1 year ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

2 years ago

1.2.5

2 years ago

1.5.1

2 years ago

1.2.4

2 years ago

1.5.0

2 years ago

1.2.3

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago