All Projects → bevacqua → Insignia

bevacqua / Insignia

Licence: mit
🔖 Customizable tag input. Progressive. No non-sense!

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Projects that are alternatives of or similar to Insignia

Horsey
🐴 Progressive and customizable autocomplete component
Stars: ✭ 1,146 (+72.33%)
Mutual labels:  component, autocomplete, front-end, vanilla
Rome
📆 Customizable date (and time) picker. Opt-in UI, no jQuery!
Stars: ✭ 2,901 (+336.24%)
Mutual labels:  component, front-end, vanilla
Dragula
👌 Drag and drop so simple it hurts
Stars: ✭ 21,011 (+3059.55%)
Mutual labels:  component, front-end, vanilla
Jkanban
Vanilla Javascript plugin for manage kanban boards
Stars: ✭ 664 (-0.15%)
Mutual labels:  component, vanilla
Woofmark
🐕 Barking up the DOM tree. A modular, progressive, and beautiful Markdown and HTML editor
Stars: ✭ 1,594 (+139.7%)
Mutual labels:  front-end, vanilla
React Input Tags
React component for tagging inputs.
Stars: ✭ 10 (-98.5%)
Mutual labels:  component, autocomplete
React Places Autocomplete
React component for Google Maps Places Autocomplete
Stars: ✭ 1,265 (+90.23%)
Mutual labels:  component, autocomplete
Egjs
Javascript components group that brings easiest and fastest way to build a web application in your way.
Stars: ✭ 871 (+30.98%)
Mutual labels:  component, front-end
React Autocomplete Input
Autocomplete input field for React
Stars: ✭ 100 (-84.96%)
Mutual labels:  component, autocomplete
Autocomplete
Blazing fast and lightweight autocomplete widget without dependencies. Only 1KB gzipped. Demo:
Stars: ✭ 244 (-63.31%)
Mutual labels:  component, autocomplete
vanilla-place-picker
Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android
Stars: ✭ 113 (-83.01%)
Mutual labels:  autocomplete, vanilla
Croppr.js
A vanilla JavaScript image cropper that's lightweight, awesome, and has absolutely zero dependencies.
Stars: ✭ 294 (-55.79%)
Mutual labels:  component, vanilla
Bunny
BunnyJS - Lightweight native (vanilla) JavaScript (JS) and ECMAScript 6 (ES6) browser library, package of small stand-alone components without dependencies: FormData, upload, image preview, HTML5 validation, Autocomplete, Dropdown, Calendar, Datepicker, Ajax, Datatable, Pagination, URL, Template engine, Element positioning, smooth scrolling, routing, inversion of control and more. Simple syntax and architecture. Next generation jQuery and front-end framework. Documentation and examples available.
Stars: ✭ 473 (-28.87%)
Mutual labels:  autocomplete, vanilla
Vue Tabs Component
An easy way to display tabs with Vue
Stars: ✭ 616 (-7.37%)
Mutual labels:  component
Elasticsuite
Smile ElasticSuite - Magento 2 merchandising and search engine built on ElasticSearch
Stars: ✭ 647 (-2.71%)
Mutual labels:  autocomplete
React Native Autocomplete Input
Pure javascript autocomplete input for react-native
Stars: ✭ 615 (-7.52%)
Mutual labels:  autocomplete
React Native Snackbar
🍱 Material Design "Snackbar" component for Android and iOS.
Stars: ✭ 613 (-7.82%)
Mutual labels:  component
Why Did You Render
why-did-you-render by Welldone Software monkey patches React to notify you about potentially avoidable re-renders. (Works with React Native as well.)
Stars: ✭ 7,695 (+1057.14%)
Mutual labels:  component
Zsh Autocomplete
🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
Stars: ✭ 641 (-3.61%)
Mutual labels:  autocomplete
Rsuite
🧱 A suite of React components .
Stars: ✭ 6,344 (+853.98%)
Mutual labels:  component

Insignia

Customizable tag input. Progressive. No non-sense!

Browser support includes every sane browser and IE7+.

Demo!

You can see a live demo here.

screenshot.png

