Socket
Book a DemoInstallSign in
Socket

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

Package Overview
Dependencies
Maintainers
6
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Dual List Selector component for selecting items between two lists

latest
npmnpm
Version
1.1.0
Version published
Maintainers
6
Created
Source

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

PropTypeRequiredDescription
availableOptionsOption[]YesArray of options available for selection
chosenOptionsOption[]YesArray of currently chosen options
searchInputReact.ReactNodeYesSearch input component for filtering available options
searchAvailableValuestringYesCurrent search value for available options
namestringYesFormik field name for form integration

Option

PropertyTypeRequiredDescription
textstringYesDisplay text for the option
selectedbooleanYesWhether the option is currently selected
isVisiblebooleanYesWhether the option is visible (not filtered out)
isDisabledbooleanYesWhether 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

FAQs

Package last updated on 05 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts