l-min-components 1.0.379 → 1.0.382
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -20,22 +20,24 @@ const SearchBar = ({
|
|
|
20
20
|
asyncResult,
|
|
21
21
|
inFilter,
|
|
22
22
|
outFilter,
|
|
23
|
+
children,
|
|
24
|
+
onChange,
|
|
25
|
+
hasCustomDropdown = false,
|
|
23
26
|
...restProps
|
|
24
27
|
}) => {
|
|
25
28
|
const [searchValue, setSearchValue] = useState("");
|
|
26
29
|
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
27
30
|
const [suggestions, setSuggestions] = useState([]);
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
32
|
+
const handleInputChange = async (event) => {
|
|
33
|
+
const value = event.target.value;
|
|
34
|
+
setSearchValue(value);
|
|
35
|
+
if (asyncResult) {
|
|
36
|
+
const suggestions = await asyncResult(value);
|
|
37
|
+
setSuggestions(suggestions);
|
|
38
|
+
setShowSuggestions(true);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
39
41
|
|
|
40
42
|
const handleEnterPress = (event) => {
|
|
41
43
|
if (event.key === "Enter") {
|
|
@@ -53,26 +55,29 @@ const SearchBar = ({
|
|
|
53
55
|
|
|
54
56
|
return (
|
|
55
57
|
<Container>
|
|
56
|
-
<SearchBarContainer
|
|
58
|
+
<SearchBarContainer
|
|
57
59
|
heightSize={restProps.heightSize}
|
|
58
60
|
widthSize={restProps.widthSize}
|
|
59
61
|
borderRadius={restProps.borderRadius}
|
|
60
62
|
border={restProps.border}
|
|
61
63
|
outlineColor={restProps.outlineColor}
|
|
62
64
|
>
|
|
63
|
-
<SearchIcon
|
|
65
|
+
<SearchIcon
|
|
64
66
|
onClick={(e) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}}
|
|
68
|
-
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
onSubmit(searchValue);
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<SearchSvg />
|
|
69
72
|
</SearchIcon>
|
|
70
|
-
|
|
73
|
+
|
|
71
74
|
<SearchInput
|
|
72
75
|
type="search"
|
|
73
|
-
placeholder={
|
|
76
|
+
placeholder={
|
|
77
|
+
restProps.placeholder || "Search by Name / Email / Username"
|
|
78
|
+
}
|
|
74
79
|
value={searchValue}
|
|
75
|
-
onChange={handleInputChange}
|
|
80
|
+
onChange={onChange || handleInputChange}
|
|
76
81
|
onKeyPress={handleEnterPress}
|
|
77
82
|
borderRadius={restProps.borderRadius || "12px"}
|
|
78
83
|
border={restProps.border || "1px solid #DFE6E6"}
|
|
@@ -81,9 +86,9 @@ const SearchBar = ({
|
|
|
81
86
|
/>
|
|
82
87
|
{showSuggestions && (
|
|
83
88
|
<SuggestionList>
|
|
84
|
-
{suggestions.map((suggestion) => (
|
|
89
|
+
{suggestions.map((suggestion, index) => (
|
|
85
90
|
<SuggestionItem
|
|
86
|
-
key={
|
|
91
|
+
key={index}
|
|
87
92
|
onClick={() => handleSuggestionClick(suggestion)}
|
|
88
93
|
>
|
|
89
94
|
{suggestion}
|
|
@@ -92,13 +97,10 @@ const SearchBar = ({
|
|
|
92
97
|
</SuggestionList>
|
|
93
98
|
)}
|
|
94
99
|
{warning && <WarningText>{warning}</WarningText>}
|
|
95
|
-
{inFilter &&
|
|
96
|
-
|
|
97
|
-
}
|
|
100
|
+
{inFilter && <SearchFilterIcon />}
|
|
101
|
+
{hasCustomDropdown && <> {children} </>}
|
|
98
102
|
</SearchBarContainer>
|
|
99
|
-
|
|
100
|
-
<SearchFilterIcon />
|
|
101
|
-
}
|
|
103
|
+
{outFilter && <SearchFilterIcon />}
|
|
102
104
|
</Container>
|
|
103
105
|
);
|
|
104
106
|
};
|
|
@@ -107,12 +109,12 @@ SearchBar.propTypes = {
|
|
|
107
109
|
onSubmit: PropTypes.func,
|
|
108
110
|
warning: PropTypes.string,
|
|
109
111
|
asyncResult: PropTypes.func,
|
|
110
|
-
heightSize:PropTypes.string,
|
|
112
|
+
heightSize: PropTypes.string,
|
|
111
113
|
widthSize: PropTypes.string,
|
|
112
114
|
borderRadius: PropTypes.string,
|
|
113
115
|
border: PropTypes.string,
|
|
114
116
|
outlineColor: PropTypes.string,
|
|
115
|
-
inFilter: PropTypes.bool
|
|
117
|
+
inFilter: PropTypes.bool,
|
|
116
118
|
};
|
|
117
119
|
|
|
118
120
|
// SearchBar.defaultProps = {
|
|
@@ -9,8 +9,7 @@ export const Container = styled.div`
|
|
|
9
9
|
// justify-content: center;
|
|
10
10
|
align-items: center;
|
|
11
11
|
gap: 10px;
|
|
12
|
-
position: relative
|
|
13
|
-
|
|
12
|
+
position: relative;
|
|
14
13
|
`;
|
|
15
14
|
|
|
16
15
|
export const SearchBarContainer = styled.div`
|
|
@@ -19,26 +18,25 @@ export const SearchBarContainer = styled.div`
|
|
|
19
18
|
position: relative;
|
|
20
19
|
height: ${({ heightSize }) => heightSize || "50px"};
|
|
21
20
|
width: ${({ widthSize }) => widthSize || "100%"};
|
|
22
|
-
border: ${({ border}) => border || "1px solid #DFE6E6"};
|
|
21
|
+
border: ${({ border }) => border || "1px solid #DFE6E6"};
|
|
23
22
|
border-radius: ${({ borderRadius }) => borderRadius || "12px"};
|
|
24
|
-
background-color: #
|
|
23
|
+
background-color: #ffffff;
|
|
25
24
|
transition: box-shadow 0.2s ease;
|
|
26
25
|
transition: all 0.3s;
|
|
27
26
|
&:focus-within {
|
|
28
27
|
box-shadow: 0 0 0 1px ${({ outlineColor }) => outlineColor || "#FEBF10"};
|
|
29
|
-
transform: scale(1.01);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
svg{
|
|
30
|
+
svg {
|
|
33
31
|
margin-right: 20px;
|
|
34
|
-
// display: ${({display}) => display || "none"}
|
|
32
|
+
// display: ${({ display }) => display || "none"}
|
|
35
33
|
}
|
|
36
34
|
`;
|
|
37
35
|
|
|
38
36
|
export const SearchIcon = styled.div`
|
|
39
37
|
position: absolute;
|
|
40
38
|
margin-left: 12px;
|
|
41
|
-
color: #
|
|
39
|
+
color: #adb3b3;
|
|
42
40
|
font-size: 20px;
|
|
43
41
|
margin-top: 6px;
|
|
44
42
|
`;
|
|
@@ -51,14 +49,20 @@ export const SearchInput = styled.input`
|
|
|
51
49
|
border: none;
|
|
52
50
|
border-radius: ${({ borderRadius }) => borderRadius || "12px"};
|
|
53
51
|
font-size: 16px;
|
|
54
|
-
background-color: #
|
|
52
|
+
background-color: #ffffff;
|
|
55
53
|
color: #333333;
|
|
56
54
|
outline: none;
|
|
57
55
|
&::placeholder {
|
|
58
56
|
font-weight: 600;
|
|
59
57
|
font-size: 16px;
|
|
60
58
|
line-height: 22px;
|
|
61
|
-
color: #
|
|
59
|
+
color: #adb3b3;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:focus {
|
|
63
|
+
border: none;
|
|
64
|
+
box-shadow: none;
|
|
65
|
+
outline: none;
|
|
62
66
|
}
|
|
63
67
|
`;
|
|
64
68
|
|
|
@@ -83,7 +87,7 @@ export const SuggestionList = styled.ul`
|
|
|
83
87
|
padding: 0;
|
|
84
88
|
margin: 0;
|
|
85
89
|
list-style: none;
|
|
86
|
-
border: 1px solid
|
|
90
|
+
border: 1px solid #dfe6e6;
|
|
87
91
|
background-color: #f1f1f1;
|
|
88
92
|
z-index: 10;
|
|
89
93
|
`;
|
|
@@ -100,7 +104,6 @@ export const OptionIcon = styled(SearchFilterIcon)`
|
|
|
100
104
|
color: ${({ outlineColor }) => outlineColor || "#ADB3B3"};
|
|
101
105
|
font-size: 18px;
|
|
102
106
|
display: none;
|
|
103
|
-
|
|
104
107
|
`;
|
|
105
108
|
|
|
106
109
|
export const OptionIconSearch = styled(SearchFilterIcon)`
|