intelicoreact 0.2.25 → 0.2.26
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.
|
@@ -69,6 +69,12 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
69
69
|
|
|
70
70
|
var dropdownRef = (0, _react.useRef)(null);
|
|
71
71
|
var dropdownListRef = (0, _react.useRef)(null);
|
|
72
|
+
|
|
73
|
+
var _useState5 = (0, _react.useState)(false),
|
|
74
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
75
|
+
isFocusedByClick = _useState6[0],
|
|
76
|
+
setIsFocusedByClick = _useState6[1];
|
|
77
|
+
|
|
72
78
|
if (!options) return null;
|
|
73
79
|
var filteredGroups = options.filter(function (item) {
|
|
74
80
|
var _item$items;
|
|
@@ -210,6 +216,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
210
216
|
};
|
|
211
217
|
}, [value]);
|
|
212
218
|
(0, _react.useEffect)(function () {
|
|
219
|
+
if (!isOpen) setIsFocusedByClick(false);
|
|
220
|
+
|
|
213
221
|
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
|
|
214
222
|
dropdownListRef.current.addEventListener('scroll', doScrollCallback);
|
|
215
223
|
}
|
|
@@ -218,6 +226,17 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
218
226
|
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object') removeEventListener('scroll', doScrollCallback);
|
|
219
227
|
};
|
|
220
228
|
}, [isOpen, dropdownListRef]);
|
|
229
|
+
|
|
230
|
+
var onKeyDown = function onKeyDown(e) {
|
|
231
|
+
if (![9, 13].includes(e.keyCode)) return false;
|
|
232
|
+
setIsOpen(false);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
var onKeyUp = function onKeyUp(e) {
|
|
236
|
+
if (![9, 13].includes(e.keyCode)) return false;
|
|
237
|
+
setIsOpen(true);
|
|
238
|
+
};
|
|
239
|
+
|
|
221
240
|
var postfixText = selectedLabel && ((_filteredOptions$find = filteredOptions.find(function (option) {
|
|
222
241
|
return option.value === value;
|
|
223
242
|
})) === null || _filteredOptions$find === void 0 ? void 0 : _filteredOptions$find.postfix) || null;
|
|
@@ -226,18 +245,20 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
226
245
|
disabled: disabled
|
|
227
246
|
}),
|
|
228
247
|
ref: dropdownRef,
|
|
229
|
-
onKeyDown:
|
|
230
|
-
|
|
231
|
-
setIsOpen(false);
|
|
232
|
-
},
|
|
233
|
-
onKeyUp: function onKeyUp(e) {
|
|
234
|
-
if (!['Tab', 'Enter'].includes(e.code)) return false;
|
|
235
|
-
setIsOpen(true);
|
|
236
|
-
}
|
|
248
|
+
onKeyDown: onKeyDown,
|
|
249
|
+
onKeyUp: onKeyUp
|
|
237
250
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
238
251
|
className: "".concat(RC, "__trigger input__wrap ").concat(isOpen ? 'input__wrap--focus' : '', " ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : ''),
|
|
239
252
|
onClick: function onClick() {
|
|
240
253
|
return !isSearchable ? setIsOpen(!isOpen) : null;
|
|
254
|
+
},
|
|
255
|
+
onMouseDown: function onMouseDown() {
|
|
256
|
+
return setIsFocusedByClick(true);
|
|
257
|
+
},
|
|
258
|
+
onKeyDown: onKeyDown,
|
|
259
|
+
onKeyUp: onKeyUp,
|
|
260
|
+
onFocus: function onFocus() {
|
|
261
|
+
return !isFocusedByClick ? setIsOpen(true) : null;
|
|
241
262
|
}
|
|
242
263
|
}, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
|
|
243
264
|
className: "".concat(RC, "__input"),
|