Giter Club home page Giter Club logo

kompletr's Introduction

JS autocompletion library - Kømpletr

Logo Kømpletr light Logo Kømpletr dark

10kb of vanilla lightweight for a simple & efficient autocomplete

Github action workflow status GitHub Release CodeFactor Coverage Status GPL Licence JsDelivr Statistics

Features

  • ✅ Sync / async querying
  • ✅ Cache management
  • ✅ Keyboard navigation
  • ✅ Flexible research (begining, whole word or ... on your own)
  • ✅ Flexible suggestions display (1, 2, 3, ... fields)
  • ✅ Support string or object values
  • ✅ No dependencies
  • ✅ 10kb fully included

Installation

Package manager

$ npm i kompletr --save

Direct download

  1. Download latest release archive
  2. Get JS files from ./dist/js/.js*
  3. Get CSS files from ./dist/css/.css*

Getting started

Load Kømpletr assets:

...
<link href="kompletr.min.css" rel="stylesheet" type="text/css" />
<script src="kompletr.min.js" type="module"></script>
...

Define input element:

<input type="text" id="auto-complete" autocomplete="off" placeholder="Whatever you want..." />

Invoke Kømpletr:

kompletr({
  input: 'auto-complete',
  data: [],
  onSelect: (selected) => {
    console.log('There is the selected value', selected);
  }
});

Options

  • fieldsToDisplay: string[], properties to display in the suggestion field when suggestions are Objects
  • mapPropertyAsValue: string, property to map as input value when the suggestions are Objects
  • filterOn: string, check expression from beginning of the value or on the whole word. Default 'prefix'
  • startQueryingFromChar: int, number of chars completed in input before kompletr fire search
  • maxResults: int, number of max results to display
  • onKeyup: function(value), callback fired each time the user press a keyboard touch
  • onSelect: function(selected), callback fired after selection of on result item
  • onError: function(error), callback fired when an error occurs

Licence

GPL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.