Liya Gebre

Liya Gebre

1604670840

Feature-rich Autocomplete Component for Vue.js

vue-simple-suggest

Simple yet feature-rich autocomplete component for Vue.js

Install

npm install --save vue-simple-suggest

See installation guide for more options.

What is it

This is a simple yet feature-rich suggestion/autocomplete component for Vue.js.

Actually, it’s so feature rich, that it’s possible to do crazy stuff with it, like

  • Imitating drop-downs and drop-down menus
  • Turn suggestions list into an actual suggestions table
  • Work with ANY type of custom input passed (like type=button, radio and etc.)
  • … And many more things

And, as a bonus, it is very light.

Features

  • v-model support.
  • Automatic accessibility attributes (WAI-ARIA complete)
  • Switching v-model type (select/input).
  • Custom input element through default slot.
  • Custom list items through named scoped slots.
  • All HTML5-valid props for default input element are provided (type, tabindex and etc…).
  • Customizable keyboard controls.
  • Rich and simple API.
  • CSS classes for quick and easy restyling.
  • Many build variants to choose from.
  • Flexible and customizable component design.
  • Optional polyfills for IE importable from the lib.

All of the props, events and slots are OPTIONAL for this component, so it can be used without any configuration at all.

New features?

If you feel that something important is missing (or found a bug) - feel free to create an issue. :)


Examples:

To use the component just install via NPM:

npm install --save vue-simple-suggest

Then, in your Vue.js component/page do the following…

Simple example

If you need to suggest things from a static array:

<!-- Some component.vue -->
<template>
  <vue-simple-suggest
    v-model="chosen"
    :list="simpleSuggestionList"
    :filter-by-query="true">
<!-- Filter by input text to only show the matching results -->
  </vue-simple-suggest>

  <br>

  <p>Chosen element: {{ chosen }}</p>
</template>

<script>
  import VueSimpleSuggest from 'vue-simple-suggest'
  import 'vue-simple-suggest/dist/styles.css' // Optional CSS

  export default {
    components: {
      VueSimpleSuggest
    },
    data() {
      return {
        chosen: ''
      }
    },
    methods: {
      simpleSuggestionList() {
        return [
          'Vue.js',
          'React.js',
          'Angular.js'
        ]
      }
    }
  }
</script>

Async example

If you’re dealing with async data from server (example using https://swapi.co/):

<!-- Some component.vue -->
<template>
  <vue-simple-suggest
    v-model="chosen"
    display-attribute="name"
    value-attribute="url"
    :list="getSuggestionList"
  ></vue-simple-suggest>

  <br>

  <p>Chosen element: {{ chosen }}</p>
</template>

<script>
  import VueSimpleSuggest from 'vue-simple-suggest'
  import 'vue-simple-suggest/dist/styles.css' // Optional CSS

  export default {
    components: {
      VueSimpleSuggest
    },
    data() {
      return {
        chosen: ''
      }
    },
    methods: {
      // Function returning a promise as a factory for suggestion lists.
      //
      // vue-simple-suggest calls it automatically when an update to the list is needed,
      // no need for watchers here!
      getSuggestionList() {
        return fetch('https://swapi.co/api/people', { method: 'GET' })
          .then(response => response.json())
          .then(json => json.results); /*
          returns a promise with a list of star-wars characters
        */
      }
    }
  }
</script>

For a more advanced example (using wikipedia search) see our example source.


Installation

NPM

npm install --save vue-simple-suggest
# or
yarn add vue-simple-suggest

Unpkg

If including via this method - the component will automatically install itself.

<!-- UMD Component, async/await polyfills through promises -->
<script type="text/javascript" src="https://unpkg.com/vue-simple-suggest"></script>
<script type="text/javascript" src="https://unpkg.com/vue-simple-suggest@1.5.1"></script>
                                                              <!-- Specific version -->

<!-- CSS -->
<link rel="stylesheet" href="https://unpkg.com/vue-simple-suggest/dist/styles.css">

<!-- If you need polyfills, use IIFE verision below -->
<!-- IIFE build includes ALL polyfills: Object.assign, Promises, Generators, Async/Await! -->
<script type="text/javascript" src="https://unpkg.com/vue-simple-suggest/dist/iife.js"></script>

Importing

/// ESNext (original code, no pollyfills, single-file .vue component, css included)
import VueSimpleSuggest from 'vue-simple-suggest/lib'
///

/// ES6 (async polyfills)
import VueSimpleSuggest from 'vue-simple-suggest'
// or, if you have problems importing:
import VueSimpleSuggest from 'vue-simple-suggest/dist/es6'
///

/// ES7 and above (no polyfills)
import VueSimpleSuggest from 'vue-simple-suggest/dist/es7'
///

/// CommonJS (async, arrow-functions and promises are polyfilled)
const VueSimpleSuggest = require('vue-simple-suggest')
// or, if you have problems importing:
const VueSimpleSuggest = require('vue-simple-suggest/dist/cjs')
///

// Optional - import css separately with css loaders:
import 'vue-simple-suggest/dist/styles.css'
Polyfills

New in v1.8.3

vue-simple-suggest comes with minimal optional polyfills for IE11+ - Object.assign, Element.prototype.closest and Element.prototype.matches. You can import them like this:

import 'vue-simple-suggest/lib/polyfills';
// or
require('vue-simple-suggest/lib/polyfills');

Usage

Globaly:

// You don't need to do it, if including via <script> (umd, iife)
Vue.component('vue-simple-suggest', VueSimpleSuggest)

In single-file .vue components:

<script>
  import VueSimpleSuggest from 'vue-simple-suggest'
  import 'vue-simple-suggest/dist/styles.css' // Using a css-loader

  export default {
    components: {
      VueSimpleSuggest
    }
  }
</script>

Build Setup

# clone the repo
git clone https://github.com/KazanExpress/vue-simple-suggest.git
cd ./vue-simple-suggest

# install dependencies
npm install

# serve example with hot reload at localhost
npm run dev

# build example & readme for static serving
npm run docs

Default Controls

New in v1.2.0

These are default keyboard shortcuts.

Can be customized with the controls prop. All fields in this controls object are optional.

Default scheme:

Key (key code) Description
Escape (27) If the suggestions list is shown - hide it. Defined by hideList property.
ArrowDown (40) If the suggestions list is hidden - show it. Defined by showList property.
ArrowUp (38) / ArrowDown (40) Cycle (hover) through suggestions. Defined by selectionUp/selectionDown properties respectfully.
Enter (13) If the list is shown - chooses the highlighted element. Defined by select property.
(Ctrl/Shift) + Space (32) Select the first element in the list. Defined by autocomplete property. Works with Ctrl modifier key or Shift modifier key.
(Ctrl/Shift) + Enter (13) Same as previous, but also hides the suggestions list.

JS object:

{
  selectionUp: [38],
  selectionDown: [40],
  select: [13],
  showList: [40],
  hideList: [27],
  autocomplete: [32, 13]
}

Component API

TLDR

Click to expand

<!-- Ref to access the API, v-model for efficient query binding -->
<vue-simple-suggest ref="vueSimpleSuggest" v-model="model"
  value-attribute="id"
  display-attribute="title"
  mode="input"
  placeholder="placeholder!!!"
  :list="getListFunction"
  :max-suggestions="10"
  :min-length="3"
  :debounce="100"
  :destyled="false"
  :remove-list="false"
  :filter-by-query="false"
  :filter="customFilterFunction"
  :value="defaultValue"
  :nullable-select="true"
  :controls="{
    selectionUp: [38, 33],
    selectionDown: [40, 34],
    select: [13, 36],
    showList: [40],
    hideList: [27, 35],
    autocomplete: [32, 13],
  }"
  @input="onInputEvent"
  @select="onSuggestSelect"
  @hover="onSuggestHover"
  @focus="onFocus"
  @blur="onBlur"
  @request-start="onRequestStart"
  @request-done="onRequestDone"
  @request-failed="onRequestFailed"
  @show-list="onShowList"
  @hide-list="onHideList"
