intelicoreact 1.1.20 → 1.1.22
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.
|
@@ -124,17 +124,15 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
124
124
|
return option.items = moveOtherToEnd(option.items);
|
|
125
125
|
} else return option;
|
|
126
126
|
});
|
|
127
|
-
var filteredGroups = optionsWithOtherAtTheEnd.
|
|
127
|
+
var filteredGroups = optionsWithOtherAtTheEnd.map(function (item) {
|
|
128
128
|
var _item$items;
|
|
129
129
|
|
|
130
|
-
return (_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.length;
|
|
131
|
-
}).map(function (item) {
|
|
132
130
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
133
|
-
items: isSearchable ? item.items.filter(function (el) {
|
|
131
|
+
items: !isSearchable || !isSearchChanged ? item === null || item === void 0 ? void 0 : item.items : (_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.slice().filter(function (el) {
|
|
134
132
|
var _el$label;
|
|
135
133
|
|
|
136
|
-
return
|
|
137
|
-
})
|
|
134
|
+
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()) || '')) || !(el !== null && el !== void 0 && el.value) || (el === null || el === void 0 ? void 0 : el.value) === '';
|
|
135
|
+
})
|
|
138
136
|
});
|
|
139
137
|
}).filter(function (item) {
|
|
140
138
|
var _item$items2;
|
|
@@ -148,7 +146,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
148
146
|
}).filter(function (item) {
|
|
149
147
|
var _item$label;
|
|
150
148
|
|
|
151
|
-
|
|
149
|
+
if (!isSearchable || !isSearchChanged) return true;
|
|
150
|
+
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) === '';
|
|
152
151
|
});
|
|
153
152
|
var filteredOptions = [].concat((0, _toConsumableArray2.default)(filteredItems), (0, _toConsumableArray2.default)(filteredGroups));
|
|
154
153
|
var modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
|
|
@@ -227,7 +226,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
227
226
|
return /*#__PURE__*/_react.default.createElement("button", {
|
|
228
227
|
"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"),
|
|
229
228
|
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, '_'),
|
|
230
|
-
|
|
229
|
+
onMouseDown: function onMouseDown() {
|
|
231
230
|
return depend.onChange(item);
|
|
232
231
|
},
|
|
233
232
|
className: (0, _classnames.default)("".concat(RC, "__list-item"), (_cn = {}, (0, _defineProperty2.default)(_cn, "".concat(RC, "__list-item_active"), item.value === value), (0, _defineProperty2.default)(_cn, "".concat(RC, "__list-item_disabled"), item.disabled), _cn), item.className)
|
|
@@ -366,6 +365,13 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
366
365
|
}, noOptionsText), disabled && isOpen && /*#__PURE__*/_react.default.createElement(_DropdownLoader.default, null));
|
|
367
366
|
};
|
|
368
367
|
|
|
368
|
+
var toggleList = function toggleList(e) {
|
|
369
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
370
|
+
setIsOpen(function (isOpen) {
|
|
371
|
+
return !isOpen;
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
|
|
369
375
|
var closeList = handleClickOutside;
|
|
370
376
|
(0, _react.useEffect)(function () {
|
|
371
377
|
initListContainer();
|
|
@@ -415,17 +421,20 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
415
421
|
};
|
|
416
422
|
|
|
417
423
|
(0, _react.useEffect)(function () {
|
|
418
|
-
if (!searchValue &&
|
|
424
|
+
if (!searchValue && isSearchInputFocused) {
|
|
419
425
|
setSearchValue(selectedLabel);
|
|
420
426
|
setTimeout(function () {
|
|
421
427
|
return searchInputRef.current.select();
|
|
422
428
|
}, 1);
|
|
423
429
|
}
|
|
424
430
|
|
|
425
|
-
if (!isSearchInputFocused) {
|
|
431
|
+
if (!isSearchInputFocused && !isOpen) {
|
|
426
432
|
setSearchValue(null);
|
|
427
433
|
}
|
|
428
|
-
}, [
|
|
434
|
+
}, [isSearchInputFocused]);
|
|
435
|
+
(0, _react.useEffect)(function () {
|
|
436
|
+
if (isOpen && !isSearchInputFocused) searchInputRef.current.focus();
|
|
437
|
+
}, [isOpen]);
|
|
429
438
|
var postfixText = selectedLabel && ((_filteredOptions$find = filteredOptions.find(function (option) {
|
|
430
439
|
return option.value === value;
|
|
431
440
|
})) === null || _filteredOptions$find === void 0 ? void 0 : _filteredOptions$find.postfix) || null;
|
|
@@ -439,18 +448,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
439
448
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
440
449
|
"data-testid": "dropdown--".concat(testId || '', "--container"),
|
|
441
450
|
className: "".concat(RC, "__trigger input__wrap ").concat(isOpen ? 'input__wrap--focus' : '', " ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : ''),
|
|
442
|
-
onClick:
|
|
443
|
-
e.stopPropagation();
|
|
444
|
-
setIsOpen(!isOpen);
|
|
445
|
-
},
|
|
446
|
-
onMouseDown: function onMouseDown() {
|
|
447
|
-
return setIsFocusedByClick(true);
|
|
448
|
-
},
|
|
451
|
+
onClick: toggleList,
|
|
449
452
|
onKeyDown: onKeyDown,
|
|
450
|
-
onKeyUp: onKeyUp
|
|
451
|
-
onFocus: function onFocus() {
|
|
452
|
-
return !isFocusedByClick ? setIsOpen(true) : null;
|
|
453
|
-
}
|
|
453
|
+
onKeyUp: onKeyUp
|
|
454
454
|
}, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
|
|
455
455
|
ref: searchInputRef,
|
|
456
456
|
className: "".concat(RC, "__input"),
|
|
@@ -465,8 +465,11 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
465
465
|
onBlur: function onBlur() {
|
|
466
466
|
return setIsSearchInputFocused(false);
|
|
467
467
|
},
|
|
468
|
-
|
|
469
|
-
if (!isOpen)
|
|
468
|
+
onMouseDown: function onMouseDown() {
|
|
469
|
+
if (!isOpen) {
|
|
470
|
+
setIsSearchInputFocused(true);
|
|
471
|
+
setIsOpen(true);
|
|
472
|
+
}
|
|
470
473
|
}
|
|
471
474
|
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
472
475
|
className: "text"
|
|
@@ -474,10 +477,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
474
477
|
className: "dropdown__list-item-postfix"
|
|
475
478
|
}, postfixText)), /*#__PURE__*/_react.default.createElement("span", {
|
|
476
479
|
className: (0, _classnames.default)("".concat(RC, "__arrow"), (0, _defineProperty2.default)({}, "".concat(RC, "__arrow_active"), isOpen)),
|
|
477
|
-
onClick:
|
|
478
|
-
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
479
|
-
setIsOpen(!isOpen);
|
|
480
|
-
}
|
|
480
|
+
onClick: toggleList
|
|
481
481
|
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && renderListContainer());
|
|
482
482
|
};
|
|
483
483
|
|