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

@huner2/react-column-select

v1.0.4

Published

React multiselect with twocolumns

Downloads

19

Readme

React-Column-Select

codecov Build npm

This package is a fork of react-multiselect-two-sides with a few changes.

Differences from react-multiselect-two-sides

This package is a typescript conversion, thus types are exported and visible in bundles.

Peer-dependencies have been updated to use recent versions of React.

Tests have been rewritten using modern testing frameworks.

The API is a little bit stricter due to the new Typescript types.

Preview

Preview

Install

npm install @huner2/react-column-select

Example

import React from 'react';
import createRoot from 'react-dom/client'
import ColumnSelect from '@huner2/react-column-select'

const App = () => {
    const options = [
        {name: 'Foo', value: 0},
        {name: 'Bar', value: 1},
        {name: 'Baz', value: 2, disabled: true},
        {name: 'Qux', value: 3},
        {name: 'Quux', value: 4},
        {name: 'Corge', value: 5},
        {name: 'Grault', value: 6},
        {name: 'Garply', value: 7},
        {name: 'Waldo', value: 8},
        {name: 'Fred', value: 9},
        {name: 'Plugh', value: 10},
        {name: 'Xyzzy', value: 11},
        {name: 'Thud', value: 12}
    ]
    const [value, setValue] = React.useState([0, 3, 9]);

    return (
        <ColumnSelect
            className="msts_theme_example"
            availableHeader="Available"
            availableFooter={`Available ${options.length - value.length}`}
            selectedHeader="Selected"
            selectedFooter={`Selected ${value.length}`}
            showControls
            searchable
            onChange={v => setValue(v)}
        />
    );
}

const root = createRoot(document.getElementById("root"));
root.render(App);

Props

Note: all props are optional but operation would be limited if you did not supply options or a value.

 

availableFooter

React.ReactNode

Used to provide a custom footer for the available column.

availableHeader

React.ReactNode

Used to provide a custom header for the available column.

className

string

Used to provide a custom classname to the container component.

clearFilterText

string

Used to provide a custom label for the filter clear button.

clearable

boolean

Used to toggle the clear button for the filter.

deselectAllText

string

Used to provide a custom label for the deselect all button.

disabled

boolean

Used to determine whether the value can be changed (readonly).

filterBy

Value := string | number
Option := {
    name := string
    value := Value
    disabled? := boolean
    highlight? := boolean
}

filterBy := (option: Option, filter: string) => boolean

Used to provide a custom filter function. The provided function should accept an option object and a string filter and return a boolean.

The return value determines whether or not the option will be included in the results (i.e. true will show the option).

filterComponent

FilterProps := {
    clearFilterText := string
    clearable := boolean
    disabled := boolean
    onChange := (filter: string) => void
    placeholder := string
    value := string
}

filterComponent := {
    React.FunctionComponent<FilterProps> |
        React.ComponentClass<FilterProps>
}

Used to provide a custom filter component.

The component should accept an object that conforms to FilterProps. Whenever the value changes, onChange should be called to propagate back to the ColumnSelect component.

The component can be either a functional component or a class component.

highlight

Value := string | number

hightlight := Value[]

Used to provide a list of values that should be highlighted, regardless of column.

limit

number

Limit controls the allowed number of selected items.

onChange

Value := string | number

onChange := (options: Value[]) => void

onChange is called with the new array of selected values on any change.

options

Value := string | number

Option := {
    name := string
    value := Value
    disabled? := boolean
    highlight? := boolean
}

Options := Option[]

Options is the list of options that should be available. Name is the label that will be displayed in the columns. Disabled and highlight are both optional and can be enabled per-option to disable or highlight an option.

placeholder

string

Used to customize the placeholder string in the filter inputs.

searchable

boolean

Used to toggle filters on or off.

selectAllText

string

Used to customize the label for the select all button.

selectedFooter

React.ReactNode

Used to customize the footer on the selected column.

selectedHeader

React.ReactNode

Used to customize the header on the selected column.

showControls

boolean

Used to toggle control buttons on or off.

value

Value := string | number

value := Value[]

Used to specify what options are selected