GithubHelp home page GithubHelp logo

nitesh9001 / multi-nested-select Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 5.0 1.08 MB

npm package for a react-ui library which provide nested list option selector for continent, country and state

Home Page: https://www.npmjs.com/package/multi-nested-select

License: MIT License

HTML 0.18% CSS 0.73% JavaScript 95.15% TypeScript 3.93%
checkbox-selection country-dropdown country-list country-selector country-state-address css group-selection multi-select nested-select nested-selection

multi-nested-select's Introduction

REACT MULTI-NESTED-SELECT DROPDOWN

npm License npm bundle size npm Libraries.io dependency status for latest release

๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ฅ React Library for SCREEN RECORDER . Tiny and Efficient. Check it Out ๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ฅ

Description

A React component which provides multi select functionality for nested option list of continent -> country -> state with various features like selection limit, CSS customization, checkbox, search option, disable preselected values, control nested level keyboard navigation for accessibility, chip select, delete selected, limit chip count, leading and trailing icon for search box, placeholder context and grouping features. Also it has feature to behave like normal dropdown(means single select dropdown).

๐ŸŽ‰๐ŸŽ‰ New features in >=1.1.7

โœจ Easy to use
๐Ÿƒ Light weight
๐Ÿš€ Typescript

๐Ÿณ๏ธโ€๐ŸŒˆ Getting Started

1. Installation ๐Ÿ”ง

npm install multi-nested-select

yarn add multi-nested-select

2. Demo ๐Ÿ‘๏ธ

React-multi-nested-select-dropdown


3. Basic Usage ๐Ÿ“‘

import NestedSelect from "multi-nested-select";;


callbackFunction(selectedItem) {
    ...
}

onChange(e_selected) {
    ...
}

<NestedSelect
    buttonContent="Done" // For custom text for button
    enableButton={true}  // To show or hide the button 
    state={true}         // show the nested level state 
    continent={true}     // show and hide the continent 
    chip={true}          // show and hide the chip 
    onChange={(val) => onChange(val)}  // while adding/removing this onchange will call
    callback={(val) => callbackFunction(val)}  //on submit or save button callback()
/>


4. Props ๐Ÿ’ฌ

Prop Type Default Description
callback function (val) => {} Callback function will invoked on click of save button
onSearch function (val) => {} Callback function will invoked on change of input feild event (similar to onChange). Params are searchValue
onChange function (val) => {} Callback function will invoked on selection or removal of options. Params are selectedList.
onViewmore function (val) => {} Callback function will invoked on click on view more (only when chip is true).
onChipDelete function (val) => {} Callback function will invoked on deletion of chip. (only when chip is true).
disabled boolean false Make it true to disable the select input feild.
selectedValue array [] Default value to persist in dropdown
showCustomList array [] Dropdown array list according to showCustomList.
error bool false To display error on input field.
helperText string "" To display the helper text for input.
expandChip bool true To display chip expand and collapse option
showCheckbox bool true To display checkbox option in the dropdown
omitSelected bool false To unselect the selected when clicked outside of dropdown.
selectLimit number -1 You can limit the number of items that can be selected in a dropdown
placeholder string Select Area Placeholder text
buttonContent string Save Selected To display the button text content`
disable bool false to disaled / enabled the button
selectAllOption bool false to enable "All regions" select option to select in one go
width number 360 width of the component.
height number 260 height of the dropdown.
chip bool false view selected option as chip.
chipCount number 5 chip count displayed on input.
placeholderCtx bool true enabale/ disable placeholderctx after option select.
enableButton bool true Make it false to hide the button.
trailing bool true Make it false to hide the trailing message ex- 0 of 24 selected'.
leading bool true Make it false to hide the leading icon in search box'.
trailingIcon bool true Make it false to hide the trailing icon in search box'.
state bool true Option to show or hide the state option list .make it false to hide state list.
continent bool true Option to show or hide the continent option list .make it false to hide continent list.
id string '' Id for the search container / input field..
buttonClass string '' styling for the save button(this is className).
dropDownClass string '' styling for the dropdown(this is className).
inputClass string '' styling for the input field wrapper with trailing icon or leading icons(this is className).
style object {} CSS Customization for multi-nested-select input fields.
...props attribute '' pass any attribute other than above listed, it will default assigned to input feild as their own attributes.

5. CSS Customization ๐ŸŒˆ

For customization of CSS we have provide className based support 

* For input box -- 
Pass props as inputClass= " ... your class name... "
<SelectCountry 
  inputClass="myCustom_text"
/>


* For drop-Down box -- 
Pass props as dropDownClass= "... your class name... "
<SelectCountry 
  dropDownClass="myCustom_dropbox"
/>

* For drop-Down box -- 
Pass props as dropDownClass= "... your class name... "
<SelectCountry 
  buttonClass="myCustom_button"
/>

Now create your own .css or .scss file to define that class style according to your need.

Ex -

Create `custom.css` file in your repo


.myCustom_dropbox{
    height: 200px;
    z-index: 1000;
}

8. Licence ๐Ÿ“œ

MIT

9. Development

This package is build with typescript, react js and webpack .

10. Contributions

Contributions are welcome, please open an issue and preferrably file a pull request.

Opening Issue Please share sample code using codesandbox.com or stackblitz.com to help me re-produce the issue.

11. Playground

https://codesandbox.io/s/multi-select-nested-options-5eyyu4?file=/src/App.js

multi-nested-select's People

Contributors

nitesh9001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

multi-nested-select's Issues

Nested list is not rendered

import React, { useEffect, useRef, useState } from "react";
import { NestedSelect } from "multi-nested-select";
import './App.css';
const data = [
{
name: "Georgia",
code: "AF",
zones: ['Tbilisi,Gori'],
continent: "Asia",
provinceKey: "REGION"
}
];
function App() {
const ref = useRef();
const [response, setResponse] = useState([]);

const callbackFUnction = (value) => {
console.log(value);
setResponse(value);
};

useEffect(() => {
const handleClickOutside = (event) => {
if (ref.current && !ref.current.contains(event.target)) {
// alert("sving fat");
}
};
document.addEventListener("click", handleClickOutside, true);
return () => {
document.removeEventListener("click", handleClickOutside, true);
};
});
return (


<NestedSelect
showCustomList={data}
buttonContent="Save Selected"
enableButton={true}
state={true}
width={450}
height={200}
leading={true}
chip={false}
placeholderCtx={true}
trailing={true}
trailingIcon={true}
inputClass="myCustom_text"
continent={false}
dropDownClass="myCustom_dropbox"
selectedValue={data}
expandChip={true}

  />
</div>

);
}

export default App;.

The result i have is :
image

Please make it useable for any list.

Problem
I installed this package, but I forgot to read the description, I spent a couple of hours using it with my array of data. After a lot of searching and effort, I read the description and came to know it is not agnostic.

Solution
It is a very beautiful package, it has good looking UI, typescript support, and briefed documentation and it is the perfect choice when we require geo data in the list. I am here to request a feature, please make it available for all types of lists. I found no package on npm to choose against my requirements. Not only me but most of the developers would praise you if you consider this feature to add to Multi-Nested-Select.

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.