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-selectable-extended

v0.1.0

Published

Allows individual or group selection of items using the mouse/touch.

Downloads

6

Readme

Selectable items for React

Allows individual or group selection of items using the mouse/touch.

Demo

Try it out

Based on react-selectable

This project is based on react-selectable by unclecheese. It extends the original functionality in the following ways:

  • Adds support for clicking individual items without dragging.
  • Adds optional dontClearSelection feature to allow for additions to selected items.
  • Adds optional duringSelection callback feature to allow for a callback function to be called repeatedly throughout selection.

If you are looking for a lightweight, stateless selector and don't need any of the features listed above, go with react-selectable.

Getting started

npm install react-selectable-extended
import React from 'react';
import { render } from 'react-dom';
import { SelectableGroup, createSelectable } from 'react-selectable';
import SomeComponent from './some-component';

const SelectableComponent = createSelectable(SomeComponent);

class App extends React.Component {
  
  constructor (props) {
  	super(props);
  	this.state = {
  		selectedKeys: [],
      selectingKeys: []
  	};
  }

  render () {
    return (
      <SelectableGroup onSelection={this.handleSelection} duringSelection={this.handleSelecting}>
        {this.props.items.map((item, i) => {
          	let selected = this.state.selectedKeys.indexOf(item.id) > -1;
            let selecting = this.state.selectingKeys.indexOf(item.id) > -1;
          	return (
          		<SelectableComponent key={i} selected={selected} selecting={selecting} selectableKey={item.id}>
          			{item.title}
          		</SelectableComponent>
          	);
        })}
      </SelectableGroup>
    );
  },
  
  handleSelection (selectedKeys) {
  	this.setState({ selectedKeys });
  }

  handleSelecting (selectingKeys) {
    this.setState({ selectingKeys });
  }
	
}

Configuration

The <SelectableGroup /> component accepts a few optional props:

  • onSelection (Function) Callback fired after user completes selection
  • duringSelection (Function) Callback fired rapidly during selection (while the selector is being dragged). Passes an array containing the keys of the items currently under the selector to the callback function.
  • tolerance (Number) The amount of buffer to add around your <SelectableGroup /> container, in pixels.
  • component (String) The component to render. Defaults to div.
  • fixedPosition (Boolean) Whether the <SelectableGroup /> container is a fixed/absolute position element or the grandchild of one.
  • dontClearSelection (Boolean) When enabled, makes all new selections add to the already selected items, except for selections that contain only previously selected items—in this case it unselects those items.

NOTE: For both fixedPosition and dontClearSelection, if you get an error that Value must be omitted for boolean attributes when you try, for example, <SelectableGroup fixedPosition={true} />, simply use Javascript's boolean object function: <SelectableGroup fixedPosition={Boolean(true)} />.