intelicoreact 1.1.21 → 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,16 +124,14 @@ 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 === null || item === void 0 ? void 0 : item.items : 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
|
|
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) === '';
|
|
137
135
|
})
|
|
138
136
|
});
|
|
139
137
|
}).filter(function (item) {
|
|
@@ -148,15 +146,14 @@ 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';
|
|
155
154
|
|
|
156
155
|
var onChangeHandler = function onChangeHandler(item) {
|
|
157
156
|
setIsOpen(false);
|
|
158
|
-
setSearchValue(null);
|
|
159
|
-
setIsSearchChanged(false);
|
|
160
157
|
onChange(item.value);
|
|
161
158
|
}; // decorator
|
|
162
159
|
|
|
@@ -229,7 +226,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
229
226
|
return /*#__PURE__*/_react.default.createElement("button", {
|
|
230
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"),
|
|
231
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, '_'),
|
|
232
|
-
|
|
229
|
+
onMouseDown: function onMouseDown() {
|
|
233
230
|
return depend.onChange(item);
|
|
234
231
|
},
|
|
235
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)
|
|
@@ -368,6 +365,13 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
368
365
|
}, noOptionsText), disabled && isOpen && /*#__PURE__*/_react.default.createElement(_DropdownLoader.default, null));
|
|
369
366
|
};
|
|
370
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
|
+
|
|
371
375
|
var closeList = handleClickOutside;
|
|
372
376
|
(0, _react.useEffect)(function () {
|
|
373
377
|
initListContainer();
|
|
@@ -444,18 +448,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
444
448
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
445
449
|
"data-testid": "dropdown--".concat(testId || '', "--container"),
|
|
446
450
|
className: "".concat(RC, "__trigger input__wrap ").concat(isOpen ? 'input__wrap--focus' : '', " ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : ''),
|
|
447
|
-
onClick:
|
|
448
|
-
e.stopPropagation();
|
|
449
|
-
setIsOpen(!isOpen);
|
|
450
|
-
},
|
|
451
|
-
onMouseDown: function onMouseDown() {
|
|
452
|
-
return setIsFocusedByClick(true);
|
|
453
|
-
},
|
|
451
|
+
onClick: toggleList,
|
|
454
452
|
onKeyDown: onKeyDown,
|
|
455
|
-
onKeyUp: onKeyUp
|
|
456
|
-
onFocus: function onFocus() {
|
|
457
|
-
return !isFocusedByClick ? setIsOpen(true) : null;
|
|
458
|
-
}
|
|
453
|
+
onKeyUp: onKeyUp
|
|
459
454
|
}, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
|
|
460
455
|
ref: searchInputRef,
|
|
461
456
|
className: "".concat(RC, "__input"),
|
|
@@ -470,8 +465,11 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
470
465
|
onBlur: function onBlur() {
|
|
471
466
|
return setIsSearchInputFocused(false);
|
|
472
467
|
},
|
|
473
|
-
|
|
474
|
-
if (!isOpen)
|
|
468
|
+
onMouseDown: function onMouseDown() {
|
|
469
|
+
if (!isOpen) {
|
|
470
|
+
setIsSearchInputFocused(true);
|
|
471
|
+
setIsOpen(true);
|
|
472
|
+
}
|
|
475
473
|
}
|
|
476
474
|
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
477
475
|
className: "text"
|
|
@@ -479,10 +477,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
479
477
|
className: "dropdown__list-item-postfix"
|
|
480
478
|
}, postfixText)), /*#__PURE__*/_react.default.createElement("span", {
|
|
481
479
|
className: (0, _classnames.default)("".concat(RC, "__arrow"), (0, _defineProperty2.default)({}, "".concat(RC, "__arrow_active"), isOpen)),
|
|
482
|
-
onClick:
|
|
483
|
-
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
484
|
-
setIsOpen(!isOpen);
|
|
485
|
-
}
|
|
480
|
+
onClick: toggleList
|
|
486
481
|
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && renderListContainer());
|
|
487
482
|
};
|
|
488
483
|
|