0.28.2 • Published 27 days ago

@bolttech/molecules-dropdown v0.28.2

Weekly downloads
-
License
-
Repository
-
Last release
27 days ago

Dropdown Component

The Dropdown component is a customizable React component that provides a dropdown input with a list of selectable options.

Installation

To use the Dropdown component, you need to install the required dependencies:

npm install @bolttech/frontend-foundations @bolttech/molecules-dropdown

or

yarn add @bolttech/frontend-foundations @bolttech/molecules-dropdown

Usage

You can utilize the Dropdown component by importing it and including it in your JSX. Here's an example:

import React from 'react';
import { Dropdown } from '@bolttech/molecules-dropdown'; // Adjust the path to your component

const options = [
  { id: '1', label: 'Option 1', value: 'option1' },
  { id: '2', label: 'Option 2', value: 'option2' },
  { id: '3', label: 'Option 3', value: 'option3' },
];

function App() {
  const handleOptionChange = (selectedOption) => {
    console.log('Selected option:', selectedOption);
  };

  return (
    <div>
      <Dropdown label="Select an option" optionList={options} value="option2" onChange={handleOptionChange} />
    </div>
  );
}

export default App;

Props

The Dropdown component accepts the following props:

PropTypeDescription
labelstringLabel for the dropdown.
variantstringVariant style of the dropdown. Defaults to 'grey'.
requiredbooleanWhether the dropdown is required or not.
optionListOptionType[]Array of selectable options for the dropdown.
disabledbooleanWhether the dropdown is disabled or not.
errorMessagestringError message to display when there's an error with the dropdown.
urlFilterOptionsstringURL for fetching filtered options based on input.
idstringComponent identification.
dataTestIdstringThe data-testid attribute for testing purposes.
filterOptionsParamfunctionFunction to filter options based on input and URL.
valuestringCurrently selected value.
onChangefunctionCallback function triggered when the selected option changes.
onBlurfunctionCallback function triggered when the dropdown loses focus.
onFocusfunctionCallback function triggered when the dropdown is focused.
placeholderstringPlaceholder text for the input.
disableSearchbooleanBoolean that represent if we should disable user searching on the dropdown. Defaults to false
onKeyUpfunctionThe onkeyup event occurs when the user releases a key on the keyboard
onKeyDownbooleanOnkeydown is an event handler in Javascript that gets called when a key is pressed on the keyboard
asyncOptionListbooleanA boolean prop that controls a different behavior when OptionList are set by an API request
helperMessagestringAn optional string to display as a helper message for the dropdown

Functionality

The Dropdown component provides the following functionality:

  • Option Selection: Allows the user to select an option from the dropdown.
  • Input Interaction: The input field can be focused, blurred, and modified.
  • Filtering: Supports dynamic option filtering based on input and URL.
  • Accessibility: Proper accessibility structure is maintained for interacting with the dropdown.

Contribution

Contributions to the Dropdown component are welcomed. If you encounter issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the component's Bitbucket repository.

0.28.2

27 days ago

0.28.1

1 month ago

0.28.0

1 month ago

0.27.0

1 month ago

0.26.0

2 months ago

0.25.2

3 months ago

0.25.1

3 months ago

0.25.0

3 months ago

0.23.0

3 months ago

0.24.0

3 months ago

0.22.2

3 months ago

0.22.1

3 months ago

0.21.0

4 months ago

0.22.0

3 months ago

0.20.2

4 months ago

0.20.1

4 months ago

0.20.0

5 months ago

0.19.0

5 months ago

0.17.2

6 months ago

0.17.3

6 months ago

0.12.0

9 months ago

0.13.0

9 months ago

0.14.0

9 months ago

0.15.0

8 months ago

0.16.0

7 months ago

0.17.0

6 months ago

0.18.0

6 months ago

0.17.1

6 months ago

0.10.0

9 months ago

0.9.0

10 months ago

0.8.0

10 months ago

0.9.1

10 months ago

0.5.0

10 months ago

0.7.0

10 months ago

0.6.0

10 months ago

0.5.1

10 months ago

0.4.3

11 months ago

0.4.1

11 months ago

0.4.0

11 months ago

0.4.2

11 months ago

0.1.14

12 months ago

0.3.0

11 months ago

0.2.0

12 months ago

0.3.2

11 months ago

0.3.1

11 months ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.9

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago