
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@rhc-shared-components/dual-list-selector
Advanced tools
Dual List Selector component for selecting items between two lists
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.
npm install --save @rhc-shared-components/dual-list-selector
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>
);
};
| 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 |
| 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 |
cd components/dual-list-selector
npm install
npm run dev
npm run build
npm run lint
npm run lint-fix
This component requires the following peer dependencies:
<Formik> component.name prop.MIT
FAQs
Did you know?

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.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.