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 🙏

© 2026 – Pkg Stats / Ryan Hefner

perdana-autocomplete

v1.1.1

Published

**Perdana Autocomplete** is a plug-and-play React component for an input with a suggestion list. It works in controlled or uncontrolled mode and can render an optional action button.

Readme

Perdana Autocomplete is a plug-and-play React component for an input with a suggestion list. It works in controlled or uncontrolled mode and can render an optional action button.

Installation

npm install perdana-autocomplete
# react and react-dom must already be installed (peer dependencies)

Quick Start

import { useState } from 'react'
import PerdanaAutoComplete from 'perdana-autocomplete'

const people = [
  { id: 1, name: 'Alice' },
  { id: 2, name: 'Bob' },
  { id: 3, name: 'Charlie' },
]

export default function Example() {
  const [value, setValue] = useState('')

  return (
    <PerdanaAutoComplete
      id="people-search"
      list={people}
      placeholder="Search people"
      value={value} // omit for uncontrolled mode
      onChange={setValue}
      onSelect={(item) => console.log('Selected:', item)}
      withButton={{
        text: 'Search',
        position: 'right',
        backgroundColor: '#007BFF',
        textColor: '#fff',
        onClick: (_id, currentValue) => console.log('Search click', currentValue),
      }}
    />
  )
}

API Props

  • id (string, default: "perdana-auto-complete"): id applied to the input.
  • list (Array<{ id?: string|number, name: string }>): suggestion source. Filtering is substring, case-insensitive, against name.
  • placeholder (string): input placeholder text.
  • value (string) and onChange(value, event) (function): provide both for controlled mode. If value is omitted, the component runs uncontrolled.
  • onSelect(item) (function): fired when a suggestion is chosen.
  • debounce (number, default: 500 ms): wait time before filtering.
  • minChars (number, default: 0): minimum characters before suggestions show.
  • renderSuggestion(item, { query }) (function): custom renderer for each suggestion row.
  • emptyMessage (string, default: "No results found"): text when there are no matches.
  • className, style: forwarded to the outer container.
  • inputProps (object): extra props for the <input> (e.g., name, aria-*, etc.).

withButton options

Render a button to the left or right of the input by passing an object:

  • text (string): button label (ignored if iconSrc is provided).
  • iconSrc, iconAlt: optional icon.
  • position (left|right, default: right): button position.
  • backgroundColor, textColor, style: button style overrides.
  • id, className: attributes for <button>.
  • onClick(id, value): callback when clicked, receives the input id and current value.

Behavior & Styling

  • Filtering is debounced (default 500 ms), substring, case-insensitive against item.name.
  • Dropdown closes on blur; clicking a suggestion or the button will not steal focus thanks to preventDefault on mousedown.
  • Available CSS hooks:
    • .pg-cont (outer flex container)
    • .pg-input-wrapper (input + dropdown wrapper)
    • .pg-inp-auto-comp (input)
    • .pg-suggest-cont (suggestion list, absolutely positioned)
    • .pg-suggestion-item (suggestion row)
    • .pg-empty-state (“no results” row)
  • Base styles are injected automatically via the bundle (style-loader), so you do not need to import CSS separately. You can still override with your own CSS.

Custom Rendering Example

<PerdanaAutoComplete
  list={people}
  renderSuggestion={(item) => (
    <span>
      {item.name} <small style={{ color: '#888' }}>id: {item.id}</small>
    </span>
  )}
/>;

Development Scripts

  • npm run dev — Runs the React demo playground (src/demo.jsx) at http://localhost:3000.
  • npm run build — Produces the UMD bundle at dist/index.js for consumption by other React apps or for publishing.