intelicoreact 1.1.18 → 1.1.19
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.
|
@@ -90,8 +90,13 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
90
90
|
|
|
91
91
|
var _useState7 = (0, _react.useState)(false),
|
|
92
92
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
isSearchChanged = _useState8[0],
|
|
94
|
+
setIsSearchChanged = _useState8[1];
|
|
95
|
+
|
|
96
|
+
var _useState9 = (0, _react.useState)(false),
|
|
97
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
98
|
+
isFocusedByClick = _useState10[0],
|
|
99
|
+
setIsFocusedByClick = _useState10[1];
|
|
95
100
|
|
|
96
101
|
if (!options) return null;
|
|
97
102
|
|
|
@@ -123,7 +128,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
123
128
|
items: item.items.filter(function (el) {
|
|
124
129
|
var _el$label;
|
|
125
130
|
|
|
126
|
-
return el === null || el === void 0 ? void 0 : (_el$label = el.label) === null || _el$label === void 0 ? void 0 : _el$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '');
|
|
131
|
+
return isSearchChanged ? el === null || el === void 0 ? void 0 : (_el$label = el.label) === null || _el$label === void 0 ? void 0 : _el$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '') : true;
|
|
127
132
|
})
|
|
128
133
|
});
|
|
129
134
|
}).filter(function (item) {
|
|
@@ -138,7 +143,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
138
143
|
}).filter(function (item) {
|
|
139
144
|
var _item$label;
|
|
140
145
|
|
|
141
|
-
return (item === null || item === void 0 ? void 0 : (_item$label = item.label) === null || _item$label === void 0 ? void 0 : _item$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(item !== null && item !== void 0 && item.value) || (item === null || item === void 0 ? void 0 : item.value) === '';
|
|
146
|
+
return isSearchChanged ? (item === null || item === void 0 ? void 0 : (_item$label = item.label) === null || _item$label === void 0 ? void 0 : _item$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(item !== null && item !== void 0 && item.value) || (item === null || item === void 0 ? void 0 : item.value) === '' : true;
|
|
142
147
|
});
|
|
143
148
|
var filteredOptions = [].concat((0, _toConsumableArray2.default)(filteredItems), (0, _toConsumableArray2.default)(filteredGroups));
|
|
144
149
|
var modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
|
|
@@ -183,6 +188,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
183
188
|
var onSearchHandler = function onSearchHandler(name) {
|
|
184
189
|
var inputValue = name;
|
|
185
190
|
if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
|
|
191
|
+
setIsSearchChanged(true);
|
|
186
192
|
setSearchValue(inputValue);
|
|
187
193
|
};
|
|
188
194
|
|
|
@@ -211,9 +217,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
211
217
|
var depend = getDepends(modalBtnTrigger);
|
|
212
218
|
|
|
213
219
|
var getMarkupForElement = function getMarkupForElement(item, index, optTestId) {
|
|
214
|
-
var _item$
|
|
220
|
+
var _item$value, _item$value$toString, _item$value2, _item$value2$toString, _cn;
|
|
215
221
|
|
|
216
|
-
return
|
|
222
|
+
return /*#__PURE__*/_react.default.createElement("button", {
|
|
217
223
|
"data-testid": "dropdown--button--key-".concat(optTestId || (item === null || item === void 0 ? void 0 : (_item$value = item.value) === null || _item$value === void 0 ? void 0 : (_item$value$toString = _item$value.toString()) === null || _item$value$toString === void 0 ? void 0 : _item$value$toString.replace(/\s/, '-')) || (item === null || item === void 0 ? void 0 : item.key) || 'item', "--option"),
|
|
218
224
|
key: (_item$value2 = item.value) === null || _item$value2 === void 0 ? void 0 : (_item$value2$toString = _item$value2.toString()) === null || _item$value2$toString === void 0 ? void 0 : _item$value2$toString.replace(/ /g, '_'),
|
|
219
225
|
onClick: function onClick() {
|
|
@@ -227,7 +233,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
227
233
|
dangerouslySetInnerHTML: {
|
|
228
234
|
__html: hightlightedText(item.label, item.postfix)
|
|
229
235
|
}
|
|
230
|
-
}))
|
|
236
|
+
}));
|
|
231
237
|
};
|
|
232
238
|
|
|
233
239
|
var filteredOptionList = function filteredOptionList(filteredOption) {
|
|
@@ -379,7 +385,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
379
385
|
};
|
|
380
386
|
}, [value]);
|
|
381
387
|
(0, _react.useEffect)(function () {
|
|
382
|
-
if (!isOpen)
|
|
388
|
+
if (!isOpen) {
|
|
389
|
+
setIsFocusedByClick(false);
|
|
390
|
+
setIsSearchChanged(false);
|
|
391
|
+
}
|
|
383
392
|
|
|
384
393
|
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
|
|
385
394
|
dropdownListRef.current.addEventListener('scroll', doScrollCallback);
|