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

@inthepocket/itp-rcc-autocomplete

v0.0.4

Published

ITP Autocomplete component

Downloads

7

Readme

ITP AutoComplete component

Built on downshift. For now, this is a controlled component only. You'll have to pass the input value and handle the changes and manage the autocomplete items.

Usage

$ npm install @inthepocket/itp-rcc-autocomplete

Import (Typescript)

import { default as AutoComplete } from '@inthepocket/itp-rcc-autocomplete';

Import (ES)

import AutoComplete from '@inthepocket/itp-rcc-autocomplete';

JSX

<AutoComplete
  items={[{ value: 'Amsterdam' }, { value: 'Brussels' }]}
  name="city"
  onChange={({ value }) => { ... }}
  placeholder="City"
  size="small"
  type="search"
  value="Amsterdam"
/>

API documentation

AutoComplete

<AutoComplete
  items={[{ value: 'Amsterdam' }, { value: 'Brussels' }]}
  name="city"
  onChange={({ value }) => { ... }}
  placeholder="City"
  size="small"
  type="search"
  value="Amsterdam"
/>

| Property | Description | Type | Default | Required | | ------------------ | ------------------------------------------------------- | ------------------------ | ----------------------------------- | -------- | | autoComplete | translates into autocomplete attribute on input element | boolean | 'new-password' | No | | hasRandomizedName | randomizes the input's name attribute as a workaround for Chrome's stubborn autofill / autocompletion | boolean | true | No | | InputComponent | Input component | React.ReactNode | <input /> | No | | isDisabled | Disabled state | boolean | false | No | | isLoading | Loading state | boolean | false | No | | items | Dropdown items | Array | undefined | No | | itemsToString | List item toString method | Function | item => (item && item.value) || '', | No | | Loader | Loading state component | React.ReactNode | <span>Loading</span> | No | | onChange | onChange event handler | Function | undefined | No | | placeholder | input element placeholder text | String | '' | No | | prefixCss | Prefix for css classNames | String | 'auto-complete' | No | | size | 'small' | 'default' | 'large' | String | 'default' | No | | styles | imported css module (if passed, prefixed classNames will be disabled), see styles property | Object | null | No | | type | input element type: 'email' | 'text' | 'search' | String | 'text' | No | | value | input element value | String | '' | No |

Classnames (when not using the styles property - css module)

.itp-autocomplete { ... } // container
.itp-autocomplete--isLoading { ... } // container loading state
.itp-autocomplete--isOpen { ... } // container dropdown-opened state
.itp-autocomplete__input { ... } // text input container
.itp-autocomplete__list { ... } // dropdown list
.itp-autocomplete__listItem { ... } // dropdown list item
.itp-autocomplete__listItem--isHighlighted { ... } // dropdown list item highlighted state
.itp-autocomplete__listItem--isSelected { ... } // dropdown list item selected state
.itp-autocomplete__loader { ... } // loader element (mounted when isLoading property is true)

Styles property (when using the styles property - css module)

| Property | Description | Type | Default | Required | | ------------- | -------------------------------------------- | ------ | ------- | -------- | | autoComplete | Autocomplete container | string | - | No | | input | Text input container | string | - | No | | isHighlighted | Dropdown list item highlighted state | string | - | No | | isLoading | Autocomplete container loading state | string | - | No | | isOpen | Autocomplete container dropdown-opened state | string | - | No | | isSelected | Dropdown list item selected state | string | - | No | | list | Dropdown list | string | - | Yes | | listItem | Dropdown list item | string | - | Yes | | loader | Loader component | string | - | No |

The css module should look like this:

.autoComplete { ... }
.input { ... }
.isHighlighted { ... }
.isLoading { ... }
.isOpen { ... }
.isSelected { ... }
.list { ... }
.listItem { ... }
.loader { ... }

DisableBrowserAutoComplete

Disables html form input autocomplete and autofill for every child on Chrome and Firefox. Based on https://gist.github.com/niksumeiko/360164708c3b326bd1c8

import { DisableBrowserAutoComplete } from '@inthepocket/itp-rcc-autocomplete';

usage:

<DisableBrowserAutoComplete>
  <AutoComplete />
  <input />
</DisableBrowserAutoComplete>

Development

Installation

$ npm install

Test

$ npm run test

Build

Compiles the TypeScript source to ES5.

$ npm run build