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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rhc-shared-components/dual-list-selector

v1.1.2

Published

Dual List Selector component for selecting items between two lists

Readme

Dual List Selector

A dual list selector component that allows users to move items between two lists (available and selected). This component integrates with Formik for form management and provides advanced features like search, filtering, and loading states.

Features

  • Move individual items between lists
  • Move all items at once
  • Checkbox selection for multiple items
  • Search and filter functionality
  • Loading states with spinner
  • Empty state handling
  • Formik integration for form management
  • TypeScript support
  • Accessible design using PatternFly components

Installation

npm install --save @rhc-shared-components/dual-list-selector

Usage

import React, { useState } from 'react';
import { Formik, Form } from 'formik';
import { SearchInput } from '@patternfly/react-core';
import { DualListSelectorComposable, Option } from '@rhc-shared-components/dual-list-selector';

const MyComponent = () => {
  const [searchAvailableValue, setSearchAvailableValue] = useState('');

  const availableOptions: Option[] = [
    { text: 'Option 1', selected: false, isVisible: true, isDisabled: false },
    { text: 'Option 2', selected: false, isVisible: true, isDisabled: false },
    { text: 'Option 3', selected: false, isVisible: true, isDisabled: false },
  ];

  const [filteredAvailableOptions, setFilteredAvailableOptions] = useState(availableOptions);

  const onFilterChange = (value: string) => {
    setSearchAvailableValue(value);
    const filtered = availableOptions.map(option => ({
      ...option,
      isVisible: value === "" || option.text.toLowerCase().includes(value.toLowerCase())
    }));
    setFilteredAvailableOptions(filtered);
  };

  const searchInput = (
    <SearchInput
      value={searchAvailableValue}
      onChange={(_event, value) => onFilterChange(value)}
      onClear={() => onFilterChange("")}
    />
  );

  return (
    <Formik
      initialValues={{ selectedOptions: [] }}
      onSubmit={(values) => {
        console.log('Form submitted with:', values);
      }}
    >
      <Form>
        <DualListSelectorComposable
          availableOptions={filteredAvailableOptions}
          chosenOptions={[]}
          searchInput={searchInput}
          searchAvailableValue={searchAvailableValue}
          name="selectedOptions"
        />
      </Form>
    </Formik>
  );
};

Props

DualListSelectorComposableProps

| Prop | Type | Required | Description | |------|------|----------|-------------| | availableOptions | Option[] | Yes | Array of options available for selection | | chosenOptions | Option[] | Yes | Array of currently chosen options | | searchInput | React.ReactNode | Yes | Search input component for filtering available options | | searchAvailableValue | string | Yes | Current search value for available options | | name | string | Yes | Formik field name for form integration |

Option

| Property | Type | Required | Description | |----------|------|----------|-------------| | text | string | Yes | Display text for the option | | selected | boolean | Yes | Whether the option is currently selected | | isVisible | boolean | Yes | Whether the option is visible (not filtered out) | | isDisabled | boolean | Yes | Whether the option is disabled |

Development

Running the example

cd components/dual-list-selector
npm install
npm run dev

Building the component

npm run build

Linting

npm run lint
npm run lint-fix

Dependencies

This component requires the following peer dependencies:

  • React >= 16.13.1
  • @patternfly/react-core >= 5.3.4
  • formik >= 2.1.4

Important Notes

  • This component requires Formik context to work properly. It must be wrapped in a <Formik> component.
  • The component integrates with Formik's field management system using the name prop.
  • Search functionality is handled externally - you need to implement filtering logic and pass filtered options.
  • The component uses PatternFly's composable dual list selector components internally.

License

MIT