
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
vue3-simple-typeahead
Advanced tools
A simple and lightweight Vue3 typeahead component that show a suggested list of elements while the user types in.
A Vue3 component for a simple typeahead component. It will show a list of suggested items based on the user input.
The component includes it's own input and when the user types on it the suggested options appear.
npm install vue3-simple-typeahead
You can also use the browser bundle in a script tag.
<script src="https://unpkg.com/vue3-simple-typeahead"></script>
Import the vue3-simple-typeahead component and register it globally in your Vue app. Import the CSS as well if you wish to use the default styling.
import { createApp } from 'vue';
import App from './App.vue';
import SimpleTypeahead from 'vue3-simple-typeahead';
import 'vue3-simple-typeahead/dist/vue3-simple-typeahead.css'; //Optional default CSS
let app = createApp(App);
app.use(SimpleTypeahead);
app.mount('#app');
You can also import vue3-simple-typeahead locally in your component if you prefer.
import SimpleTypeahead from 'vue3-simple-typeahead'
import 'vue3-simple-typeahead/dist/vue3-simple-typeahead.css' //Optional default CSS
export default {
name: 'my-vue-component',
...
components: {
SimpleTypeahead
}
...
}
Use the component on your own app components
<vue3-simple-typeahead
id="typeahead_id"
placeholder="Start writing..."
:items="['One','Two','Three',...]"
:minInputLength="1"
:itemProjection="itemProjectionFunction"
@selectItem="selectItemEventHandler"
@onInput="onInputEventHandler"
@onFocus="onFocusEventHandler"
@onBlur="onBlurEventHandler"
>
</vue3-simple-typeahead>
With custom slots template
<vue3-simple-typeahead
id="typeahead_id"
placeholder="Start writing..."
:items="['One','Two','Three',...]"
:minInputLength="1"
:itemProjection="itemProjectionFunction"
@selectItem="selectItemEventHandler"
@onInput="onInputEventHandler"
@onFocus="onFocusEventHandler"
@onBlur="onBlurEventHandler"
>
<template #list-header>
LIST HEADER
</template>
<template #list-item-text="slot"><span v-html="slot.boldMatchText(slot.itemProjection(slot.item))"></span></template>
<template #list-footer>
LIST FOOTER
</template>
</vue3-simple-typeahead>
When the user types on the typeahead input and the minimum input length is meeted a suggestion list appears below the input with the items that match the user input. You can continue to type further to filter the selection, but you could use keyboard or mouse input to make your selection.abnf
When the suggestion list show up, you can continue to type to filter the selection or you use the Arrow Up
↑ or Arrow Down
↓ keys to navigate the list of suggestions. When you have selected the desired element press Enter or TAB to select the current element.
Control | Effect |
---|---|
↑ | Navigate up on the suggestion list, selecting the previous element |
↓ | Navigate down on the suggestion list, selecting the next element |
Enter | Choose the current element selection |
TAB | Choose the current element selection |
You can use the mouse instead, simply hover you cursor over the desire element and click on it.
Prop | Type | Default | Description |
---|---|---|---|
id | String | Random id generation | The id for the input control. Can be useful to link with a label for="" |
placeholder | String | '' | Placeholder text for the input |
items | Array (Required) | List of objects or strings with the elements for suggestions | |
minInputLength | Number | 2 | Minimum input length for the suggestion length to appear, the prop value has to be >= 0 |
itemProjection | Function: String | (item) => {return item;} | Projection function to map the items to a string value for search and display |
Remember you can always use lower-kebap-case for camelCase props like min-input-length
Event | Signature | Description |
---|---|---|
selectItem | function (item: String): void | Emitted when the user selects an item from the suggestion list |
onInput | function (event: Object { input: String, items: Array }): void | Emitted when the user types anything |
onFocus | function (event: Object { input: String, items: Array }): void | Emitted when the input control get the focus |
onBlur | function (event: Object { input: String, items: Array }): void | Emitted when the input control lost the focus [When the user select an item, the focus is lost too] |
Prop | Parent | Props | Description |
---|---|---|---|
#list-header | div.simple-typeahead-list-header | Slot to be show at top of the suggestion list | |
#list-item-text | span.simple-typeahead-list-item-text' | Slot to customize the text of every item in the suggestion list | |
#list-footer | div.simple-typeahead-list-footer | item , itemProjection , boldMatchText | Slot to be show at bottom of the suggestion list |
#list-footer
propsProp | Type | Description |
---|---|---|
item | String or Object | The item of the items array |
itemProjection | function | Use the item projection function provided as prop to the vue3-simple-typeahead element |
boldMatchText | function | A function that receives a string and add strong tags to the parts of the text matched by the search criteria |
Overwrite styles when using the default css included or add custom styles basing your rules on this structure.
div#{:id}_wrapper.simple-typeahead
input#{:id}.simple-typeahead-input
div.simple-typeahead-list
.simple-typeahead-list-header
.simple-typeahead-list-item &.simple-typeahead-list-item-active
.simple-typeahead-list-item-text
.simple-typeahead-list-footer
FAQs
A simple and lightweight Vue3 typeahead component that show a suggested list of elements while the user types in.
The npm package vue3-simple-typeahead receives a total of 2,937 weekly downloads. As such, vue3-simple-typeahead popularity was classified as popular.
We found that vue3-simple-typeahead demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.