Skip to content

Commit 01ae2f0

Browse files
author
nitesh.singh
committed
added leading icon and trailing icons and bug fix for state select
1 parent b004b27 commit 01ae2f0

File tree

13 files changed

+160
-69
lines changed

13 files changed

+160
-69
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
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 and grouping features. Also it has feature to behave like normal dropdown(means single select dropdown).
1414

1515

16-
<img src="./images/ss_4.png" width="200"/>
17-
<div align="center">
16+
<div>
1817
<div style="display: flex;">
18+
<img src="./images/ss_4.png" width="200"/>
1919
<img src="./images/ss_7.png" width="150" />
20+
</div>
21+
<div style="display: flex;">
2022
<img src="./images/ss8.png" width="150" />
2123
<img src="./images/ss_6.png" width="150" />
2224
</div>
@@ -86,7 +88,8 @@ onChange(e_selected) {
8688
| `width` | `number` | `360` | width of the component to display dropdown.
8789
| `enableButton` | `bool` | `true` | Make it `false` to hide the button.
8890
| `trailing` | `bool` | `true` | Make it `false` to hide the trailing message ex- 0 of 24 selected'.
89-
| `leading` | `bool` | `true` | Make it `false` to hide the leading search icon '.
91+
| `leading` | `bool` | `true` | Make it `false` to hide the leading icon in search box'.
92+
| `trailingIcon` | `bool` | `true` | Make it `false` to hide the trailing icon in search box'.
9093
| `state` | `bool` | `true` | Option to show or hide the state option list .make it `false` to hide state list.
9194
| `style` | `object` | `{}` | CSS Customization for multi-nested-select. Refer below object for **css customization.
9295
| `continent` | `bool` | `true` | Option to show or hide the continent option list .make it `false` to hide continent list.

example/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ td{
4444
/* justify-content: center; */
4545
font-size: calc(10px + 2vmin);
4646
color: white;
47-
margin-bottom: 800px;
47+
/* margin-bottom: 800px; */
4848
}

example/src/App.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const App = () => {
3434
}
3535
}];
3636
const callbackFUnction = (value) => {
37-
console.log(value);
37+
console.log("value", value);
3838
setResponse(value);
3939
}
4040

@@ -45,12 +45,14 @@ const App = () => {
4545
<div className='center-component'>
4646
<NestedSelect
4747
buttonContent="Save Selected"
48-
enableButton={false}
48+
enableButton={true}
4949
state={true}
50-
// selectLimit={3}
51-
leading={true}
52-
continent={true}
53-
selectedValue={data}
50+
// leading={true}
51+
// trailing={true}
52+
// trailingIcon={true}
53+
continent={false}
54+
// selectedValue={data}
55+
onChange={(v) => console.log("okay", v)}
5456
callback={(val) => callbackFUnction(val)}/>
5557
</div>
5658
<h1>Selected Country-state</h1>

images/ss_4.png

-25.2 KB
Loading

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "multi-nested-select",
3-
"version": "1.1.5",
4-
"description": "",
3+
"version": "1.1.6",
4+
"description": "multi-nested-select package",
55
"main": "dist/index.js",
66
"typings": "dist/types/index.d.ts",
77
"scripts": {
8-
"build": "webpack --mode production",
8+
"build": "webpack --mode production --watch",
99
"clean": "rm -rf dist",
1010
"copy-dts": "copyfiles -u 1 \"src/**/*.d.ts\" dist"
1111
},

src/Elements/ActionButton.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
color: white;
1717
font-size: 16px;
1818
cursor: pointer;
19-
box-shadow: rgb(0 0 0 / 20%) 0px 2px 1px -1px,
19+
/* box-shadow: rgb(0 0 0 / 20%) 0px 2px 1px -1px,
2020
rgb(0 0 0 / 14%) 0px 1px 1px 0px,
21-
rgb(0 0 0 / 12%) 0px 1px 3px 0px;
21+
rgb(0 0 0 / 12%) 0px 1px 3px 0px; */
2222
}
2323

2424
.NSI-select-drop-down-menu-button:disabled {

src/Elements/ActionButton.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,43 @@ import './ActionButton.css';
55
function ActionButton({
66
value,
77
callback,
8+
setIsLoading,
89
buttonContent,
910
buttonClass,
10-
closeDropDown
11+
closeDropDown,
12+
setIsExpand,
13+
isExpand
1114
}: ActionButtonProps) {
1215

13-
const [isLoading, setIsloading] = useState<boolean>(false);
16+
const [isLoading, setIsloadingButton] = useState<boolean>(false);
1417

1518
useEffect(() => {
16-
if (value.length == 0 ||
19+
if (value?.length == 0 ||
1720
value == null ||
18-
value == undefined ||
19-
value === []) {
20-
setIsloading(true);
21+
value == undefined
22+
) {
23+
setIsloadingButton(true);
2124
} else {
22-
setIsloading(false);
25+
setIsloadingButton(false);
2326
}
2427
}, [value]);
2528

2629
const onTrigerSave = () => {
27-
if (value.length == 0 ||
30+
if (value?.length == 0 ||
2831
value == null ||
29-
value == undefined ||
30-
value == []) {
31-
setIsloading(true);
32+
value == undefined) {
33+
setIsloadingButton(true);
3234
console.log("Nested select :- Please select some value");
3335
} else {
34-
setIsloading(true);
36+
setIsloadingButton(true);
3537
if(callback){
3638
callback(value);
39+
if(setIsLoading){
40+
setIsLoading(true);
41+
}
42+
if(setIsExpand && isExpand){
43+
setIsExpand(!isExpand);
44+
}
3745
}
3846
}
3947
closeDropDown(false);

src/SelectModule/SelectModule.css

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
height: 40px;
1414
border-radius: 5px;
1515
outline: none;
16-
font-size: 18px;
16+
font-size: 16px;
1717
text-transform: capitalize;
1818
padding-left: 5px;
1919
border: 1px solid #dcdcdc;
@@ -35,6 +35,25 @@
3535
width: 16px;
3636
height: 16px;
3737
}
38+
.NSI-select-input-trailing{
39+
position: absolute;
40+
right: -32px;
41+
width: 16px;
42+
height: 16px;
43+
background-color: white;
44+
padding: 12px;
45+
top: 2px;
46+
}
47+
.NSI-select-input-trailing-180{
48+
position: absolute;
49+
transform: rotateZ(180deg);
50+
top: 2px;
51+
right: -32px;
52+
width: 16px;
53+
height: 16px;
54+
background-color: white;
55+
padding: 12px;
56+
}
3857
.NSI-continent-text{
3958
list-style: none;
4059
}
@@ -78,7 +97,7 @@
7897
justify-content: space-between;
7998
margin-left: 20px;
8099
align-items: center;
81-
font-size: 18px;
100+
font-size: 14px;
82101
text-align: left;
83102
}
84103

@@ -155,7 +174,7 @@
155174
transition: box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
156175
border-radius: 5px;
157176
padding: 8px;
158-
width: 98% ;
177+
width: 104% ;
159178
box-shadow: rgb(0 0 0 / 20%) 0px 2px 1px -1px,
160179
rgb(0 0 0 / 14%) 0px 1px 1px 0px,
161180
rgb(0 0 0 / 12%) 0px 1px 3px 0px;

0 commit comments

Comments
 (0)