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

auto-textfiller

v0.1.1

Published

This is a react atuocomplete component with a built in input box.

Downloads

7

Readme

This is a react atuocomplete component with a built in input box.

Guide

This component takes a total of 4 props, 2 mandatory and rest optional. The props are,

  1. suggestions: This is the array of items to be suggested. This can be primitive array of strings such as

        const suggestions = ['mango', 'apple', 'strawberry'];

    but the detailed object format would be,

        const suggestions = [
            {
              id: 'bgd',
              text: 'Bangladesh',
              sub: 'South Asia',
                img: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Flag_of_Bangladesh.svg/1200px-Flag_of_Bangladesh.svg.png'
            },
            {
              id: 'ind',
              text: 'India',
              sub: 'South Asia',
              img: 'https://upload.wikimedia.org/wikipedia/en/thumb/4/41/Flag_of_India.svg/1200px-Flag_of_India.svg.png'
            },
            {
              id: 'pks',
              text: 'Pakistan',
              sub: 'South Asia',
              img: 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSJTlfUBGgU7BcdQRBaSSR7ttosxQ25mU-big&usqp=CAU'
            }
        ]

    here, text: the primnary text displayed in bold sub: secondary text, shown in gray, optional img: link to the logo, optional id: whenever an item is selected, the dropdown closes automatically, displays the selected title in the input returns the corresponding id to the parent. id is mandatory until the useTextAsId flag is marked true.

  2. getSelected: Function that returns the id of the selected item. Should be defined in the parent and passed as prop.

        const getSelected = item => {
            console.log(item)
            //process item as any string
        }
  3. useTextAsId (optional): The component expects atleast two properties for each element of the suggestions array and these are text and id. However if user wants to use same string for both text and id, such is when any fruit apple is selected the package should return the same string apple, they can mark pass this prop as useTextAsId={true}. This should also be passed when a primitive array of strings is used in suggestions array.

  4. anywhere (optional): The filtering in general cases excludes suggestions for which the prefix doesn't match to reduce traffic. For example, when a is typed, the suggestions for countries will display Algeria but not Bangladesh even though the word Bangladesh contains two instances of a. To gain this facility, that is to suggest items no matter where they contain the typed phrase, anyhwhere={true} must be passed as props.

A call from the parent

    import Autocomplete from 'autocomplete'
    
        const suggestions = [
        {
          id: 'bgd',
          text: 'Bangladesh',
          sub: 'South Asia',
            img: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Flag_of_Bangladesh.svg/1200px-Flag_of_Bangladesh.svg.png'
        },
        {
          id: 'ind',
          text: 'India',
          sub: 'South Asia',
          img: 'https://upload.wikimedia.org/wikipedia/en/thumb/4/41/Flag_of_India.svg/1200px-Flag_of_India.svg.png'
        },
        {
          id: 'pks',
          text: 'Pakistan',
          sub: 'South Asia',
          img: 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSJTlfUBGgU7BcdQRBaSSR7ttosxQ25mU-big&usqp=CAU'
        }
    ]
    
    const getSelected = item => {
        console.log(item)
        //process item as any string
    }
    
    return (
        <Autocomplete suggestions={suggestions} getSelected={getSelected} />
    )