Awesomplete wrapper for Vue and webpack
Awesomplete Vue webpack Component (AVWC) is an Awesomplete VueJS wrapper component that assumes webpack bundling. AVWC accepts comma-separated strings, arrays, or Promise-returning functions as its data source allowing developer flexibility for source implementation, and supports setting/overriding Awesomplete properties via VueJS component structure. AVWC also has a few additional features over core Awesomplete.
npm install awesomplete-vue-webpack-component
import AVWC from "awesomplete-vue-webpack-component";
Vue.component("avwc", AVWC);
<template>
<avwc :fill-list="DataSourcePromise" @selectcomplete="ItemSelected"></avwc>
</template>
<script>
export default {
methods: {
DataSourcePromise(userInputText) {
return Promise.resolve([ "Option 1", "Option 2", "Option 3" ]);
},
ItemSelected(awesompleteEvent) {
console.log(awesompleteEvent.text);
},
},
}
</script>
AVWC uses single-file component (.vue) design, and automatically imports the Awesomplete CSS.
{
module: {
rules: [
{ test: /\.css$/, use: [`style-loader`, `css-loader`] },
{ test: /\.vue$/, use: `vue-loader` },
]
}
}
For webpack 4+/compatiable vue-loader, VueLoaderPlugin usage is assumed to be configured correctly
The following props are recognized by AVWC.
Prop | Type | Notes |
---|---|---|
fill-list |
|
Awesomplete-compatible set of options |
Prop | Type | Notes |
---|---|---|
auto-first |
Boolean | Awesomplete's autoFirst property |
max-items |
Number |
|
min-chars |
Number |
|
Prop | Type | Notes |
---|---|---|
container |
Function | Override Awesomplete's container function |
filter |
Function | Override Awesomplete's filter function |
item |
Function | Override Awesomplete's item function |
replace |
Function |
|
sort |
|
Override Awesomplete's sort function |
Prop | Type | Notes |
---|---|---|
clear-on-close |
Boolean |
|
css-class |
String | One or more CSS classes to add to the Awesomplete block |
dropdown |
Boolean |
|
drop-down-css-class |
String | One or more CSS classes to add to the drop-down button |
initial-text |
String |
|
initial-text-evaluate |
Boolean |
|
initial-text-select |
|
|
input-css-class |
String | One or more CSS classes to add to the text input element |
ms-throttle |
Number |
|
placeholder |
|
|
replace-selection-with |
String |
|
striped |
Boolean | Add a .striped CSS class to Awesomplete with a default striping color scheme applied |
All five currently existing Awesomplete events are mapped to the VueJS event emitter without the awesomplete- prefix
Awesomplete Event | AVWC Emitted Event |
---|---|
awesomplete-close |
close |
awesomplete-highlight |
highlight |
awesomplete-open |
open |
awesomplete-select |
select |
awesomplete-selectcomplete |
selectcomplete |
AVWC emits objects as events after initialization
Emitted Event | Description |
---|---|
awesomplete-object | The Awesomplete object |
ref-input | The text input element |
ref-dropdown-button | The dropdown button (only when dropdown is enabled) |
AVWC provides CSS classes on its UI elements
- AVWC is wrapped in a
<span />
with an.avwc-container
class - The input element has an
.avwc-entry
class - The drop-down button has an
.avwc-dropdown
class
Additionally, as noted above, the following props can be used to set additional CSS classes on each UI element
css-class
drop-down-css-class
input-css-class
Awesomplete Vue webpack Component is released under the MIT License. See License file for more details.
Pull requests will be considered provided they follow existing code's styling, and are well commented.