sag_components 1.0.973 → 1.0.975
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/dist/stories/components/BannerEventBoxList.js +5 -3
- package/dist/stories/components/BannerEventBoxList.style.js +8 -1
- package/dist/stories/components/DropdownMultiNew.js +48 -37
- package/dist/stories/components/DropdownMultiNew.style.js +18 -6
- package/dist/stories/components/DropdownNew.js +19 -11
- package/dist/stories/components/DropdownNew.style.js +0 -3
- package/dist/stories/components/DropdownSingleNew.js +30 -10
- package/dist/stories/components/DropdownSingleNew.style.js +18 -4
- package/package.json +1 -1
|
@@ -34,7 +34,8 @@ const BannerEventBoxList = props => {
|
|
|
34
34
|
linkText,
|
|
35
35
|
disableToggle,
|
|
36
36
|
bannerWidth,
|
|
37
|
-
loaderColor
|
|
37
|
+
loaderColor,
|
|
38
|
+
showDraft
|
|
38
39
|
} = props;
|
|
39
40
|
const [IsItemOpen, setIsItemOpen] = (0, _react.useState)(false);
|
|
40
41
|
const handleToggle = () => {
|
|
@@ -95,7 +96,7 @@ const BannerEventBoxList = props => {
|
|
|
95
96
|
onInfoClick: () => retailerFile(item === null || item === void 0 ? void 0 : item.banner),
|
|
96
97
|
disabled: item === null || item === void 0 ? void 0 : item.disabled,
|
|
97
98
|
buttonText: item.buttonText
|
|
98
|
-
}))) : children));
|
|
99
|
+
})), showDraft && /*#__PURE__*/_react.default.createElement(_BannerEventBoxList.DraftTag, null, "DRAFT")) : children));
|
|
99
100
|
};
|
|
100
101
|
BannerEventBoxList.defaultProps = {
|
|
101
102
|
className: '',
|
|
@@ -146,6 +147,7 @@ BannerEventBoxList.defaultProps = {
|
|
|
146
147
|
disableToggle: true,
|
|
147
148
|
children: null,
|
|
148
149
|
bannerWidth: 'auto',
|
|
149
|
-
loaderColor: '#212121'
|
|
150
|
+
loaderColor: '#212121',
|
|
151
|
+
showDraft: false
|
|
150
152
|
};
|
|
151
153
|
var _default = exports.default = BannerEventBoxList;
|
|
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.ToggleContainer = exports.SubDetails = exports.ProductName = exports.MainDetails = exports.MainContainer = exports.LoaderWrapper = exports.Loader = exports.CollapseMenuItemMainContainer = exports.CollapseMenuItemContentContainer = exports.CollapseMenuItemContainer = exports.BannerIcon = void 0;
|
|
7
|
+
exports.ToggleContainer = exports.SubDetails = exports.ProductName = exports.MainDetails = exports.MainContainer = exports.LoaderWrapper = exports.Loader = exports.DraftTag = exports.CollapseMenuItemMainContainer = exports.CollapseMenuItemContentContainer = exports.CollapseMenuItemContainer = exports.BannerIcon = void 0;
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
const CollapseMenuItemMainContainer = exports.CollapseMenuItemMainContainer = _styledComponents.default.div`
|
|
10
10
|
font-family: "Poppins", sans-serif;
|
|
@@ -179,4 +179,11 @@ const MainContainer = exports.MainContainer = _styledComponents.default.div`
|
|
|
179
179
|
display: flex;
|
|
180
180
|
gap: 20px;
|
|
181
181
|
padding: 20px 0 4px;
|
|
182
|
+
`;
|
|
183
|
+
const DraftTag = exports.DraftTag = _styledComponents.default.div`
|
|
184
|
+
color: #E41111;
|
|
185
|
+
border: 2px solid #E41111;
|
|
186
|
+
font-size: 20px;
|
|
187
|
+
padding: 6px 18px;
|
|
188
|
+
height: fit-content;
|
|
182
189
|
`;
|
|
@@ -12,15 +12,12 @@ var _MenuItemOpenIcon = require("./icons/MenuItemOpenIcon");
|
|
|
12
12
|
var _CheckBoxCheckedIcon = require("./icons/CheckBoxCheckedIcon");
|
|
13
13
|
var _CheckBoxNotCheckedIcon = require("./icons/CheckBoxNotCheckedIcon");
|
|
14
14
|
var _DropdownMultiNew = require("./DropdownMultiNew.style");
|
|
15
|
-
/* eslint-disable react/prop-types */
|
|
16
|
-
|
|
17
15
|
const DropdownMultiNew = _ref => {
|
|
18
16
|
let {
|
|
19
17
|
label,
|
|
20
18
|
labelEmptyValue,
|
|
21
19
|
options,
|
|
22
20
|
selectedValue,
|
|
23
|
-
placeHolder,
|
|
24
21
|
onChange,
|
|
25
22
|
required,
|
|
26
23
|
disabled,
|
|
@@ -30,17 +27,37 @@ const DropdownMultiNew = _ref => {
|
|
|
30
27
|
labelColor,
|
|
31
28
|
xIconShow,
|
|
32
29
|
checkBoxColor,
|
|
33
|
-
showLabelOnTop
|
|
30
|
+
showLabelOnTop,
|
|
31
|
+
orderBy,
|
|
32
|
+
elementType
|
|
34
33
|
} = _ref;
|
|
35
34
|
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
36
35
|
const [showOptions, setShowOptions] = (0, _react.useState)(false);
|
|
37
|
-
const [inputValue, setInputValue] = (0, _react.useState)(
|
|
36
|
+
const [inputValue, setInputValue] = (0, _react.useState)("");
|
|
38
37
|
const [selectedOptions, setSelectedOptions] = (0, _react.useState)([]);
|
|
39
38
|
const [hoverInputContainer, setHoverInputContainer] = (0, _react.useState)(false);
|
|
40
39
|
const [hoverOptionsContainer, setHoverOptionsContainer] = (0, _react.useState)(false);
|
|
41
40
|
const inputRef = (0, _react.useRef)(null);
|
|
42
41
|
const containerRef = (0, _react.useRef)(null);
|
|
43
|
-
|
|
42
|
+
let filteredOptions = options === null || options === void 0 ? void 0 : options.filter(option => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
43
|
+
switch (orderBy) {
|
|
44
|
+
case "asc":
|
|
45
|
+
filteredOptions = filteredOptions.sort((a, b) => a.label.localeCompare(b.label));
|
|
46
|
+
break;
|
|
47
|
+
case "element":
|
|
48
|
+
if (elementType === "number") {
|
|
49
|
+
filteredOptions = filteredOptions.sort((a, b) => a.element - b.element);
|
|
50
|
+
} else {
|
|
51
|
+
filteredOptions = filteredOptions.sort((a, b) => {
|
|
52
|
+
const dateA = new Date(a.element.split("-").reverse().join("-"));
|
|
53
|
+
const dateB = new Date(b.element.split("-").reverse().join("-"));
|
|
54
|
+
return dateB - dateA;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
44
61
|
(0, _react.useEffect)(() => {
|
|
45
62
|
if (selectedValue) {
|
|
46
63
|
setSelectedOptions(selectedValue);
|
|
@@ -62,13 +79,6 @@ const DropdownMultiNew = _ref => {
|
|
|
62
79
|
setIsFocused(true);
|
|
63
80
|
setShowOptions(true);
|
|
64
81
|
};
|
|
65
|
-
|
|
66
|
-
// const handleBlur = () => {
|
|
67
|
-
// if (isMulti) return;
|
|
68
|
-
// setIsFocused(false);
|
|
69
|
-
// setTimeout(() => setShowOptions(false), 200); // Delay hiding options to allow clicking on them
|
|
70
|
-
// };
|
|
71
|
-
|
|
72
82
|
const toggleOption = option => {
|
|
73
83
|
if (disabled) return;
|
|
74
84
|
const selectedIndex = selectedOptions.findIndex(selectedOption => selectedOption.value === option.value);
|
|
@@ -141,37 +151,36 @@ const DropdownMultiNew = _ref => {
|
|
|
141
151
|
width: "8px",
|
|
142
152
|
height: "8px",
|
|
143
153
|
fill: "#212121"
|
|
144
|
-
})) :
|
|
154
|
+
})) : " ";
|
|
145
155
|
}), selectedOptions.length > 2 ? /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.SelectedOptionItem, {
|
|
146
156
|
className: "SelectedOptionItem"
|
|
147
|
-
}, selectedOptions.length - 2, "+") :
|
|
157
|
+
}, selectedOptions.length - 2, "+") : "");
|
|
148
158
|
return content;
|
|
149
159
|
};
|
|
150
160
|
const getLabel = () => {
|
|
151
161
|
if (!showLabelOnTop && isFocused) {
|
|
152
|
-
return
|
|
162
|
+
return "";
|
|
153
163
|
}
|
|
154
164
|
if ((selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) > 0) {
|
|
155
165
|
return label;
|
|
156
166
|
}
|
|
157
167
|
return labelEmptyValue;
|
|
158
|
-
// selectedOptions?.length > 0 ? label : labelEmptyValue}
|
|
159
168
|
};
|
|
160
169
|
const getRequired = () => {
|
|
161
170
|
if (!showLabelOnTop && isFocused) {
|
|
162
|
-
return
|
|
171
|
+
return "";
|
|
163
172
|
}
|
|
164
173
|
if (!showLabelOnTop && !label && (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) > 0) {
|
|
165
|
-
return
|
|
174
|
+
return "";
|
|
166
175
|
}
|
|
167
176
|
if (required) {
|
|
168
177
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
169
178
|
style: {
|
|
170
|
-
color:
|
|
179
|
+
color: "red"
|
|
171
180
|
}
|
|
172
181
|
}, "*");
|
|
173
182
|
}
|
|
174
|
-
return
|
|
183
|
+
return "";
|
|
175
184
|
};
|
|
176
185
|
return /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.DropdownWrapper, {
|
|
177
186
|
className: "DropdownWrapper",
|
|
@@ -210,10 +219,10 @@ const DropdownMultiNew = _ref => {
|
|
|
210
219
|
onClick: handleLabelClick,
|
|
211
220
|
type: "search",
|
|
212
221
|
disabled: disabled,
|
|
213
|
-
placeholder: isFocused ?
|
|
222
|
+
placeholder: isFocused ? filteredOptions.length <= 5 ? "Select Option…" : "Type To Search" : "",
|
|
214
223
|
error: error,
|
|
215
224
|
isFocused: isFocused
|
|
216
|
-
}) :
|
|
225
|
+
}) : " "), selectedOptions.length > 0 && xIconShow && /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.IconContainer, {
|
|
217
226
|
className: "IconContainer",
|
|
218
227
|
onClick: handleClearClick
|
|
219
228
|
}, /*#__PURE__*/_react.default.createElement(_CloseXIcon.CloseXIcon, {
|
|
@@ -237,45 +246,47 @@ const DropdownMultiNew = _ref => {
|
|
|
237
246
|
onMouseLeave: () => setHoverOptionsContainer(false),
|
|
238
247
|
showoptions: showOptions,
|
|
239
248
|
disabled: disabled,
|
|
240
|
-
filteredoptions:
|
|
249
|
+
filteredoptions: filteredOptions
|
|
241
250
|
}, /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.OptionsSubContainer, {
|
|
242
251
|
className: "OptionsSubContainer",
|
|
243
252
|
showoptions: showOptions,
|
|
244
253
|
disabled: disabled,
|
|
245
|
-
filteredoptions:
|
|
246
|
-
},
|
|
254
|
+
filteredoptions: filteredOptions
|
|
255
|
+
}, filteredOptions.map(option => /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.OptionItem, {
|
|
247
256
|
className: "OptionItem",
|
|
248
257
|
key: option.value,
|
|
249
258
|
onClick: () => toggleOption(option),
|
|
250
259
|
selected: isDropdowned(option)
|
|
251
|
-
},
|
|
260
|
+
}, " ", /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.IconContainer, {
|
|
252
261
|
className: "IconContainer"
|
|
253
262
|
}, selectedOptions.find(itemSelectedOptions => option.value === itemSelectedOptions.value) ? /*#__PURE__*/_react.default.createElement(_CheckBoxCheckedIcon.CheckBoxCheckedIcon, {
|
|
254
263
|
width: "14px",
|
|
255
264
|
height: "14px",
|
|
256
|
-
color: disabled ?
|
|
265
|
+
color: disabled ? "#888" : checkBoxColor
|
|
257
266
|
}) : /*#__PURE__*/_react.default.createElement(_CheckBoxNotCheckedIcon.CheckBoxNotCheckedIcon, {
|
|
258
267
|
width: "14px",
|
|
259
268
|
height: "14px",
|
|
260
|
-
color: disabled ?
|
|
269
|
+
color: disabled ? "#888" : "#212121"
|
|
261
270
|
})), option.label)))));
|
|
262
271
|
};
|
|
263
272
|
exports.DropdownMultiNew = DropdownMultiNew;
|
|
264
273
|
var _default = exports.default = DropdownMultiNew;
|
|
265
274
|
DropdownMultiNew.defaultProps = {
|
|
266
|
-
placeHolder:
|
|
267
|
-
label:
|
|
268
|
-
labelEmptyValue:
|
|
269
|
-
labelColor:
|
|
270
|
-
checkBoxColor:
|
|
275
|
+
placeHolder: "Type To Search",
|
|
276
|
+
label: "Label",
|
|
277
|
+
labelEmptyValue: "All Labels",
|
|
278
|
+
labelColor: "#066768",
|
|
279
|
+
checkBoxColor: "#229E38",
|
|
271
280
|
required: true,
|
|
272
|
-
width:
|
|
281
|
+
width: "300px",
|
|
273
282
|
disabled: false,
|
|
274
283
|
error: false,
|
|
275
|
-
errorMessage:
|
|
284
|
+
errorMessage: "",
|
|
276
285
|
options: [],
|
|
277
286
|
selectedValue: [],
|
|
278
287
|
xIconShow: true,
|
|
279
288
|
onChange: () => {},
|
|
280
|
-
showLabelOnTop: true
|
|
289
|
+
showLabelOnTop: true,
|
|
290
|
+
orderBy: "asc",
|
|
291
|
+
elementType: "number"
|
|
281
292
|
};
|
|
@@ -8,6 +8,23 @@ exports.StyledInput = exports.SelectedOptionsContainer = exports.SelectedOptionI
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
/* eslint-disable no-nested-ternary */
|
|
10
10
|
|
|
11
|
+
const scrollableStyles = `
|
|
12
|
+
overflow-y: auto;
|
|
13
|
+
|
|
14
|
+
&::-webkit-scrollbar {
|
|
15
|
+
width: 4px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&::-webkit-scrollbar-track {
|
|
19
|
+
background: #E8E8E8;
|
|
20
|
+
border-radius: 5px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&::-webkit-scrollbar-thumb {
|
|
24
|
+
background: #D0D0D0;
|
|
25
|
+
border-radius: 5px;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
11
28
|
const DropdownWrapper = exports.DropdownWrapper = _styledComponents.default.div`
|
|
12
29
|
position: relative;
|
|
13
30
|
display: flex;
|
|
@@ -22,7 +39,6 @@ const DropdownWrapper = exports.DropdownWrapper = _styledComponents.default.div`
|
|
|
22
39
|
border-radius: 10px;
|
|
23
40
|
`;
|
|
24
41
|
const Label = exports.Label = _styledComponents.default.label`
|
|
25
|
-
|
|
26
42
|
font-size: ${props => props.isFocused || props.hasValue ? '14px' : '14px'};
|
|
27
43
|
font-weight: 400;
|
|
28
44
|
padding-inline-end: 5px;
|
|
@@ -46,7 +62,6 @@ const Label = exports.Label = _styledComponents.default.label`
|
|
|
46
62
|
}
|
|
47
63
|
`;
|
|
48
64
|
const InputContainer = exports.InputContainer = _styledComponents.default.div`
|
|
49
|
-
|
|
50
65
|
display: flex;
|
|
51
66
|
flex-direction: row;
|
|
52
67
|
flex-wrap: nowrap;
|
|
@@ -69,16 +84,13 @@ const InputContainer = exports.InputContainer = _styledComponents.default.div`
|
|
|
69
84
|
border-radius: 12px;
|
|
70
85
|
outline: none;
|
|
71
86
|
color: ${props => props.disabled ? '#888' : '#212121'};
|
|
72
|
-
|
|
73
87
|
&:hover {
|
|
74
88
|
border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelColor || '#212121'};
|
|
75
89
|
cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
|
|
76
90
|
}
|
|
77
|
-
|
|
78
91
|
&:focus {
|
|
79
92
|
border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelColor || '#212121'};
|
|
80
93
|
}
|
|
81
|
-
|
|
82
94
|
`;
|
|
83
95
|
const InputSubContainer = exports.InputSubContainer = _styledComponents.default.div`
|
|
84
96
|
|
|
@@ -122,9 +134,9 @@ const OptionsContainer = exports.OptionsContainer = _styledComponents.default.di
|
|
|
122
134
|
var _props$filteredoption;
|
|
123
135
|
return props.showoptions && ((_props$filteredoption = props.filteredoptions) === null || _props$filteredoption === void 0 ? void 0 : _props$filteredoption.length) > 0 ? 'block' : 'none';
|
|
124
136
|
}};
|
|
125
|
-
|
|
126
137
|
`;
|
|
127
138
|
const OptionsSubContainer = exports.OptionsSubContainer = _styledComponents.default.ul`
|
|
139
|
+
${scrollableStyles}
|
|
128
140
|
list-style: none;
|
|
129
141
|
font-weight: 400;
|
|
130
142
|
margin: 0;
|
|
@@ -28,7 +28,9 @@ const DropdownNew = _ref => {
|
|
|
28
28
|
labelColor,
|
|
29
29
|
checkBoxColor,
|
|
30
30
|
xIconShow,
|
|
31
|
-
showLabelOnTop
|
|
31
|
+
showLabelOnTop,
|
|
32
|
+
orderBy,
|
|
33
|
+
elementType
|
|
32
34
|
} = _ref;
|
|
33
35
|
return /*#__PURE__*/_react.default.createElement(_DropdownNew.DropdownMain, {
|
|
34
36
|
className: "DropdownMain",
|
|
@@ -49,7 +51,9 @@ const DropdownNew = _ref => {
|
|
|
49
51
|
selectedValue: selectedValue,
|
|
50
52
|
xIconShow: xIconShow,
|
|
51
53
|
onChange: onChange,
|
|
52
|
-
showLabelOnTop: showLabelOnTop
|
|
54
|
+
showLabelOnTop: showLabelOnTop,
|
|
55
|
+
orderBy: orderBy,
|
|
56
|
+
elementType: elementType
|
|
53
57
|
}) : /*#__PURE__*/_react.default.createElement(_DropdownSingleNew.DropdownSingleNew, {
|
|
54
58
|
className: "DropdownSingleNew",
|
|
55
59
|
placeHolder: placeHolder,
|
|
@@ -66,25 +70,29 @@ const DropdownNew = _ref => {
|
|
|
66
70
|
selectedValue: selectedValue,
|
|
67
71
|
xIconShow: xIconShow,
|
|
68
72
|
onChange: onChange,
|
|
69
|
-
showLabelOnTop: showLabelOnTop
|
|
73
|
+
showLabelOnTop: showLabelOnTop,
|
|
74
|
+
orderBy: orderBy,
|
|
75
|
+
elementType: elementType
|
|
70
76
|
}));
|
|
71
77
|
};
|
|
72
78
|
exports.DropdownNew = DropdownNew;
|
|
73
79
|
var _default = exports.default = DropdownNew;
|
|
74
80
|
DropdownNew.defaultProps = {
|
|
75
|
-
placeHolder:
|
|
76
|
-
label:
|
|
77
|
-
labelEmptyValue:
|
|
78
|
-
labelColor:
|
|
79
|
-
checkBoxColor:
|
|
81
|
+
placeHolder: "Type...",
|
|
82
|
+
label: "Label",
|
|
83
|
+
labelEmptyValue: "All Labels",
|
|
84
|
+
labelColor: "#066768",
|
|
85
|
+
checkBoxColor: "#229E38",
|
|
80
86
|
required: true,
|
|
81
|
-
width:
|
|
87
|
+
width: "300px",
|
|
82
88
|
disabled: false,
|
|
83
89
|
error: false,
|
|
84
|
-
errorMessage:
|
|
90
|
+
errorMessage: "",
|
|
85
91
|
options: [],
|
|
86
92
|
selectedValue: [],
|
|
87
93
|
xIconShow: true,
|
|
88
94
|
onChange: () => {},
|
|
89
|
-
showLabelOnTop: true
|
|
95
|
+
showLabelOnTop: true,
|
|
96
|
+
orderBy: "asc",
|
|
97
|
+
elementType: "number"
|
|
90
98
|
};
|
|
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.DropdownMain = void 0;
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
/* eslint-disable no-nested-ternary */
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
12
9
|
const DropdownMain = exports.DropdownMain = _styledComponents.default.div`
|
|
13
10
|
position: relative;
|
|
14
11
|
display: flex;
|
|
@@ -18,7 +18,6 @@ const DropdownSingleNew = _ref => {
|
|
|
18
18
|
labelEmptyValue,
|
|
19
19
|
options,
|
|
20
20
|
selectedValue,
|
|
21
|
-
placeHolder,
|
|
22
21
|
onChange,
|
|
23
22
|
required,
|
|
24
23
|
disabled,
|
|
@@ -27,7 +26,9 @@ const DropdownSingleNew = _ref => {
|
|
|
27
26
|
errorMessage,
|
|
28
27
|
xIconShow,
|
|
29
28
|
labelColor,
|
|
30
|
-
showLabelOnTop
|
|
29
|
+
showLabelOnTop,
|
|
30
|
+
orderBy,
|
|
31
|
+
elementType
|
|
31
32
|
} = _ref;
|
|
32
33
|
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
33
34
|
const [showOptions, setShowOptions] = (0, _react.useState)(false);
|
|
@@ -37,7 +38,25 @@ const DropdownSingleNew = _ref => {
|
|
|
37
38
|
const [hoverOptionsContainer, setHoverOptionsContainer] = (0, _react.useState)(false);
|
|
38
39
|
const inputRef = (0, _react.useRef)(null);
|
|
39
40
|
const containerRef = (0, _react.useRef)(null);
|
|
40
|
-
|
|
41
|
+
let filteredOptions = options === null || options === void 0 ? void 0 : options.filter(option => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
42
|
+
switch (orderBy) {
|
|
43
|
+
case "asc":
|
|
44
|
+
filteredOptions = filteredOptions.sort((a, b) => a.label.localeCompare(b.label));
|
|
45
|
+
break;
|
|
46
|
+
case "element":
|
|
47
|
+
if (elementType === "number") {
|
|
48
|
+
filteredOptions = filteredOptions.sort((a, b) => a.element - b.element);
|
|
49
|
+
} else {
|
|
50
|
+
filteredOptions = filteredOptions.sort((a, b) => {
|
|
51
|
+
const dateA = new Date(a.element.split("-").reverse().join("-"));
|
|
52
|
+
const dateB = new Date(b.element.split("-").reverse().join("-"));
|
|
53
|
+
return dateB - dateA;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
41
60
|
(0, _react.useEffect)(() => {
|
|
42
61
|
if (selectedValue) {
|
|
43
62
|
setSelectedOptions(selectedValue);
|
|
@@ -123,7 +142,6 @@ const DropdownSingleNew = _ref => {
|
|
|
123
142
|
return label;
|
|
124
143
|
}
|
|
125
144
|
return labelEmptyValue;
|
|
126
|
-
// selectedOptions?.length > 0 ? label : labelEmptyValue}
|
|
127
145
|
};
|
|
128
146
|
const getRequired = () => {
|
|
129
147
|
if (!showLabelOnTop && isFocused) {
|
|
@@ -176,7 +194,7 @@ const DropdownSingleNew = _ref => {
|
|
|
176
194
|
onChange: handleInputChange,
|
|
177
195
|
onClick: handleLabelClick,
|
|
178
196
|
disabled: disabled,
|
|
179
|
-
placeholder: isFocused ?
|
|
197
|
+
placeholder: isFocused ? filteredOptions.length <= 5 ? "Select Option…" : "Type To Search" : "",
|
|
180
198
|
error: error,
|
|
181
199
|
isFocused: isFocused
|
|
182
200
|
})), selectedOptions.length > 0 && xIconShow && /*#__PURE__*/_react.default.createElement(_DropdownSingleNew.IconContainer, {
|
|
@@ -203,13 +221,13 @@ const DropdownSingleNew = _ref => {
|
|
|
203
221
|
onMouseLeave: () => setHoverOptionsContainer(false),
|
|
204
222
|
showoptions: showOptions,
|
|
205
223
|
disabled: disabled,
|
|
206
|
-
filteredoptions:
|
|
224
|
+
filteredoptions: filteredOptions
|
|
207
225
|
}, /*#__PURE__*/_react.default.createElement(_DropdownSingleNew.OptionsSubContainer, {
|
|
208
226
|
className: "OptionsSubContainer",
|
|
209
227
|
showoptions: showOptions,
|
|
210
228
|
disabled: disabled,
|
|
211
|
-
filteredoptions:
|
|
212
|
-
},
|
|
229
|
+
filteredoptions: filteredOptions
|
|
230
|
+
}, filteredOptions.map(option => /*#__PURE__*/_react.default.createElement(_DropdownSingleNew.OptionItem, {
|
|
213
231
|
className: "OptionItem",
|
|
214
232
|
key: option.value,
|
|
215
233
|
onClick: () => toggleOption(option),
|
|
@@ -219,7 +237,7 @@ const DropdownSingleNew = _ref => {
|
|
|
219
237
|
exports.DropdownSingleNew = DropdownSingleNew;
|
|
220
238
|
var _default = exports.default = DropdownSingleNew;
|
|
221
239
|
DropdownSingleNew.defaultProps = {
|
|
222
|
-
placeHolder: "Type
|
|
240
|
+
placeHolder: "Type To Search",
|
|
223
241
|
label: "Label",
|
|
224
242
|
labelEmptyValue: "All Labels",
|
|
225
243
|
labelColor: "#066768",
|
|
@@ -232,5 +250,7 @@ DropdownSingleNew.defaultProps = {
|
|
|
232
250
|
selectedValue: [],
|
|
233
251
|
xIconShow: true,
|
|
234
252
|
onChange: () => {},
|
|
235
|
-
showLabelOnTop: true
|
|
253
|
+
showLabelOnTop: true,
|
|
254
|
+
orderBy: "asc",
|
|
255
|
+
elementType: "number"
|
|
236
256
|
};
|
|
@@ -8,6 +8,23 @@ exports.StyledInput = exports.OptionsSubContainer = exports.OptionsContainer = e
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
/* eslint-disable no-nested-ternary */
|
|
10
10
|
|
|
11
|
+
const scrollableStyles = `
|
|
12
|
+
overflow-y: auto;
|
|
13
|
+
|
|
14
|
+
&::-webkit-scrollbar {
|
|
15
|
+
width: 4px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&::-webkit-scrollbar-track {
|
|
19
|
+
background: #E8E8E8;
|
|
20
|
+
border-radius: 5px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&::-webkit-scrollbar-thumb {
|
|
24
|
+
background: #D0D0D0;
|
|
25
|
+
border-radius: 5px;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
11
28
|
const DropdownWrapper = exports.DropdownWrapper = _styledComponents.default.div`
|
|
12
29
|
position: relative;
|
|
13
30
|
display: flex;
|
|
@@ -45,7 +62,6 @@ const Label = exports.Label = _styledComponents.default.label`
|
|
|
45
62
|
}
|
|
46
63
|
`;
|
|
47
64
|
const InputContainer = exports.InputContainer = _styledComponents.default.div`
|
|
48
|
-
|
|
49
65
|
display: flex;
|
|
50
66
|
flex-direction: row;
|
|
51
67
|
flex-wrap: nowrap;
|
|
@@ -68,19 +84,16 @@ const InputContainer = exports.InputContainer = _styledComponents.default.div`
|
|
|
68
84
|
border-radius: 12px;
|
|
69
85
|
outline: none;
|
|
70
86
|
color: ${props => props.disabled ? '#888' : '#212121'};
|
|
71
|
-
|
|
72
87
|
&:hover {
|
|
73
88
|
border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelColor || '#212121'};
|
|
74
89
|
cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
|
|
75
90
|
}
|
|
76
|
-
|
|
77
91
|
&:focus {
|
|
78
92
|
border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelColor || '#212121'};
|
|
79
93
|
}
|
|
80
94
|
|
|
81
95
|
`;
|
|
82
96
|
const InputSubContainer = exports.InputSubContainer = _styledComponents.default.div`
|
|
83
|
-
|
|
84
97
|
display: flex;
|
|
85
98
|
flex-direction: column;
|
|
86
99
|
flex-wrap: nowrap;
|
|
@@ -123,6 +136,7 @@ const OptionsContainer = exports.OptionsContainer = _styledComponents.default.di
|
|
|
123
136
|
}};
|
|
124
137
|
`;
|
|
125
138
|
const OptionsSubContainer = exports.OptionsSubContainer = _styledComponents.default.ul`
|
|
139
|
+
${scrollableStyles}
|
|
126
140
|
list-style: none;
|
|
127
141
|
font-weight: 400;
|
|
128
142
|
margin: 0;
|