Inspiration

I needed a tag input that was progressively enhanced, fast, easy to use, and reliable. Tag inputs I stumbled upon were too bloated, too dependant on JavaScript, or provided an unfriendly human experience.

The goal is to produce a framework-agnostic tag input editor that is easily integrated into your favorite MVC framework, that doesn't translate into a significant addition to your codebase, and that's enjoyable to work with. Insignia shares the modular design philosophy of Rome, the datetime picker.

Features

  • Small and focused
  • Natural keyboard navigation
  • Progressively enhanced
  • Extensive browser support

Install

You can get it on npm.

npm install insignia --save

Or bower, too.

bower install insignia --save

Usage

Insignia demands one thing of you: the input must have no siblings.

<div>
  <input id='insigificant' />
</div>

If client-side JavaScript never executes, because its disabled or too slow (on intermittent mobile network connections, for example), you should treat user input as a delimited list of tags. When JavaScript does execute, you should consider sending tags as a single string and splitting them on the server-side, for consistency.

insignia.find(input)

Retrieves a previously created instance of Insignia associated with the provided input. Returns null if none can be found.

insignia(input, options={})

Insignia exposes a function to turn an input into a tag list input. Empty spans will be added on both sides of your input element.

A few options may be provided. They are detailed below.

free

Defaults to true. When this flag is turned off, tags can't be edited by hand but they can still be deleted entirely using backspace. Tags would have to be added programmatically.

deletion

When true, humans will be able to delete individual tags by clicking on an icon.

delimiter

The separator between tags. Defaults to ' '. Must be a single character.

preventInvalid

This option will prevent tags identified as invalid from being added. By default this is turned off and they just get a nsg-invalid CSS class.

validate(value)

A method that validates whether the user input value constitutes a valid tag. Useful to filter out duplicates. Defaults to the method below, that does exactly that. Note that in the code below, toy is the API returned by calling insignia(el).

function validate (value) {
  return toy.findItem(value) === null;
}

Note that tags is only a copy and modifying it won't affect the list of tags.

render(container, item)

A method that's called whenever a tag should be rendered. Defaults to setting getText(item) as the container's text.

getText

When you have complex data items from autocomplete, you need to set getText to read the value that should be used as a display value.

getValue

When you have complex data items from autocomplete, you need to set getValue to read the value that should be used as each tag's value.

convertOnBlur

By default, tags are converted whenever the blur event fires on elements other than input. Set to false to disable.

Instance API

When you call insignia(input, options), you'll get back a tiny API to interact with the instance. Calling insignia repeatedly on the same DOM element will have no effect, and it will return the same API object.

.addItem(data)

Adds an item to the input. The data parameter could be a string or a complex object, depending on your instance configuration.

.findItem(data)

Finds an item by its data string or object.

.findItemIndex(data)

Return the index of the first item found by its data string or object.

.findItemByElement(el)

Finds an item by its .nsg-tag DOM element.

.removeItem(data)

Removes an item from the input. The item is found using the data string or object.

.removeItemByElement(el)

Removes an item from the input. The item is found using a .nsg-tag DOM element.

.value()

Returns the list of valid tags as an array.

.allValues()

Returns the list of tags as an array including invalid tags.

.refresh()

When changing the value of the el input by hand, call .refresh() to convert tags again.

.destroy()

Removes all event listeners, CSS classes, and DOM elements created by insignia. The input's value is set to the output of .value(). Once the instance is destroyed it becomes useless, and you'll have to call insignia(input, options) once again if you want to restore the behavior.

Instance Events

The instance API comes with a few events.

Event Arguments Description
add data, el Emitted whenever a new item is added to the list
remove data Emitted whenever an item is removed from the list
invalid data, el Emitted whenever an invalid item is added to the list

You can listen to these events using the following API.

const toy = insignia(el);
toy.on('add', data => console.log(data)); // listen to an event
toy.once('invalid', data => throw new Error('invalid data')); // listener discarded after one execution

toy.on('add', added);
toy.off('add', added); // removes `added` listener

function added (data) {
  console.log(data);
}

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].