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

react-combo

v0.4.7

Published

React Combo

Downloads

33

Readme

react-combo

A carefully crafted combo-box on steroids for React

Install

$ npm i --save react-combo

Usage


import Combo from 'react-combo'
import 'react-combo/index.css'

const data = [
  { id: 1, label: 'First option' },
  { id: 2, label: 'Second' },
  { id: 3, label: 'Third' },
  { id: 4, label: 'Forth' }
]

<Combo
  dataSource={data}
  idProperty="id"
  displayProperty="label"
  defaultValue={[1,2]}
/>
import Combo, { List } from 'react-combo'
import 'react-combo/index.css'


<Combo
  dataSource={data}
  idProperty="id"
  displayProperty="label"
  defaultValue={[1,2]}
>
  <List
    emptyText="No items here"
    loadingText={<span>loading</span>}
    listPosition="top"
  />
</Combo>

DON'T forget to import the styles from react-combo/index.css

Behavior

Selected options can be navigated to with arrow keys and removed with Delete or Backspace or with click on remove icon.

Properties

Property | Type | Default | Description ----|---|---|--- dataSource| Array|Promise(Array) | - | an array of items, or a promise resolving to an array. idProperty| String|Function | - | the name of the property to be used as an id for each item in the dataSource. If the idProperty is a function, it will be called with the item object and expected to return an id. displayProperty | String|Function | - | the name of the property to be displayed for each item in the dataSource. If the displayProperty is a function, it will be called with the item object and expected to return the item display value. value | String|Number|Array | - | a single value, or an array of values, if you want to have multiselect. expanded | Boolean | - | if you want to control the expanded prop (when this is true, the list is visible). defaultExpanded | Boolean | false | uncontrolled version of expanded. onChange(value) | Function | - | the onChange callback. Will be called with a value or an array of values. renderItem(props) | Function | - | a function that can be used to customize how an item is rendered. If you return a React Node, the node will be rendered. If instead you only modify the props passed into this fn and return undefined, those props will be reflected on the default renderItem implementation. You can also use displayProperty: Function to render something else for each item. renderTag(props) | Function | - | a function that can be used to customize how a selected item is rendered in the combo tagClearTool(props) | Function | true | specify false or null if you don't want to render a clear icon for selected items/tags gotoNextOnSelect | Booleon | true | if the combo is a multiSelect and this flag is true, when selecting an item, the current index is moved to the next item, so it can be easily selected by pressing the Enter key again. renderExpandTool(props) | Function | - | a function to render the expand tool. It receives props for the tool. If you only want to modify the props, you can do so and return undefined. Otherwise, you can return a custom expand tool. toggleSelection | Boolean | true | when clicking an already selected item, it is deselected clearTextOnSelect | Boolean | true | when you filter for an item, and then select one, the text is cleared. defaultText | String | - | - text | String | - | the text to show in the filtering input, controlled version of defaultText. onTextChange | Function | - | called when text is changed in the filtering input. disabled | Boolean | false | prevent all actions on combo: new selection, clear selection. onActiveTagIndexChange(index) | Function | - | callback called when activeTagIndex changes, if index is -1 no tag is active activeTagIndex | Number | - | specify which tag is active, specify it's index, controlled version of defaultActiveTagIndex, -1 no tag is active defaultActiveTagIndex | Number | -1 | specify which tag is active at first render, -1 no tag is active

Development

$ git clone https://github.com/zippyui/react-combo.git
$ npm i
$ npm run dev

Navigate to http://localhost:9090/

License

MIT