intelicoreact 1.1.17 → 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.
|
@@ -79,19 +79,19 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
79
79
|
searchValue = _useState4[0],
|
|
80
80
|
setSearchValue = _useState4[1];
|
|
81
81
|
|
|
82
|
-
var _useState5 = (0, _react.useState)(false),
|
|
83
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
84
|
-
isSearching = _useState6[0],
|
|
85
|
-
setIsSearching = _useState6[1];
|
|
86
|
-
|
|
87
82
|
var dropdownRef = (0, _react.useRef)(null);
|
|
88
83
|
var dropdownListRef = (0, _react.useRef)(null);
|
|
89
84
|
var searchInputRef = (0, _react.useRef)(null);
|
|
90
85
|
|
|
91
|
-
var
|
|
86
|
+
var _useState5 = (0, _react.useState)(null),
|
|
87
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
88
|
+
initListHeight = _useState6[0],
|
|
89
|
+
setInitListHeight = _useState6[1];
|
|
90
|
+
|
|
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
95
|
|
|
96
96
|
var _useState9 = (0, _react.useState)(false),
|
|
97
97
|
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
@@ -128,7 +128,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
128
128
|
items: item.items.filter(function (el) {
|
|
129
129
|
var _el$label;
|
|
130
130
|
|
|
131
|
-
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;
|
|
132
132
|
})
|
|
133
133
|
});
|
|
134
134
|
}).filter(function (item) {
|
|
@@ -143,7 +143,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
143
143
|
}).filter(function (item) {
|
|
144
144
|
var _item$label;
|
|
145
145
|
|
|
146
|
-
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;
|
|
147
147
|
});
|
|
148
148
|
var filteredOptions = [].concat((0, _toConsumableArray2.default)(filteredItems), (0, _toConsumableArray2.default)(filteredGroups));
|
|
149
149
|
var modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
|
|
@@ -188,6 +188,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
188
188
|
var onSearchHandler = function onSearchHandler(name) {
|
|
189
189
|
var inputValue = name;
|
|
190
190
|
if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
|
|
191
|
+
setIsSearchChanged(true);
|
|
191
192
|
setSearchValue(inputValue);
|
|
192
193
|
};
|
|
193
194
|
|
|
@@ -216,9 +217,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
216
217
|
var depend = getDepends(modalBtnTrigger);
|
|
217
218
|
|
|
218
219
|
var getMarkupForElement = function getMarkupForElement(item, index, optTestId) {
|
|
219
|
-
var _item$
|
|
220
|
+
var _item$value, _item$value$toString, _item$value2, _item$value2$toString, _cn;
|
|
220
221
|
|
|
221
|
-
return
|
|
222
|
+
return /*#__PURE__*/_react.default.createElement("button", {
|
|
222
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"),
|
|
223
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, '_'),
|
|
224
225
|
onClick: function onClick() {
|
|
@@ -232,7 +233,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
232
233
|
dangerouslySetInnerHTML: {
|
|
233
234
|
__html: hightlightedText(item.label, item.postfix)
|
|
234
235
|
}
|
|
235
|
-
}))
|
|
236
|
+
}));
|
|
236
237
|
};
|
|
237
238
|
|
|
238
239
|
var filteredOptionList = function filteredOptionList(filteredOption) {
|
|
@@ -384,7 +385,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
384
385
|
};
|
|
385
386
|
}, [value]);
|
|
386
387
|
(0, _react.useEffect)(function () {
|
|
387
|
-
if (!isOpen)
|
|
388
|
+
if (!isOpen) {
|
|
389
|
+
setIsFocusedByClick(false);
|
|
390
|
+
setIsSearchChanged(false);
|
|
391
|
+
}
|
|
388
392
|
|
|
389
393
|
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
|
|
390
394
|
dropdownListRef.current.addEventListener('scroll', doScrollCallback);
|
|
@@ -406,13 +410,13 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
406
410
|
};
|
|
407
411
|
|
|
408
412
|
(0, _react.useEffect)(function () {
|
|
409
|
-
if (isOpen
|
|
413
|
+
if (isOpen) {
|
|
410
414
|
setSearchValue(selectedLabel);
|
|
411
415
|
setTimeout(function () {
|
|
412
416
|
return searchInputRef.current.select();
|
|
413
417
|
}, 1);
|
|
414
418
|
}
|
|
415
|
-
}, [
|
|
419
|
+
}, [isOpen]);
|
|
416
420
|
var postfixText = selectedLabel && ((_filteredOptions$find = filteredOptions.find(function (option) {
|
|
417
421
|
return option.value === value;
|
|
418
422
|
})) === null || _filteredOptions$find === void 0 ? void 0 : _filteredOptions$find.postfix) || null;
|
|
@@ -427,7 +431,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
427
431
|
"data-testid": "dropdown--".concat(testId || '', "--container"),
|
|
428
432
|
className: "".concat(RC, "__trigger input__wrap ").concat(isOpen ? 'input__wrap--focus' : '', " ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : ''),
|
|
429
433
|
onClick: function onClick() {
|
|
430
|
-
return
|
|
434
|
+
return setIsOpen(!isOpen);
|
|
431
435
|
},
|
|
432
436
|
onMouseDown: function onMouseDown() {
|
|
433
437
|
return setIsFocusedByClick(true);
|
|
@@ -440,24 +444,11 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
440
444
|
}, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
|
|
441
445
|
ref: searchInputRef,
|
|
442
446
|
className: "".concat(RC, "__input"),
|
|
443
|
-
value:
|
|
447
|
+
value: isOpen ? searchValue !== null && searchValue !== void 0 ? searchValue : '' : selectedLabel || '',
|
|
444
448
|
onChange: function onChange(e) {
|
|
445
449
|
return onSearchHandler(e.target.value);
|
|
446
450
|
},
|
|
447
451
|
placeholder: placeholder,
|
|
448
|
-
onFocus: function onFocus(e) {
|
|
449
|
-
if (!isOpen) {
|
|
450
|
-
e.preventDefault();
|
|
451
|
-
e.stopPropagation();
|
|
452
|
-
e.target.blur();
|
|
453
|
-
return;
|
|
454
|
-
} else {
|
|
455
|
-
setIsSearching(true);
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
onBlur: function onBlur() {
|
|
459
|
-
return setIsSearching(false);
|
|
460
|
-
},
|
|
461
452
|
onClick: function onClick() {
|
|
462
453
|
if (!isOpen) setIsOpen(true);
|
|
463
454
|
}
|