npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

t-i-b

v2.2.5

Published

Better tags input interaction with JavaScript.

Downloads

5

Readme

Simplest Tags Input Beautifier

Better tags input interaction with JavaScript.

What is this?

Demo

Image

→ https://tovic.github.io/tags-input-beautifier

Got it?

Usage

<!DOCTYPE html>
<html dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Demo</title>
    <link href="tags-input-beautifier.min.css" rel="stylesheet">
  </head>
  <body>
    <input name="tags" type="text">
    <script src="tags-input-beautifier.min.js"></script>
    <script>
    var tags = new TIB(document.querySelector('input[name="tags"]'));
    </script>
  </body>
</html>

Options

var tags = new TIB(source, config);

Variable | Description -------- | ----------- source | The text input element you want to beautify. config | The configuration data. See below!

config = {
    join: ', ', // Tags joiner of the output value
    max: 9999, // Maximum tags allowed
    escape: [','], // List of character(s) used to trigger the tag addition
    pattern: false, // Custom pattern to filter the tag name [^1]
    placeholder: false, // Custom tags input placeholder [^2]
    alert: true,
    text: ['Delete \u201C%s%\u201D', 'Duplicate \u201C%s%\u201D', 'Please match the requested format: %s%'],
    classes: ['tags', 'tag', 'tags-input', 'tags-output', 'tags-view'], // HTML classes
    update: function() {} // Hook that will be triggered on every tags item update
};

// [^1]: Or simply use `data-pattern` attribute of `source` element.
// [^2]: Or simply use `data-placeholder` or `placeholder` attribute of `source` element.

Methods

Initiation

var tags = new TIB( … );

Get Current Tags Data

console.log(tags.tags);

Get Fake Tags Input Element

console.log(tags.input);

Get Tags View HTML Element

console.log(tags.self);

Get Original Tags Input Element

console.log(tags.output);

Get Configuration Data

console.log(tags.config);

Remove All Tags

tags.reset();

Remove bar Tag

tags.reset('bar');

Refresh Tags Value

tags.update();

Merge new values to the current values:

tags.update(['foo', 'bar', 'baz']);

Sanitize Tag Name

Create custom tag input sanitizer:

tags.filter = function(text) {
    text = text.replace(/^\s+|\s+$/g, ""); // trim white-space(s)
    text = text.replace(/,/g, ""); // disallow `,` in tag name
    text = text.toLowerCase(); // force lower-case letter(s)
    return text;
};

Add bar Tag

tags.set('bar');

Check for Duplicate Tag Name

if (tags.tags['bar']) {
    alert('Duplicate `bar` !!!')
}

Check for Tags Length

console.log(Object.keys(tags.tags).length);

Playground

  • http://codepen.io/tovic/pen/ZQewJq