1.0.9 • Published 1 year ago

typeahead-autocomplete v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

typeahead-autocomplete

Description

This package is available for VueJS 2x

View The Examples

image image

Installation

From NPM:

> npm i typeahead-autocomplete

Browser

<script
  type="text/javascript"
  src="node_modules/vuejs/dist/vue.min.js"
></script>
<script
  type="text/javascript"
  src="node_modules/typeahead-autocomplete/dist/typeahead-autocomplete.min.js"
></script>
<script type="text/javascript">
  Vue.use(TypeaheadAutocomplete);
</script>

Usage

Import and register the component

import TypeaheadAutocomplete from "typeahead-autocomplete";

// Global registration
Vue.use(TypeaheadAutocomplete);

// OR

// Local registration
export default {
  components: {
    TypeaheadAutocomplete,
  },
};

Basic Usage

<typeahead-autocomplete
  v-model="selectedValue"
  :items="[
    { 
      text: 'ABC', 
      value: 'abc' 
    }, 
    { 
      text: 'DEF', 
      value: 'def' 
    }, 
    { 
      text: 'GHI', 
      value: 'ghi' 
    }
  ]"
/>

Attributes

NameTypeDefaultDescription
itemsArray[]Array of data.
initialTextStringtextThe displayed text at first.
initialValueString, NumbervalueThe selected value at first.
bindingTextStringtextPath to the property used to display the text.
bindingValueStringvaluePath to the property used to return the value.
prependTextStringText used to add at the beginning of the item.
appendTextStringText used to add at the end of the item.
disableSearchBooleanfalseTurn off the search function on the input field.
disableInputBooleanfalseDisable input.
placeholderStringPlaceholder for input field.
inputClassStringCustom classes for input field.
readOnlyBooleanfalseSet read-only for input field.
showNoDataBooleantrueOption to show text or not when no data is found.
remoteModeBooleanfalseSwitch to load data through API.
remoteUrlStringData request URL (Only works when remoteMode is enabled.
requestTimeoutNumber10000Maximum time for API to request data (milliseconds) (Only works when remoteMode is enabled.

Events

NameDescription
changeTriggered when an autocomplete item is selected. The entry in the input data array that was selected is returned.
inputTriggered when typing on search box. The typed data is returned.
hitThe component can be used with v-model. The bindingValue of the entry in the input data will be returned
fetchReturn all data from API after successfully fetched.

Slots

prepend and append slots available for adding buttons or other markup. nodata available for customizing the text when no data is found.

Contributing

PR's are welcome!