A Simple Autocomplete input Built using Vue.JS & Typescript

A Simple Autocomplete input Built using Vue.JS & Typescript

A simple autocomplete input πŸ”¨ built using Vue.JS & Typescript

vue-simple-complete

https://github.com/rohitkvv/vue-simple-complete/releases/tag/1.2.0

Description

A simple autocomplete input πŸ”¨ built using Vue.JS & Typescript

Project setup

yarn add vue-simple-complete

npm i vue-simple-complete

<script>
  import VueSimpleComplete from "vue-simple-complete";

  export default {
    name: 'app',
    data() {
    },
    components: {
      VueSimpleComplete
    },
  };
</script>

Wiki

Props Type Description
:items Array This contains data for the auto-complete, this can either be an array of string or an array of custom objects
:objectMatchkey String This is required if the items is of type object array. The objectMatchKey then becomes the key that is used within the match function
:template Object This is required if the items is of type object array. The template is then used to display the items as per the defined template. If the template is not defined then ObjectMatchKey will be used to form the items display
Function Type Description
@inputChanged Function When input is changed this event gets fired. The consumers of the vue-simple-complete component can listen to this event and get the entered or selected value

** πŸ“„ Additional Info**:

  • The component comes with a basic styling, and the items panel usually takes the full width of the container it's placed in. To contain it's width, it can be wrapped within a div with custom width.
  • Up & Down keys can be used to go over the items in the list.
  • Down key can be used to open the items panel, when the panel is collapsed.
  • Esc key will clear out the selected value when the focus is on the input

Example-1: With items of Object type

<vue-simple-complete
        :items="items"
        :objectMatchkey="objectMatchkey"
        :template="template"
        @inputChanged="onInputChanged">
</vue-simple-complete>

<script>
  import VueSimpleComplete from "vue-simple-complete";

  export default {
    name: 'app',
    components: {
      "vue-simple-complete": VueSimpleComplete
    },
    data() {
        return {
            items: [
                { Id: 1, Name: "Amsterdam" },
                { Id: 2, Name: "Berlin" },
                { Id: 3, Name: "London" },
                { Id: 4, Name: "Mumbai" }
            ],
            objectMatchkey: "Name",
            template: {
                keys: ["Id", "Name"],
                separator: ", "
            },
            changedInput: ""
        };
    },
    methods: {
        onInputChanged(value) {
            this.changedInput = value;
        }
    }
  };
</script>

ObjectImage1 ObjectImage2 ObjectImage3

Example-2: With items of string type

<vue-simple-complete
        :items="items"
        @inputChanged="onInputChanged">
</vue-simple-complete>

<script>
  import VueSimpleComplete from "vue-simple-complete";

  export default {
    name: 'app',
    components: {
      "vue-simple-complete": VueSimpleComplete
    },
    data() {
        return {
            items: [
                "Amsterdam",
                "Berlin",
                "London",
                "Mumbai"
            ],
            changedInput: ""
        };
    },
    methods: {
        onInputChanged(value) {
            this.changedInput = value;
        }
    }
  };
</script>

StringImage1 StringImage2 StringImage3

Note:

There is a known issue where you will see the following error when you import the component into a TypeScript project

Could not find a declaration file for module 'vue-simple-complete'.
Try `npm install @types/vue-simple-complete` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-simple-complete';`

As a temporary solution, please edit your TypeScript Config file (tsconfig.json) and add a new key value pair, as -


"noImplicitAny": false

Download Details:

Author: rohitkvv

Source Code: https://github.com/rohitkvv/vue-simple-complete

vue vuejs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework. Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

Vue Native is a framework to build cross platform native mobile apps using JavaScript

Vue Native is a framework to build cross platform native mobile apps using JavaScript. It is a wrapper around the APIs of React Native. So, with Vue Native, you can do everything that you can do with React Native. With Vue Native, you get

How to Make a Simple Vue Custom Select Component

In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault, and you can see it in action on the playground.

Creating a Custom Tooltip Component in Vue

There are plenty of libraries out there that will have you up and running with a good tooltip solution in minutes. However, if you are like me, you are sick and tired of giant dependency trees that have the distinct possibility of breaking at any time.

Vue ShortKey plugin for Vue.js

Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.