intelicoreact 1.1.21 → 1.1.23
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)
|
|
@@ -356,18 +353,49 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
356
353
|
};
|
|
357
354
|
|
|
358
355
|
var getListMarkUp = function getListMarkUp() {
|
|
356
|
+
var _getSortedOptions;
|
|
357
|
+
|
|
359
358
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
360
359
|
className: (0, _classnames.default)("".concat(RC, "__list"), (0, _defineProperty2.default)({}, "".concat(RC, "__list-top"), isListTop)),
|
|
361
360
|
ref: dropdownListRef
|
|
362
|
-
}, getSortedOptions(depend.options).map(function (
|
|
363
|
-
var
|
|
361
|
+
}, (_getSortedOptions = getSortedOptions(depend.options)) === null || _getSortedOptions === void 0 ? void 0 : _getSortedOptions.map(function (option) {
|
|
362
|
+
var _option$items;
|
|
363
|
+
|
|
364
|
+
if (option !== null && option !== void 0 && (_option$items = option.items) !== null && _option$items !== void 0 && _option$items.length) {
|
|
365
|
+
if (!isSearchable || !isSearchChanged) {
|
|
366
|
+
return filteredOptionList(option);
|
|
367
|
+
} else {
|
|
368
|
+
var _option$items2;
|
|
369
|
+
|
|
370
|
+
var items = (_option$items2 = option.items) === null || _option$items2 === void 0 ? void 0 : _option$items2.slice().filter(function (el) {
|
|
371
|
+
var _el$label2;
|
|
372
|
+
|
|
373
|
+
return (el === null || el === void 0 ? void 0 : (_el$label2 = el.label) === null || _el$label2 === void 0 ? void 0 : _el$label2.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) === '';
|
|
374
|
+
});
|
|
375
|
+
if (items !== null && items !== void 0 && items.length) return filteredOptionList(_objectSpread(_objectSpread({}, option), {}, {
|
|
376
|
+
items: items
|
|
377
|
+
}));
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
} else {
|
|
381
|
+
var _option$label;
|
|
364
382
|
|
|
365
|
-
|
|
383
|
+
if (!isSearchable || !isSearchChanged || option !== null && option !== void 0 && (_option$label = option.label) !== null && _option$label !== void 0 && _option$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '') || !(option !== null && option !== void 0 && option.value) || (option === null || option === void 0 ? void 0 : option.value) === '') {
|
|
384
|
+
return getMarkupForElement(option);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
366
387
|
}), !filteredItems.length && !filteredGroups.length && /*#__PURE__*/_react.default.createElement("div", {
|
|
367
388
|
className: "".concat(RC, "__list-item ").concat(RC, "__list-item--no-options")
|
|
368
389
|
}, noOptionsText), disabled && isOpen && /*#__PURE__*/_react.default.createElement(_DropdownLoader.default, null));
|
|
369
390
|
};
|
|
370
391
|
|
|
392
|
+
var toggleList = function toggleList(e) {
|
|
393
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
394
|
+
setIsOpen(function (isOpen) {
|
|
395
|
+
return !isOpen;
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
|
|
371
399
|
var closeList = handleClickOutside;
|
|
372
400
|
(0, _react.useEffect)(function () {
|
|
373
401
|
initListContainer();
|
|
@@ -444,18 +472,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
444
472
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
445
473
|
"data-testid": "dropdown--".concat(testId || '', "--container"),
|
|
446
474
|
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
|
-
},
|
|
475
|
+
onClick: toggleList,
|
|
454
476
|
onKeyDown: onKeyDown,
|
|
455
|
-
onKeyUp: onKeyUp
|
|
456
|
-
onFocus: function onFocus() {
|
|
457
|
-
return !isFocusedByClick ? setIsOpen(true) : null;
|
|
458
|
-
}
|
|
477
|
+
onKeyUp: onKeyUp
|
|
459
478
|
}, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
|
|
460
479
|
ref: searchInputRef,
|
|
461
480
|
className: "".concat(RC, "__input"),
|
|
@@ -470,8 +489,11 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
470
489
|
onBlur: function onBlur() {
|
|
471
490
|
return setIsSearchInputFocused(false);
|
|
472
491
|
},
|
|
473
|
-
|
|
474
|
-
if (!isOpen)
|
|
492
|
+
onMouseDown: function onMouseDown() {
|
|
493
|
+
if (!isOpen) {
|
|
494
|
+
setIsSearchInputFocused(true);
|
|
495
|
+
setIsOpen(true);
|
|
496
|
+
}
|
|
475
497
|
}
|
|
476
498
|
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
477
499
|
className: "text"
|
|
@@ -479,10 +501,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
479
501
|
className: "dropdown__list-item-postfix"
|
|
480
502
|
}, postfixText)), /*#__PURE__*/_react.default.createElement("span", {
|
|
481
503
|
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
|
-
}
|
|
504
|
+
onClick: toggleList
|
|
486
505
|
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && renderListContainer());
|
|
487
506
|
};
|
|
488
507
|
|