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

@quigebo/tagger

v0.4.5

Published

Zero dependency, Vanilla JavaScript Tag Editor

Downloads

3

Readme

  _____
 |_   _|___ ___ ___ ___ ___
   | | | .'| . | . | -_|  _|
   |_| |__,|_  |_  |___|_|
           |___|___|   version 0.4.4

Tagger: Zero dependency, Vanilla JavaScript Tag Editor

npm

Tag Editor widget in JavaScript

Online Demo

Installation

npm install @jcubic/tagger

or

yarn add @jcubic/tagger

Usage

tagger(document.querySelector('[name="tags"]'), {allow_spaces: false});

Usage with React

Tagger can easily be used with ReactJS.

import { useRef, useState, useEffect } from 'react'
import tagger from '@jcubic/tagger'

function App() {
  const [tags, setTags] = useState(null)
  const inputRef = useRef(null)

  // Get current tags
  const getTags = () => {
    setTags(inputRef.current.value)
  }

  // Write the Tagger code inside a useEffect hook
  // It will run when the component is initially rendered
  useEffect(() => {
    // Define the Tagger options
    const taggerOptions = {
      allow_spaces: true,
    }

    // Initialize Tagger
    tagger(inputRef.current, taggerOptions)
  }, [])

  return (
    <div className='app'>
      <input type='text' defaultValue='charles, louis, michel' ref={inputRef} />
      <button onClick={getTags}>Get tags</button>

      {tags && <pre>{tags}</pre>}
    </div>
  )
}

export default App

API

methods:

  • add_tag(string): boolean
  • remove_tag(string): booelan
  • complete(string): void

Options:

  • wrap (default false) allow tags to wrap onto new lines instead of overflow scroll
  • allow_duplicates (default false)
  • allow_spaces (default true)
  • add_on_blur (default false)
  • completion {list: string[] | function(): Promise(string[])|string[], delay: miliseconds, min_length: number}
  • link function(name): string|false it should return what should be in href attribute or false
  • tag_limit number (default -1) limit number of tags, when set to -1 there are no limits

NOTE: if you're familiar with TypeScript you can check the API by looking at TypeScript definition file:

tagger.d.ts

Changelog

0.4.4

0.4.3

  • Fix completion on Safari #7

0.4.2

  • Fix autocomplete #22

0.4.1

  • fix typescript definition for completion

0.4.0

  • [Breaking] value in input no longer have space after comma
  • fix updating input when deleting tag using backspace
  • add option add_on_blur
  • add option tag_limit

0.3.1

  • fix npm package

0.3.0

  • add wrap option
  • fix remove_tag API
  • make settings optional
  • add typescript types

0.2.3

  • fix ambiguous tags

0.2.2

  • reject empty tags

0.2.1

  • Fix remove_tag when links are disabled

0.2.0

  • link option
  • working completion
  • allow to use querySelectorAll etc.

0.1.3

  • fix inialization in UMD

0.1.2

  • fix bug in adding tags

0.1.1

  • fix initalization of tags from input

0.1.0

  • initial version

License

Copyright (c) 2018-2022 Jakub T. Jankiewicz Released under the MIT license