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

@keyvaluesystems/react-multi-selection-ui-component

v1.1.0

Published

Multi Select UI Component

Downloads

36

Readme

React Multi Selection UI

A pre-built, customizable Multi-Selection UI component with an integrated search feature

Try tweaking a multi selection ui component using this codesandbox link here

Installation

The easiest way to use react-multi-selection-ui-component is to install it from npm and build it into your app with Webpack.


npm install  @keyvaluesystems/react-multi-selection-ui-component

You’ll need to install React separately since it isn't included in the package.

Note for Next.js users, if you are using Next.js version 13 or later, you will have to use the use client feature to ensure proper compatibility.

Usage

React Multi Selection UI can run in a very basic mode by just providing the options like given below:

import MultiSelection from "@keyvaluesystems/react-multi-selection-ui-component";

<MultiSelection options={optionsArray} />;

The optionsArray consists of objects with the following keys:

  • id: A unique identifier for each option.
  • name: A string representing the label for each option.
  • checked: An optional boolean value indicating the default state of the option

An example for options array is shown below:

const optionsArray = [
  {
    id: 1,
    name: "Option 1",
    checked: true,
  },
  {
    id: 2,
    name: "Option 2",
  },
];

v1.0.0 (Major Version Change)

This release includes breaking changes, new features, and updates. Please read this document carefully before upgrading

Breaking Changes

  • The productList prop has been renamed to options, and now each object within the options array includes an additional optional checked property.
  • The zeroState prop is deprecated.
  • Significant alterations have been made to the UI behavior. Please take note of these changes during the upgrade

Migration Steps

  • Update Options Prop: The productList prop has been renamed to options. Use the options prop to pass the list of items.
  • Replace searchPlaceholder with placeholder:The searchPlaceholder prop has been replaced with placeholder.
  • Utilize renderEmptyItem Prop: To pass the empty state component, use the renderEmptyItem prop.

Before

<MultiSelection
  productList={yourProductList}
  searchPlaceholder="Type to search..."
  zeroState={{
    selectionList: <YourCustomEmptyState />,
    selectedList: <YourCustomEmptyState />,
  }}
/>

After

<MultiSelection
  options={yourProductList}
  placeholder="Type to search..."
  renderEmptyItem={<YourCustomEmptyState />}
/>

Props

Props that can be passed to the component are listed below:

Style Customizations

All the default styles provided by this package are overridable using the style prop. the below code shows all the overridable styles:

<MultiSelection
 options={optionsArray}
 styles={{
    Container?: {...styles},
    SearchComponent?: {...styles},
    HelperText?: {...styles},
    InputBox?: {...styles},
    CheckedIcon?: {...styles},
    UnCheckedIcon?: {...styles},
    ChipCloseIcon?: {...styles},
    SearchIcon?: {...styles},
    ArrowIcon?: {...styles},
    HiddenChipsIndicator?: {...styles},
    ClearSearchIcon?: {...styles},
    SelectedMenuItem?: (id) => ({...styles}),
    UnSelectedMenuItem?: (id) => ({...styles}),
    ChipComponent?: (id) => ({...styles}),
 }}
/>

To customize the style of various components, you can use the following prop names, each of which accepts a style object:

  • ArrowIcon: Overrides the style of the right-arrow icon.
  • Container: Overrides the style of the multi-selection UI container.
  • CheckedIcon: Overrides the style of the checked icon.
  • ChipCloseIcon: Overrides the style of the close icon within the chip.
  • ClearSearchIcon: Overrides the style of the close icon within the search box.
  • HelperText: Overrides the style of the helper text.
  • HiddenChipsIndicator: Overrides the style of the bubble indicating the number of hidden chips if the thresholdForBubble prop has a value.
  • InputBox: Overrides the style of the box containing the chips and search bar. Can be used to style the placeholder if the search is hidden.
  • SearchIcon: Overrides the style of the search icon.
  • SearchComponent: Overrides the styles of the search component.
  • UnCheckedIcon: Overrides the style of the unchecked box.

You can utilize the provided prop names to customize the style of individual items in the chip or each item in the menu. This can be achieved by passing a function that returns the desired style for each element.

  • ChipComponent - Overrides the chip style
  • SelectedMenuItem - Overrides the selected menu item styles
  • UnSelectedMenuItem - Overrides the non selected item styles

Icon Customizations

The icons prop allows for the customization of default icons provided by this package The following code displays the icons that can be customized

<MultiSelection
 options={optionsArray}
 icons={{
    Arrow?: url || JSX.Element,
    ChipClose?: url || JSX.Element,
    Checked?: url || JSX.Element,
    ClearSearch?: url || JSX.Element,
    Search?: url || JSX.Element
 }}
/>
  • Arrow - Overrides the down arrow(right)
  • ChipClose - Overrides the chip close icon
  • Checked - Overrides the checkbox checked icon
  • ClearSearch - Overrides the close icon inside search box
  • Search - Overrides the search icon