0.1.6 • Published 4 months ago

aselect v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Documentation

ASelect Component

The ASelect component is a customizable dropdown select component for React applications.

Installation

To install ASelect in your project, you can use npm:

npm install ASelect

Or yarn:

yarn add ASelect

Usage

Importing

import { ASelect } from "ASelect";

Basic Usage

<ASelect
  value={value}
  options={["Option 1", "Option 2", "Option 3"]}
  onChange={(selectedOption, selectedOptionObject, currentSearchString) =>
    setValue(selectedOption)
  }
/>
Output

Example with Array of Objects (with keyProp)

<ASelect
  value={value}
  options={[
    { id: 1, label: "Option 1" },
    { id: 2, label: "Option 2" },
    { id: 3, label: "Option 3" },
  ]}
  keyProp="label"
  onChange={(selectedOption, selectedOptionObject, currentSearchString) => {
    setValue(selectedOption);
    setCurrentObject(selectedOptionObject);
  }}
/>
Output 1 (keyProp="label")
Output 2 (keyProp="id")

Basic Example with Grouped Options

<ASelect
  value={value}
  options={[
    {
      groupName: "Group 1",
      options: ["Option 1", "Option 2"],
    },
    {
      groupName: "Group 2",
      options: ["Option 3", "Option 4"],
    },
  ]}
  onChange={(selectedOption, selectedOptionObject, currentSearchString) =>
    setValue(selectedOption)
  }
/>
Output

Advanced Example with Grouped Options

<ASelect
  value={value}
  options={[
    {
      groupName: "ID Group",
      options: [
        { id: 1, label: "Option 1" },
        { id: 2, label: "Option 2" },
        { id: 3, label: "Option 3" },
      ],
      keyProp: "id",
    },
    {
      groupName: "Label Group",
      options: [
        { id: 1, label: "Option 1" },
        { id: 2, label: "Option 2" },
        { id: 3, label: "Option 3" },
      ],
      keyProp: "label",
    },
  ]}
  onChange={(selectedOption, selectedOptionObject, currentSearchString) =>
    setValue(selectedOption)
  }
/>
Output

Props

PropTypeDefaultDescription
valuestringThe currently selected value.
onChange(selectedOption, selectedOptionObject, currentSearchString) => {}Callback function invoked when a new value is selected.
optionsarrayList of options to display in the dropdown.
keyPropstringProperty to be used as a key within the objects of the options list. Mandatory if options is an array of objects.
searchablebooleantrueBoolean indicating if the dropdown is searchable.
placeholderstring"Search..."Placeholder text for the input field.
disabledbooleanDisables the select component.
widthstring or numberWidth of the select component.
zIndexnumber1z-index for the dropdown.
fontSizenumber16Font size for the select component.
requiredbooleanfalseIndicates whether the select component is required.

Conclusion

With the ASelect component, you can easily add customizable dropdown select functionality to your React applications. Choose from a variety of options including array of strings, array of objects with keyProp, and grouped options to suit your needs. Follow the documentation to install and use the component in your project for testing and development purposes.

0.1.6

4 months ago

0.1.5

4 months ago

0.1.4

4 months ago

0.1.3

4 months ago

0.1.2

4 months ago

0.1.1

4 months ago

0.1.0

4 months ago

0.0.9

4 months ago

0.0.8

4 months ago

0.0.7

4 months ago

0.0.6

4 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago