All Projects → moroshko → Autosuggest Highlight

moroshko / Autosuggest Highlight

Licence: mit
Utilities for highlighting text in autosuggest and autocomplete components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Autosuggest Highlight

React Autosuggest
WAI-ARIA compliant React autosuggest component
Stars: ✭ 5,773 (+3180.11%)
Mutual labels:  autocomplete, typeahead, autosuggest
Autosuggest Trie
Minimalistic trie implementation for autosuggest and autocomplete components
Stars: ✭ 22 (-87.5%)
Mutual labels:  autocomplete, typeahead, autosuggest
React Autowhatever
Accessible rendering layer for Autosuggest and Autocomplete components
Stars: ✭ 146 (-17.05%)
Mutual labels:  autocomplete, typeahead, autosuggest
React Input Enhancements
Set of enhancements for input control
Stars: ✭ 1,375 (+681.25%)
Mutual labels:  autocomplete, typeahead, autosuggest
Vue Autosuggest
🔍 Vue autosuggest component.
Stars: ✭ 492 (+179.55%)
Mutual labels:  autocomplete, typeahead, autosuggest
react-abstract-autocomplete
Bring-Your-Own-UI autocomplete / mentions component for React.
Stars: ✭ 15 (-91.48%)
Mutual labels:  autocomplete, typeahead, autosuggest
Svelte Select
A select component for Svelte apps
Stars: ✭ 414 (+135.23%)
Mutual labels:  autocomplete, typeahead
Accessible Autocomplete
An autocomplete component, built to be accessible.
Stars: ✭ 474 (+169.32%)
Mutual labels:  autocomplete, typeahead
Jquery Typeahead
Javascript Typeahead (autocomplete) plugin with more than 50 options and callbacks.
Stars: ✭ 527 (+199.43%)
Mutual labels:  autocomplete, typeahead
Vue Simple Suggest
Feature-rich autocomplete component for Vue.js
Stars: ✭ 324 (+84.09%)
Mutual labels:  autocomplete, autosuggest
Zsh Autocomplete
🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
Stars: ✭ 641 (+264.2%)
Mutual labels:  autocomplete, typeahead
React Input Tags
React component for tagging inputs.
Stars: ✭ 10 (-94.32%)
Mutual labels:  autocomplete, autosuggest
Jquery Autocomplete
Ajax Autocomplete for jQuery allows you to easily create autocomplete/autosuggest boxes for text input fields
Stars: ✭ 3,461 (+1866.48%)
Mutual labels:  autocomplete, autosuggest
Autocomplete
🔮 Fast and full-featured autocomplete library
Stars: ✭ 1,268 (+620.45%)
Mutual labels:  autocomplete, typeahead
Zsh Autosuggestions
Fish-like autosuggestions for zsh
Stars: ✭ 19,697 (+11091.48%)
Mutual labels:  autocomplete, autosuggest
V Suggestions
Vue component for suggestions with custom templates
Stars: ✭ 42 (-76.14%)
Mutual labels:  autocomplete, autosuggest
React Selectrix
A beautiful, materialized and flexible React Select control
Stars: ✭ 166 (-5.68%)
Mutual labels:  autocomplete, autosuggest
autocompletex
redis autocomplete for elixir
Stars: ✭ 22 (-87.5%)
Mutual labels:  autocomplete, typeahead
Autocomplete
Accessible autocomplete component for vanilla JavaScript and Vue.
Stars: ✭ 277 (+57.39%)
Mutual labels:  autocomplete, typeahead
Bootstrap 4 Autocomplete
A simple autocomplete/typeahead for Bootstrap 4 and jQuery
Stars: ✭ 36 (-79.55%)
Mutual labels:  autocomplete, typeahead

Build Status Contributors Coverage Status

npm Downloads npm Version

Autosuggest Highlight

Utilities for highlighting text in autosuggest and autocomplete components.

Project status

Looking for maintainers!

Unfortunately, I don't have the time to maintain this project anymore. If you are interested to help, please reach out to me on Twitter @moroshko.

Installation

yarn add autosuggest-highlight

or

npm install autosuggest-highlight --save

API

Function Description
match(text, query) Calculates the characters to highlight in text based on query.
parse(text, matches) Breaks the given text to parts based on matches.

match(text, query)

Calculates the characters to highlight in text based on query.

It returns an array of pairs. Every pair [a, b] means that text.slice(a, b) should be highlighted.

Examples

We match only at the beginning of a word:

var match = require('autosuggest-highlight/match');

// text indices:     012345678
// highlighting:          vv
var matches = match('some text', 'te'); // [[5, 7]]
// text indices:     012345678
// highlighting:
var matches = match('some text', 'e'); // []

When query is a single word, only the first match is returned:

// text indices:     012345678901234
// highlighting:     v
var matches = match('some sweet text', 's'); // [[0, 1]]

You'll get the second match, if query contains multiple words:

// text indices:     012345678901234
// highlighting:     v    v
var matches = match('some sweet text', 's s'); // [[0, 1], [5, 6]]

Matches are case insensitive:

// text indices:     012345678
// highlighting:          v
var matches = match('Some Text', 't'); // [[5, 6]]

and diacritics are removed:

// text indices:     0123456
// highlighting:     vvvv
var matches = match('Déjà vu', 'deja'); // [[0, 4]]

When query has multiple words, the order doesn't matter:

// text indices:     012345678901234
// highlighting:     v      v
var matches = match('Albert Einstein', 'a e'); // [[0, 1], [7, 8]]
// text indices:     012345678901234
// highlighting:     v      v
var matches = match('Albert Einstein', 'e a'); // [[0, 1], [7, 8]]

parse(text, matches)

Breaks the given text to parts based on matches.

It returns an array of text parts by specifying whether each part should be highlighted or not.

For example:

var parse = require('autosuggest-highlight/parse');

// text indices:   0123456789012345
// highlighting:          vv   v
var parts = parse('Pretty cool text', [[7, 9], [12, 13]]);
/*
  [
    {
      text: 'Pretty ',
      highlight: false
    },
    {
      text: 'co',
      highlight: true
    },
    {
      text: 'ol ',
      highlight: false
    },
    {
      text: 't',
      highlight: true
    },
    {
      text: 'ext',
      highlight: false
    }
  ]
*/

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].