>
  <!-- v-model on input itself is useless -->
  <input class="optional-custom-input">

  <!-- Appears o top of the list -->
  <template slot="misc-item-above" slot-scope="{ suggestions, query }">
    <div class="misc-item">
      <span>You're searching for {{ query }}.</span>
    </div>
    <div class="misc-item">
      <span>{{ suggestions.length }} suggestions are shown...</span>
    </div>
    <hr>
  </template>

  <div slot="suggestion-item" slot-scope="{ suggestion }" class="custom">{{ suggestion.title }}</div>

  <!-- Appears below the list -->
  <div class="misc-item" slot="misc-item-below" slot-scope="{ suggestions }" v-if="loading">
    <span>Loading...</span>
  </div>
</vue-simple-suggest>

CSS class structure

If there’s a need to customize the appearance of the component, here’s the internal class-structure:

// .designed is applied only if `destyled` prop is false.
.vue-simple-suggest.designed.focus // .focus is applied whenever the component is focused.
  .input-wrapper
    .default-input // Replaced with your custom input if default slot is provided.
  .suggestions // Also has transition classes, see below.
    .suggest-item

If you wish to use your existing classes, or frameworks like Bootstrap you can inject your own classes using the 'styles' prop:

<!-- Some component.vue -->
<template>
  <vue-simple-suggest
    v-model="chosen"
    :list="simpleSuggestionList"
    :styles="autoCompleteStyle"
    :destyled=true
    :filter-by-query="true">
  </vue-simple-suggest>
</template>

<script>
  ...
  export default {
    ...
    data() {
      return {
        autoCompleteStyle : {
          vueSimpleSuggest: "position-relative",
          inputWrapper: "",
          defaultInput : "form-control",
          suggestions: "position-absolute list-group z-1000",
          suggestItem: "list-group-item"
        }
      }
    },
    ...
  }
