intelicoreact 1.4.1 → 1.4.2
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.
|
@@ -72,7 +72,7 @@ const DropdownLiveSearch = _ref => {
|
|
|
72
72
|
|
|
73
73
|
return (_options$find$label = options === null || options === void 0 ? void 0 : (_options$find = options.find(item => item.value === value)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : "";
|
|
74
74
|
}, [value]);
|
|
75
|
-
const [searchValue, setSV] = (0, _react.useState)(
|
|
75
|
+
const [searchValue, setSV] = (0, _react.useState)("");
|
|
76
76
|
const [isSearchValueChangedAfterOpen, setIsSearchValueChangedAfterOpen] = (0, _react.useState)(false);
|
|
77
77
|
const dropdownLiveSearchRef = (0, _react.useRef)(null);
|
|
78
78
|
const dropdownListBoxRef = (0, _react.useRef)(null);
|
|
@@ -99,17 +99,17 @@ const DropdownLiveSearch = _ref => {
|
|
|
99
99
|
}
|
|
100
100
|
}, [options]);
|
|
101
101
|
|
|
102
|
-
const setSearchValue = val
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
const setSearchValue = function (val) {
|
|
103
|
+
let isChanged = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
104
|
+
if (isChanged) setIsSearchValueChangedAfterOpen(true);
|
|
105
|
+
setSV(val);
|
|
106
|
+
searchValueRef.current = val;
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
const setIsOpen = v => {
|
|
109
110
|
setIsOpenState(v);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
setIsValueDeleted(v);
|
|
111
|
+
setSearchValue("", false);
|
|
112
|
+
if (!v) setIsSearchValueChangedAfterOpen(false);
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
const getParentNode = () => {
|
|
@@ -199,7 +199,7 @@ const DropdownLiveSearch = _ref => {
|
|
|
199
199
|
var _item$value, _item$value$toString, _item$value2, _item$value2$toString, _item$customMobileIco;
|
|
200
200
|
|
|
201
201
|
const lowerLabel = item.label.toLowerCase();
|
|
202
|
-
const lowerSearchValue = searchValue.toLowerCase();
|
|
202
|
+
const lowerSearchValue = searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase();
|
|
203
203
|
return /*#__PURE__*/_react.default.createElement("button", {
|
|
204
204
|
"data-testid": "dropdown-live-search--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"),
|
|
205
205
|
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, "_"),
|
|
@@ -327,10 +327,6 @@ const DropdownLiveSearch = _ref => {
|
|
|
327
327
|
document.addEventListener("click", handleClickOutside, true);
|
|
328
328
|
return () => document.removeEventListener("click", handleClickOutside, true);
|
|
329
329
|
}, []);
|
|
330
|
-
(0, _react.useEffect)(() => {
|
|
331
|
-
if (!value) setSearchValue("");
|
|
332
|
-
setIsSearchValueChangedAfterOpen(false);
|
|
333
|
-
}, [value]);
|
|
334
330
|
(0, _react.useEffect)(() => {
|
|
335
331
|
if (options.length === 1 && searchValue === options[0].label) {
|
|
336
332
|
setSearchValue(options[0].label);
|
|
@@ -338,8 +334,9 @@ const DropdownLiveSearch = _ref => {
|
|
|
338
334
|
}
|
|
339
335
|
}, [options]);
|
|
340
336
|
(0, _react.useEffect)(() => {
|
|
341
|
-
if (isSearchable && debouncedSearchTerm || isValueDeleted) {
|
|
337
|
+
if (isSearchable && (debouncedSearchTerm || isValueDeleted)) {
|
|
342
338
|
doRequest(debouncedSearchTerm);
|
|
339
|
+
if (isValueDeleted) setIsValueDeleted(false);
|
|
343
340
|
}
|
|
344
341
|
}, [debouncedSearchTerm, isValueDeleted]);
|
|
345
342
|
(0, _react.useEffect)(() => {
|
|
@@ -85,7 +85,7 @@ const TagsDropdown = _ref => {
|
|
|
85
85
|
} = (0, _useIsMobile.default)();
|
|
86
86
|
const isMobile = isMobileProp && withMobileLogic && window.screen.width <= 768;
|
|
87
87
|
const [dropdownId] = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2));
|
|
88
|
-
const [isOpen,
|
|
88
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
89
89
|
const [searchValue, setSearchValue] = (0, _react.useState)("");
|
|
90
90
|
const dropdownRef = (0, _react.useRef)(null);
|
|
91
91
|
const dropdownListRef = (0, _react.useRef)(null);
|
|
@@ -136,15 +136,10 @@ const TagsDropdown = _ref => {
|
|
|
136
136
|
|
|
137
137
|
const setSearchValueInterceptor = value => {
|
|
138
138
|
setSearchValue(value);
|
|
139
|
-
setIsValueDeleted(value === "");
|
|
139
|
+
setIsValueDeleted(searchValue !== value && value === "");
|
|
140
140
|
searchValueRef.current = value;
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
const setIsOpen = v => {
|
|
144
|
-
setIsOpenState(v);
|
|
145
|
-
setSearchValueInterceptor(v ? "" : null);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
143
|
const doScrollCallback = (0, _react.useCallback)(e => {
|
|
149
144
|
if (doLiveSearchRequest && typeof doLiveSearchRequest === "function") {
|
|
150
145
|
if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
|
|
@@ -165,7 +160,6 @@ const TagsDropdown = _ref => {
|
|
|
165
160
|
/* && !isTargetInParent(target) */
|
|
166
161
|
) {
|
|
167
162
|
setIsOpen(false);
|
|
168
|
-
setSearchValueInterceptor(null);
|
|
169
163
|
}
|
|
170
164
|
};
|
|
171
165
|
|
|
@@ -652,10 +646,10 @@ const TagsDropdown = _ref => {
|
|
|
652
646
|
};
|
|
653
647
|
}, []);
|
|
654
648
|
(0, _react.useEffect)(() => {
|
|
655
|
-
if (isSearchable && useLiveSearch && debouncedSearchTerm || isValueDeleted) {
|
|
649
|
+
if (isSearchable && useLiveSearch && (debouncedSearchTerm || isValueDeleted || isOpen)) {
|
|
656
650
|
doLiveSearchRequest === null || doLiveSearchRequest === void 0 ? void 0 : doLiveSearchRequest(debouncedSearchTerm);
|
|
657
651
|
}
|
|
658
|
-
}, [debouncedSearchTerm, isValueDeleted]);
|
|
652
|
+
}, [isOpen, debouncedSearchTerm, isValueDeleted]);
|
|
659
653
|
(0, _react.useLayoutEffect)(() => {
|
|
660
654
|
var _getListContainer5;
|
|
661
655
|
|