0.0.3 • Published 8 years ago

vue-uikit-autocomplete v0.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

vue-uikit-autocomplete

A small set of Vue 2.x input components adjusted for Uikit

Links

Currently it consists of 3 components:

  • VkInput
  • VkAutocomplete
  • VkAutocompleteHttp

They are built as UMD modules, so you can use them in any way you want.

Directly in an HTML page (they will be available as global variables by their names):

<script type="text/javascript" src="http://cdn.rawgit.com/sunabozu/vue-uikit-autocomplete/master/dist/vue.min.js/VkInput.js"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/sunabozu/vue-uikit-autocomplete/master/dist/vue.min.js/VkAutocomplete.js"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/sunabozu/vue-uikit-autocomplete/master/dist/vue.min.js/VkAutocompleteHttp.js"></script>

Or by installing...

npm i vue-uikit-autocomplete --save

...and then importing them:

import VkInput from 'vue-uikit-autocomplete/dist/VkInput'
import VkAutocomplete from 'vue-uikit-autocomplete/dist/VkAutocomplete'
import VkAutocompleteHttp from 'vue-uikit-autocomplete/dist/VkAutocompleteHttp'

VkInput

A simple input field

PropertyValuesDescription
typetext, number etc.Just a regular type attribute for input element
placeholderany textA regular placeholder
iconsee iconsOne of the supported icons
colordanger or sucessMakes the border red or green
disabledtrue or falseDisables or enables the input
sizelarge or smallGeneral size of the component
widelarge, medium, small or miniWidth of the component
flip-icontrue or falseShould the icon be animated?
EventDescription
inputA standard input event, just not native

VkAutocomplete

An input field with autocompletion. Based on VkInput, generates all of it events, and accepts all of it properties. You just have to provide an array of objects, and it will automatically search for matches and display only proper items. It uses text field for matching by default, but you can change it using field property. You can also provide a custom delegate to display the results in a way you want to (see Demo)

PropertyValuesDescription
itemsArrayAn array of objects such as [{ text: 'something'}]
fieldStringA name of the field in the items objects you want to view and match
delegateObjectA Vue component you want to use instead of the standard delegate
EventDescription
selectWhen user hits Enter; passes the selected object as an argument

VkAutocompleteHttp

A variation of VkAutocomplete that fetches suggestions from the network. Generates all of it events and accepts all of the properties of the previous two (except for items). You have to provide a URL of your data source and a filter function that processes the fetched list of objects and returns a proper array.

PropertyValuesDescription
urlhttp://...A URL of your data source
http-headersArrayArray of key-value pairs with the headers you want to pass during the request
debounceNumberAn interval between the network calls (ms)
filterFunctionAccepts a raw array and returns a proper array
EventDescription
errorReturns an error if something wrong happened during fetching