</script>`

<style lang="scss">
.z-1000 {
  z-index: 1000;
}
.hover {
  background-color: #007bff;
  color: #fff;
}
</style>
Transitions

New in v1.8.0

You can also define custom list transitions by defining css rules for the transition named vue-simple-suggest on the .suggestions div:

.suggestions {
  /* It's improtant to have a cpecific pivot point for transition:*/
  opacity: 1;
}

.vue-simple-suggest-enter-active.suggestions,
.vue-simple-suggest-leave-active.suggestions {
  /* Transition length here:*/
  transition: opacity .2s;
}

.vue-simple-suggest-enter.suggestions,
.vue-simple-suggest-leave-to.suggestions {
  /* Transition rule for "disengaged" element:*/
  opacity: 0;
}

API definitions

Props
Name Type Default Description
controls v1.2.0 Object See default controls Determines the keyboard shortcuts in key-codes (for browser-compatibility purposes). Arrays provide the ability to assign multiple keys to one action. Consists of 5 array fields: selectionUp, selectionDown, select, hideList and autocomplete, all of which are optional.
max-suggestions Number 10 The maximum amount of suggestions to display. Set to 0 for infinite suggestions.
min-length Number 1 The minimum amount of symbols in input to trigger suggestion list. vue-simple-suggest starts behaving as a dropdown menu, if the value is 0.
display-attribute String 'title' The property in a suggestion object to display in a list. Supports dotted paths.
value-attribute String 'id' The property in a suggestion object to use as a unique key. Supports dotted paths.
list Function or Array () => [] The array provider function, must accept a query as its only argument. Can return an array or a promise. Can be async. The component behaves as a simple input without this function.
debounce Number 0 Determines the list debounce (a time between the input event and a function execution).
destyled Boolean false Whether to cancel the default styling of input and suggestions list.
styles v1.8.0 Object {} CSS classes to attach with current component style.
remove-list Boolean false If true - the suggestion list will be always hidden.
filter-by-query Boolean false Whether to filter the resulting suggestions by input’s text query (make it a search component).
filter Function - A custom function for filtering the suggestion results that accepts a single item and a query to filter by as its 2 arguments. Used only if filter-by-query is set to true.
mode v1.4.0 String 'input' The v-model event. Determines the event, that triggers v-model. Can be one of 'input' (v-model binds a displayed property) or 'select' (v-model binds a selected item).
type, value, pattern, etc… All of the HTML5 input attributes with their respected default values.
nullable-select v1.9.0 Boolean false Whether the select should accept null or not.
mode

New in v1.4.0

Determines the event, that triggers v-model. Can be one of 'input' (default) or 'select'.

For example, if 'input' is chosen - then v-model will update the value each time an input event is fired, setting the input’s string.

Same is for 'select' - v-model changes only when something is selected from the list, setting the selected value (string, object or whatever) to its argument.

A proper use-case for it being when one wants to use the component only for selection binding and custom input for text binding:

<vue-simple-suggest v-model="selected" mode="select">
  <input v-model="text">
</vue-simple-suggest>

Emitted Events
Name Arguments Description
input HTML input event An outward projection of the current input’s event.
focus HTML focus event An outward projection of the current input’s event.
blur HTML focus event An outward projection of the current input’s event.
select Selected suggestion Fires on suggestion selection (via a mouse click or enter keypress).
hover Hovered suggestion, target element Fires each time a new suggestion is highlighted (via a cursor movement or keyboard arrows).
suggestion-click Selected suggestion, HTML click event Fires on suggestion element click.
show-list - Fires each time the suggestion list is toggled to be shown.
hide-list - Fires each time the suggestion list is being hidden.
request-start Current input value (query) Fires each time a list function starts executing.
request-done Resulting suggestions list Fires when a list function successfully returns a result and forwards that result as an argument.
request-failed The interrrupting exception Fires if an exception occurs during the execution of a list funciton.

Ref Methods

accessed via $refs.*your ref name here*

Name Arguments Description
showList - Shows the suggestion list. Emits the respected event.
hideList - Hides the suggestion list. Emits the respected event.
getSuggestions query: string Gets and processes suggestions from the list prop. Returns a promise. Emits the requestStart, requestDone and requestFailed events.
research - Debounced getSuggestions on the current input value.
clearSuggestions - Clears the suggestions array.
select suggestion Selects the passed suggestion. Emits the respected event.
hover suggestion Hovers over the passed suggestion. Emits the respected event.
displayProperty suggestion Returns the displayed property of a suggestion.
valueProperty suggestion Returns the value property of a suggestion.
setText v1.9.0 text Reliably sets custom text to the input field.
autocompleteText v1.10.0 suggestion Autocompletes the input text using the suggestion passed as the only argument.

Ref Event Handlers

accessed via $refs.*your ref name here*

You can use these to imitate some of the component’s behaviours.

Name Arguments Description
onShowList Invoked when a suggestion list needs to be shown.
showSuggestions Shows suggestion list, refreshes the data if needed.
onInput HTML input event Invoked whenever the input text is changed. Emits the input event.
onFocus HTML focus event Invoked whenever the input comes into focus, emits the focus event.
onBlur HTML focus event Antonym to onFocus.
onAutocomplete - Invoked when the autocomplete keyboard shortcut is pressed. Selects the first suggestion.
onListKeyUp HTML keyup event Invoked on component keyup. Internally used for hiding the list.
onKeyDown HTML keydown event Invoked on component keydown. Internally used for showing the list, updating suggestions and preventing form submit.
moveSelection Invoked when hovered element needs to be changed.
suggestionClick suggestion, HTML click event Invoked on any suggestion click. Can be used to emulate such a click from ouside of the component.

Ref Data

accessed via $refs.*your ref name here*

Name Default Description
selected null Currently selected element.
hovered null Currently hovered element.
suggestions [] Current suggestions list.
textLength 0 Length of the text in the input.
listShown false Is suggestion list shown.
inputElement null Currently used HTMLInputElement.
canSend true Whether the assigned getListFuncion can be executed.
timeoutInstance null The timeout until next getListFunction execution.
text $props.value Current input text.
slotIsComponent false Whether this current custom input is a vue-component.
listIsRequest - Whether the list prop is a function.
input - A ref to the current input (component or vanilla).
hoveredIndex - The current hovered element index.
controlScheme Default Controls The current controls scheme.
isPlainSuggestion false Whether the current suggestions list consists of plain strings (not objects).
isClicking false true if the user currently clicks.
isOverList false true if the user currently hovers over suggestions list.
isInFocus false true if the component is currently in focus.
isTabbed false true if the user pressed tab, while the component is in focus.
isSelectedUpToDate false true if the user hasn’t done any inputs since the last selection, so the selection is still relevant.

Slots

Custom input

default slot (optional)

Supports nesting. Input props can be passed to a custom input to avoid their processing by vue-simple-suggest. Defaults to a simple input with props passed to vue-simple-suggest.

Warning: v-model on a custom input IS NOT the same as v-model on vue-simple-suggest!

<!--  Default HTMLInputElement example:  -->
<vue-simple-suggest v-model="model" placeholder="Text here" type="search" pattern="[a-z]+"/>
<!--  Vanilla HTMLInputElement example 1:  -->
<vue-simple-suggest>
  <input pattern="[a-z]+">
</vue-simple-suggest>
<!--  Vanilla HTMLInputElement example 2:  -->
<vue-simple-suggest v-model="model" placeholder="Text here" type="search">
</vue-simple-suggest>
<!--  Vanilla HTMLInputElement example 3 (fully equivalent to the second example):  -->
<vue-simple-suggest v-model="model">
  <input placeholder="Text here" type="search">
</vue-simple-suggest>
<!--  Vanilla HTMLInputElement example 4 (nested):  -->
<vue-simple-suggest v-model="model">
  <div>
    <section>
      <input type="email">
    </section>
  </div>
</vue-simple-suggest>
<!--  Vue component example (also supports nesting):  -->
<vue-simple-suggest v-model="vModelGoesHere">
  <my-custom-input-somponent :value="initialInputValueGoesHere"></my-custom-input-somponent>
</vue-simple-suggest>

Custom input component caveats:

To work with the vue-simple-suggest your custom input component has to follow certain standard behaviours.

Custom input component must (in order to work properly):

  • Emit an input event.
  • Emit focus and blur events.
  • Have a value prop.

Custom input component should (in order to avoid usage limitations):

  • Not stop any event propagations from internal input HTML element.
  • Forward an original event argument with focus and blur events.

If vue-simple-suggest with your custom component doesn’t seem to react to outside variable changes - bind both components’ v-model to the same variable, like so:

<vue-simple-suggest v-model="model">
  <my-custom-input-somponent v-model="model"></my-custom-input-somponent>
</vue-simple-suggest>
Accessibility on custom input

New in v1.9.0

vue-simple-suggest automatically injects 3 necessary ARIA attributes for the default <input> element and any custom input, as long as your custom input component contains an html <input> element.

These attributes ensure that the autocomplete can be used by users who rely on Screen Readers.

Name Value Description
aria-autocomplete "list" Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup.
aria-controls IDREF of suggestions list IDREF of the popup element that lists suggested values.
aria-activedescendant IDREF of hovered option Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element.
Custom suggestion item

suggestion-item slot (optional)

Description

Allows custom html-definitons of the suggestion items in a list. Defaults to <span>{{ displayAttribute(suggestion) }}</span>

Accepts the suggestion object and a query text as a slot-scope attribute values.

<!-- Example (book suggestions): -->
<vue-simple-suggest>
  <div slot="suggestion-item" slot-scope="{ suggestion, query }">
    <div>{{ suggestion.title }} by {{ suggestion.author }}</div>
  </div>
</vue-simple-suggest>

Custom buttons inside of suggestion items

If you want to add some action buttons to the suggetion items, just use the .stop directive modifier to prevent the default suggestion-click:

<!-- Example (editable book suggestion): -->
<vue-simple-suggest>
  <div slot="suggestion-item" slot-scope="{ suggestion, query }">
    <span>{{ suggestion.title }} by {{ suggestion.author }}</span>
    <button @click.stop="remove(suggestion)">remove from list</button>
    <button @click.stop="like(suggestion)">add to favorites</button>
  </div>
</vue-simple-suggest>

In this case, the buttons will ONLY execute the bound method and will not select the suggested item.

Manual autocomplete

If there’s a need to autocomplete the suggestion in the input instead of selecting it (like in mobile suggestions of google search), you can use the autocomplete() function in the slot’s scope:

<!-- Example: -->
<vue-simple-suggest>
  <div slot="suggestion-item" slot-scope="{ suggestion, autocomplete }">
    <span>{{ suggestion.title }} by {{ suggestion.author }}</span>
    <button @click.stop="autocomplete()">Complete input</button>
  </div>
</vue-simple-suggest>

or in the ref methods:

<template>
  <vue-simple-suggest ref="suggest">
    <div slot="suggestion-item" slot-scope="{ suggestion }">
      <span>{{ suggestion.title }} by {{ suggestion.author }}</span>
      <button @click.stop="onAutocompleteButtonClick(suggestion)">Complete input</button>
    </div>
  </vue-simple-suggest>
</template>

<script>
export default {
  //...
  methods: {
    onAutocompleteButtonClick(suggestion) {
      this.$refs.suggest.autocompleteText(suggestion);
    }
  }
  //...
}
</script>

Ref Data

In cooperation with ref fields this slot can be used to drastically transform the suggestion list behaviour.

One of the simplest examples - highlighting the query text in the results:

<div slot="suggestion-item" slot-scope="scope">
  <span v-html="boldenSuggestion(scope)"></span>
</div>
boldenSuggestion(scope) {
  if (!scope) return scope;

  const { suggestion, query } = scope;

  let result = this.$refs.suggestComponent.displayProperty(suggestion);

  if (!query) return result;

  const texts = query.split(/[\s-_/\\|\.]/gm).filter(t => !!t) || [''];
  return result.replace(new RegExp('(.*?)(' + texts.join('|') + ')(.*?)','gi'), '$1<b>$2</b>$3');
}

Result via Google Books search API:

Custom miscellanious item slots

misc-item-above and misc-item-below slots (optional)

Allow custom elements to be shown in suggestion list. These elements never dissapear from the list, neither can they be selected nor hovered on.

They can be used for decoration, loaders, error messages and etc.

These slots don’t have defaults, so they are not shown until defined.

Accept the suggestions array and a query text as a slot-scope attribute values.

<!-- Examples: -->
<vue-simple-suggest>
  <template slot="misc-item-above" slot-scope="{ suggestions, query }">
    <div class="misc-item">
      <span>You're searching for {{ query }}.</span>
    </div>
    <div class="misc-item">
      <span>{{ suggestions.length }} suggestions are shown...</span>
    </div>
  </template>

  <div slot="misc-item-below" slot-scope="{ suggestions }" v-if="isLoading" class="misc-item">
    <span>Loading...</span>
  </div>
</vue-simple-suggest>

These slots can also be used to handle empty results, like this:

<!-- Main slot template -->
<template slot="misc-item-above" slot-scope="{ suggestions, query }">
  <div class="misc-item">
    <span>You're searching for '{{ query }}'.</span>
  </div>

  <!-- Sub-template if have any suggestions -->
  <template v-if="suggestions.length > 0">
    <div class="misc-item">
      <span>{{ suggestions.length }} suggestions are shown...</span>
    </div>
    <hr>
  </template>

  <!-- Show "No result" otherwise, if not loading new ones -->
  <div class="misc-item" v-else-if="!loading">
    <span>No results</span>
  </div>
</template>

Download Details:

Author: KazanExpress

Demo: https://kazanexpress.github.io/vue-simple-suggest/

Source Code: https://github.com/KazanExpress/vue-simple-suggest

#vue #vuejs #javascript

What is GEEK

Buddha Community

Feature-rich Autocomplete Component for Vue.js
Ethan Hughes

Ethan Hughes

1578335505

Collection of Good Vue Autocomplete Components for Your Vue.js App

The Vue AutoComplete component helps users by providing a list of suggestions to select from as they type. It supports data binding, filtering, and more.

1. vue-suggestion

Suggestion list input for Vue.js, inspired by v-autocomplete.
Your search engine, your CSS, your everything…

vue-suggestion

Demo

Download


2. Accessible Autocomplete

Accessible autocomplete component for vanilla JavaScript and Vue.

Features

  • Accessible, with full support for ARIA attributes and keyboard interactions. Based on the WAI-ARIA Authoring Practices.
  • Available as a JavaScript or Vue component, with React coming soon.
  • Core package available if you want to bring your own rendering layer.
  • Customizable. Easily bring your own CSS, or take full control of the component rendering.
  • Support for asynchronous data fetching.

Autocomplete

Demo

Download


3. Select Auto-Complete

Provides a capability of auto-completed searching for results inside a select input field.

Select Auto-Complete

Download


4. vue-cool-select

Select with autocomplete, slots, bootstrap and material design themes.

Features

  • no dependencies
  • props (30) allow you to customize a component in a various ways
  • slots (13) allow content to be changed anywhere
  • events (8) will let you know about everything
  • autocomplete (you can use custom search, you can also disable the search input)
  • keyboard controls (not only through the arrows)
  • support on mobile devices
  • validation, state of error and success
  • disabled and readonly
  • small and large sizes (as in bootstrap)
  • the ability to set your styles, you can write theme from scratch. 2 themes: Bootstrap 4 (equal styles), Material Design
  • TypeScript support
  • tab navigation
  • SSR (Server-Side Rendering)
  • auto determine the suitable position for the menu if it goes beyond the viewport

vue-cool-select

Demo

Download


5. Vue Form Autocomplete - Simple

Vue Form Autocomplete Custom Component.

Able to use single or multiple select. Use scope slot to change the template

Vue Form Autocomplete - Simple

Demo and Download


6. Vue Tags Input

A simple tags input with typeahead built with Vue.js 2.

Vue Tags Input

Demo

Download


7. At.js for Vue.

At.js is An autocompletion library to autocomplete mentions, smileys etc.

  • Filter/Scroll/Insert/Delete
  • Keyboard/Mouse events
  • Plain-text based, no jQuery, no extra nodes
  • ContentEditable
  • Avatars, custom templates
  • Vue2
  • Vue1

At.js for Vue

Demo

Download


Thank for read!

#vue-autocomplete #autocomplete-component #autocomplete #vue-js #autocomplete-vue

Aria Barnes

Aria Barnes

1625232484

Why is Vue JS the most Preferred Choice for Responsive Web Application Development?

For more than two decades, JavaScript has facilitated businesses to develop responsive web applications for their customers. Used both client and server-side, JavaScript enables you to bring dynamics to pages through expanded functionality and real-time modifications.

Did you know!

According to a web development survey 2020, JavaScript is the most used language for the 8th year, with 67.7% of people choosing it. With this came up several javascript frameworks for frontend, backend development, or even testing.

And one such framework is Vue.Js. It is used to build simple projects and can also be advanced to create sophisticated apps using state-of-the-art tools. Beyond that, some other solid reasons give Vuejs a thumbs up for responsive web application development.

Want to know them? Then follow this blog until the end. Through this article, I will describe all the reasons and benefits of Vue js development. So, stay tuned.

Vue.Js - A Brief Introduction

Released in the year 2014 for public use, Vue.Js is an open-source JavaScript framework used to create UIs and single-page applications. It has over 77.4 million likes on Github for creating intuitive web interfaces.

The recent version is Vue.js 2.6, and is the second most preferred framework according to Stack Overflow Developer Survey 2019.

Every Vue.js development company is widely using the framework across the world for responsive web application development. It is centered around the view layer, provides a lot of functionality for the view layer, and builds single-page web applications.

Some most astonishing stats about Vue.Js:

• Vue was ranked #2 in the Front End JavaScript Framework rankings in the State of JS 2019 survey by developers.

• Approximately 427k to 693k sites are built with Vue js, according to Wappalyzer and BuiltWith statistics of June 2020.

• According to the State of JS 2019 survey, 40.5% of JavaScript developers are currently using Vue, while 34.5% have shown keen interest in using it in the future.

• In Stack Overflow's Developer Survey 2020, Vue was ranked the 3rd most popular front-end JavaScript framework.

Why is Vue.Js so popular?

• High-speed run-time performance
• Vue.Js uses a virtual DOM.
• The main focus is on the core library, while the collaborating libraries handle other features such as global state management and routing.
• Vue.JS provides responsive visual components.

Top 7 Reasons to Choose Vue JS for Web Application Development

Vue js development has certain benefits, which will encourage you to use it in your projects. For example, Vue.js is similar to Angular and React in many aspects, and it continues to enjoy increasing popularity compared to other frameworks.

The framework is only 20 kilobytes in size, making it easy for you to download files instantly. Vue.js easily beats other frameworks when it comes to loading times and usage.

Take a look at the compelling advantages of using Vue.Js for web app development.

#1 Simple Integration

Vue.Js is popular because it allows you to integrate Vue.js into other frameworks such as React, enabling you to customize the project as per your needs and requirements.

It helps you build apps with Vue.js from scratch and introduce Vue.js elements into their existing apps. Due to its ease of integration, Vue.js is becoming a popular choice for web development as it can be used with various existing web applications.

You can feel free to include Vue.js CDN and start using it. Most third-party Vue components and libraries are additionally accessible and supported with the Vue.js CDN.

You don't need to set up node and npm to start using Vue.js. This implies that it helps develop new web applications, just like modifying previous applications.

The diversity of components allows you to create different types of web applications and replace existing frameworks. In addition, you can also choose to hire Vue js developers to use the technology to experiment with many other JavaScript applications.

#2 Easy to Understand

One of the main reasons for the growing popularity of Vue.Js is that the framework is straightforward to understand for individuals. This means that you can easily add Vue.Js to your web projects.

Also, Vue.Js has a well-defined architecture for storing your data with life-cycle and custom methods. Vue.Js also provides additional features such as watchers, directives, and computed properties, making it extremely easy to build modern apps and web applications with ease.

Another significant advantage of using the Vue.Js framework is that it makes it easy to build small and large-scale web applications in the shortest amount of time.

#3 Well-defined Ecosystem

The VueJS ecosystem is vibrant and well-defined, allowing Vue.Js development company to switch users to VueJS over other frameworks for web app development.

Without spending hours, you can easily find solutions to your problems. Furthermore, VueJs lets you choose only the building blocks you need.

Although the main focus of Vue is the view layer, with the help of Vue Router, Vue Test Utils, Vuex, and Vue CLI, you can find solutions and recommendations for frequently occurring problems.

The problems fall into these categories, and hence it becomes easy for programmers to get started with coding right away and not waste time figuring out how to use these tools.

The Vue ecosystem is easy to customize and scales between a library and a framework. Compared to other frameworks, its development speed is excellent, and it can also integrate different projects. This is the reason why most website development companies also prefer the Vue.Js ecosystem over others.

#4 Flexibility

Another benefit of going with Vue.Js for web app development needs is flexibility. Vue.Js provides an excellent level of flexibility. And makes it easier for web app development companies to write their templates in HTML, JavaScript, or pure JavaScript using virtual nodes.

Another significant benefit of using Vue.Js is that it makes it easier for developers to work with tools like templating engines, CSS preprocessors, and type checking tools like TypeScript.

#5 Two-Way Communication

Vue.Js is an excellent option for you because it encourages two-way communication. This has become possible with the MVVM architecture to handle HTML blocks. In this way, Vue.Js is very similar to Angular.Js, making it easier to handle HTML blocks as well.

With Vue.Js, two-way data binding is straightforward. This means that any changes made by the developer to the UI are passed to the data, and the changes made to the data are reflected in the UI.

This is also one reason why Vue.Js is also known as reactive because it can react to changes made to the data. This sets it apart from other libraries such as React.Js, which are designed to support only one-way communication.

#6 Detailed Documentation

One essential thing is well-defined documentation that helps you understand the required mechanism and build your application with ease. It shows all the options offered by the framework and related best practice examples.

Vue has excellent docs, and its API references are one of the best in the industry. They are well written, clear, and accessible in dealing with everything you need to know to build a Vue application.

Besides, the documentation at Vue.js is constantly improved and updated. It also includes a simple introductory guide and an excellent overview of the API. Perhaps, this is one of the most detailed documentation available for this type of language.

#7 Large Community Support

Support for the platform is impressive. In 2018, support continued to impress as every question was answered diligently. Over 6,200 problems were solved with an average resolution time of just six hours.

To support the community, there are frequent release cycles of updated information. Furthermore, the community continues to grow and develop with backend support from developers.



Wrapping Up

VueJS is an incredible choice for responsive web app development. Since it is lightweight and user-friendly, it builds a fast and integrated web application. The capabilities and potential of VueJS for web app development are extensive.

While Vuejs is simple to get started with, using it to build scalable web apps requires professionalism. Hence, you can approach a top Vue js development company in India to develop high-performing web apps.

Equipped with all the above features, it doesn't matter whether you want to build a small concept app or a full-fledged web app; Vue.Js is the most performant you can rely on.

Original source

 

#vue js development company #vue js development company in india #vue js development company india #vue js development services #vue js development #vue js development companies

NBB: Ad-hoc CLJS Scripting on Node.js

Nbb

Not babashka. Node.js babashka!?

Ad-hoc CLJS scripting on Node.js.

Status

Experimental. Please report issues here.

Goals and features

Nbb's main goal is to make it easy to get started with ad hoc CLJS scripting on Node.js.

Additional goals and features are:

  • Fast startup without relying on a custom version of Node.js.
  • Small artifact (current size is around 1.2MB).
  • First class macros.
  • Support building small TUI apps using Reagent.
  • Complement babashka with libraries from the Node.js ecosystem.

Requirements

Nbb requires Node.js v12 or newer.

How does this tool work?

CLJS code is evaluated through SCI, the same interpreter that powers babashka. Because SCI works with advanced compilation, the bundle size, especially when combined with other dependencies, is smaller than what you get with self-hosted CLJS. That makes startup faster. The trade-off is that execution is less performant and that only a subset of CLJS is available (e.g. no deftype, yet).

Usage

Install nbb from NPM:

$ npm install nbb -g

Omit -g for a local install.

Try out an expression:

$ nbb -e '(+ 1 2 3)'
6

And then install some other NPM libraries to use in the script. E.g.:

$ npm install csv-parse shelljs zx

Create a script which uses the NPM libraries:

(ns script
  (:require ["csv-parse/lib/sync$default" :as csv-parse]
            ["fs" :as fs]
            ["path" :as path]
            ["shelljs$default" :as sh]
            ["term-size$default" :as term-size]
            ["zx$default" :as zx]
            ["zx$fs" :as zxfs]
            [nbb.core :refer [*file*]]))

(prn (path/resolve "."))

(prn (term-size))

(println (count (str (fs/readFileSync *file*))))

(prn (sh/ls "."))

(prn (csv-parse "foo,bar"))

(prn (zxfs/existsSync *file*))

(zx/$ #js ["ls"])

Call the script:

$ nbb script.cljs
"/private/tmp/test-script"
#js {:columns 216, :rows 47}
510
#js ["node_modules" "package-lock.json" "package.json" "script.cljs"]
#js [#js ["foo" "bar"]]
true
$ ls
node_modules
package-lock.json
package.json
script.cljs

Macros

Nbb has first class support for macros: you can define them right inside your .cljs file, like you are used to from JVM Clojure. Consider the plet macro to make working with promises more palatable:

(defmacro plet
  [bindings & body]
  (let [binding-pairs (reverse (partition 2 bindings))
        body (cons 'do body)]
    (reduce (fn [body [sym expr]]
              (let [expr (list '.resolve 'js/Promise expr)]
                (list '.then expr (list 'clojure.core/fn (vector sym)
                                        body))))
            body
            binding-pairs)))

Using this macro we can look async code more like sync code. Consider this puppeteer example:

(-> (.launch puppeteer)
      (.then (fn [browser]
               (-> (.newPage browser)
                   (.then (fn [page]
                            (-> (.goto page "https://clojure.org")
                                (.then #(.screenshot page #js{:path "screenshot.png"}))
                                (.catch #(js/console.log %))
                                (.then #(.close browser)))))))))

Using plet this becomes:

(plet [browser (.launch puppeteer)
       page (.newPage browser)
       _ (.goto page "https://clojure.org")
       _ (-> (.screenshot page #js{:path "screenshot.png"})
             (.catch #(js/console.log %)))]
      (.close browser))

See the puppeteer example for the full code.

Since v0.0.36, nbb includes promesa which is a library to deal with promises. The above plet macro is similar to promesa.core/let.

Startup time

$ time nbb -e '(+ 1 2 3)'
6
nbb -e '(+ 1 2 3)'   0.17s  user 0.02s system 109% cpu 0.168 total

The baseline startup time for a script is about 170ms seconds on my laptop. When invoked via npx this adds another 300ms or so, so for faster startup, either use a globally installed nbb or use $(npm bin)/nbb script.cljs to bypass npx.

Dependencies

NPM dependencies

Nbb does not depend on any NPM dependencies. All NPM libraries loaded by a script are resolved relative to that script. When using the Reagent module, React is resolved in the same way as any other NPM library.

Classpath

To load .cljs files from local paths or dependencies, you can use the --classpath argument. The current dir is added to the classpath automatically. So if there is a file foo/bar.cljs relative to your current dir, then you can load it via (:require [foo.bar :as fb]). Note that nbb uses the same naming conventions for namespaces and directories as other Clojure tools: foo-bar in the namespace name becomes foo_bar in the directory name.

To load dependencies from the Clojure ecosystem, you can use the Clojure CLI or babashka to download them and produce a classpath:

$ classpath="$(clojure -A:nbb -Spath -Sdeps '{:aliases {:nbb {:replace-deps {com.github.seancorfield/honeysql {:git/tag "v2.0.0-rc5" :git/sha "01c3a55"}}}}}')"

and then feed it to the --classpath argument:

$ nbb --classpath "$classpath" -e "(require '[honey.sql :as sql]) (sql/format {:select :foo :from :bar :where [:= :baz 2]})"
["SELECT foo FROM bar WHERE baz = ?" 2]

Currently nbb only reads from directories, not jar files, so you are encouraged to use git libs. Support for .jar files will be added later.

Current file

The name of the file that is currently being executed is available via nbb.core/*file* or on the metadata of vars:

(ns foo
  (:require [nbb.core :refer [*file*]]))

(prn *file*) ;; "/private/tmp/foo.cljs"

(defn f [])
(prn (:file (meta #'f))) ;; "/private/tmp/foo.cljs"

Reagent

Nbb includes reagent.core which will be lazily loaded when required. You can use this together with ink to create a TUI application:

$ npm install ink

ink-demo.cljs:

(ns ink-demo
  (:require ["ink" :refer [render Text]]
            [reagent.core :as r]))

(defonce state (r/atom 0))

(doseq [n (range 1 11)]
  (js/setTimeout #(swap! state inc) (* n 500)))

(defn hello []
  [:> Text {:color "green"} "Hello, world! " @state])

(render (r/as-element [hello]))

Promesa

Working with callbacks and promises can become tedious. Since nbb v0.0.36 the promesa.core namespace is included with the let and do! macros. An example:

(ns prom
  (:require [promesa.core :as p]))

(defn sleep [ms]
  (js/Promise.
   (fn [resolve _]
     (js/setTimeout resolve ms))))

(defn do-stuff
  []
  (p/do!
   (println "Doing stuff which takes a while")
   (sleep 1000)
   1))

(p/let [a (do-stuff)
        b (inc a)
        c (do-stuff)
        d (+ b c)]
  (prn d))
$ nbb prom.cljs
Doing stuff which takes a while
Doing stuff which takes a while
3

Also see API docs.

Js-interop

Since nbb v0.0.75 applied-science/js-interop is available:

(ns example
  (:require [applied-science.js-interop :as j]))

(def o (j/lit {:a 1 :b 2 :c {:d 1}}))

(prn (j/select-keys o [:a :b])) ;; #js {:a 1, :b 2}
(prn (j/get-in o [:c :d])) ;; 1

Most of this library is supported in nbb, except the following:

  • destructuring using :syms
  • property access using .-x notation. In nbb, you must use keywords.

See the example of what is currently supported.

Examples

See the examples directory for small examples.

Also check out these projects built with nbb:

API

See API documentation.

Migrating to shadow-cljs

See this gist on how to convert an nbb script or project to shadow-cljs.

Build

Prequisites:

  • babashka >= 0.4.0
  • Clojure CLI >= 1.10.3.933
  • Node.js 16.5.0 (lower version may work, but this is the one I used to build)

To build:

  • Clone and cd into this repo
  • bb release

Run bb tasks for more project-related tasks.

Download Details:
Author: borkdude
Download Link: Download The Source Code
Official Website: https://github.com/borkdude/nbb 
License: EPL-1.0

#node #javascript

sophia tondon

sophia tondon

1618971133

Top 10 VueJS Development Companies To Know In 2021-22

Vue.js is one of the most used and popular frontend development, or you can say client-side development framework. It is mainly used to develop single-page applications for both web and mobile. Famous companies like GitLab, NASA, Monito, Adobe, Accenture are currently using VueJS.

Do You Know?

Around 3079 companies reportedly use Vue.js in their tech stacks.
At GitHub, VueJS got 180.9K GitHub stars, including 28.5K GitHub forks.
Observing the increasing usage of VueJS and its robust features, various industry verticals are preferring to develop the website and mobile app Frontend using VueJS, and due to this reason, businesses are focusing on hiring VueJS developers from the top Vue.js development companies.

But the major concern of the enterprises is how to find the top companies to avail leading VueJS development service? Let’s move further and know what can help you find the best VueJS companies.

Read More - https://www.valuecoders.com/blog/technology-and-apps/top-10-vuejs-development-companies/

#hire vue js developer #hire vue.js developers #hire vue.js developer, #hire vue.js developers, #vue js development company #vue.js development company

Luna  Mosciski

Luna Mosciski

1600583123

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.

This framework was created by Evan You and still it is maintained by his private team members. Vue is of course an open-source framework which is based on MVVM concept (Model-view view-Model) and used extensively in building sublime user-interfaces and also considered a prime choice for developing single-page heavy applications.

Released in February 2014, Vue JS has gained 64,828 stars on Github, making it very popular in recent times.

Evan used Angular JS on many operations while working for Google and integrated many features in Vue to cover the flaws of Angular.

“I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight." - Evan You

#vuejs #vue #vue-with-laravel #vue-top-story #vue-3 #build-vue-frontend #vue-in-laravel #vue.js