Coder Social home page Coder Social logo

samettkaya / react-select-enhanced-counter Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.97 MB

A React Select package with 'Select All' feature and a counter for displaying the number of selected items beyond a specified limit.

Home Page: https://react-select-enhanced-counter.vercel.app

JavaScript 22.98% MDX 14.96% TypeScript 20.79% HTML 41.27%
multi-select react react-select react-select-multi select single-select react-select-counter

react-select-enhanced-counter's Introduction

React Select Enhanced Counter

npm version License: MIT

A React Select package with 'Select All' feature and a counter for displaying the number of selected items beyond a specified limit.

Installation

Install the package using npm:

npm install react-select-enhanced-counter

Install the package using yarn:

yarn add react-select-enhanced-counter

Live Example

You can see a live example of this package in action on the React Select Enhanced Counter Live Example.

Usage

Single Select Example

<Select
  options= {[
    { value: '1', key: 'Chocolate' },
    { value: '2', key: 'Strawberry' },
    { value: '3', key: 'Vanilla' },
    { value: '4', key: 'Banana' },
    { value: '5', key: 'Lemon' },
    { value: '6', key: 'Potato' },
  ]}
  defaultValue= {{ value: '1', key: 'Chocolate' }}
  displayExpr= {'key'}
  valueExpr= {'value'}
  isClearable= {true}
  noOptionsMessage= {'No options'}
  placeholder= {'Single Select'}
/>

Multi Select Example

<Select
  options= {[
    { value: '1', key: 'Chocolate' },
    { value: '2', key: 'Strawberry' },
    { value: '3', key: 'Vanilla' },
    { value: '4', key: 'Banana' },
    { value: '5', key: 'Lemon' },
    { value: '6', key: 'Potato' },
  ]}
  defaultValue= {[
    { value: '4', key: 'Banana' },
    { value: '5', key: 'Lemon' },
    { value: '6', key: 'Potato' },
  ]}
  displayExpr= {'key'}
  valueExpr= {'value'} 
  isMulti={ true}
  isClearable= {true}
  allowSelectAll= {true}
  numberDisplayed={2}
  placeholder= {'Multi Select'}
  selectAllText= {'Select All'}
  noOptionsMessage= {'No options'}
/>

Props

  • options* (Array): Array of possible options.
  • displayExpr* (string): Required if supplying an array of objects as options. Used to identify which property on the object is the label.
  • valueExpr* (string): Required if supplying an array of objects as options. Used to identify which property on the object is the value.
  • placeholder (string): Default message when no items are selected.
  • isMulti (boolean): Set to true for a multiselect, defaults to false.
  • className (string): Add custom class.
  • isDisabled (boolean): Is the select disabled.
  • onChangeSelect (event:any) => void: Called whenever selected value(s) have changed.
  • defaultValue (Array): It selects values by default.
  • isSearchable (boolean): If set to true, will add an input at the top of the dropdown for filtering the results.
  • allowSelectAll (boolean): If set to true, will add a Select All checkbox at the top of the list.
  • maxMenuHeight (number): The height of the dropdown. Defaults to 400px.
  • allSelectedPlaceholder (string): Default "%s selected" where %s is the number of items selected. This gets used when all options are selected.
  • selectAllText (string): Default "Select all", use this to override "Select all" text from top of dropdown when included with includeSelectAll.
  • numberDisplayed (number): The number of selected options displayed until it turns into '(selected count) selected'. Defaults to 4.
  • customStyles (StylesConfig<any, boolean, any>): Style modifier methods.
  • isLoading (boolean): Is the select in a state of loading (async).
  • isClearable (boolean): Is the select value clearable.
  • name (string): Name of the HTML Input (optional - without this, no input will be rendered).
  • noOptionsMessage (string): Text to display when there are no options to list.

Contributing

If you want to contribute to this project, feel free to open an issue or submit a pull request.

License

MIT

react-select-enhanced-counter's People

Contributors

samettkaya avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.