intelicoreact 1.4.67 → 1.4.69
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.
|
@@ -25,7 +25,7 @@ const RC = "tags-dropdown";
|
|
|
25
25
|
const MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH = 10;
|
|
26
26
|
const COLORS = ["#F1F0F0", "#E3E2E0", "#EEDFDA", "#F9DEC9", "#FDECC8", "#DBECDB", "#D3E4EF", "#E8DEEE", "#F4E0E9", "#FFE2DD", "#D3EFED", "#ECEEDE"];
|
|
27
27
|
const TagsDropdown = _ref => {
|
|
28
|
-
var _Object$keys, _dropdownListWrapperR2, _dropdownListRef$
|
|
28
|
+
var _Object$keys, _dropdownListWrapperR2, _dropdownListRef$curr8, _dropdownListRef$curr9;
|
|
29
29
|
let {
|
|
30
30
|
options: optionsProp,
|
|
31
31
|
chosenOptions = [],
|
|
@@ -91,6 +91,7 @@ const TagsDropdown = _ref => {
|
|
|
91
91
|
const isMobile = isMobileProp && withMobileLogic && window.screen.width <= 768;
|
|
92
92
|
const [dropdownId] = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2));
|
|
93
93
|
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
94
|
+
const [windowScrollTop, setWindowScrollTop] = (0, _react.useState)(0);
|
|
94
95
|
const [listPos, setListPos] = (0, _react.useState)(null);
|
|
95
96
|
const [initListHeight, setInitListHeight] = (0, _react.useState)(null);
|
|
96
97
|
const [isScrollableList, setIsScrollableList] = (0, _react.useState)(null);
|
|
@@ -559,6 +560,7 @@ const TagsDropdown = _ref => {
|
|
|
559
560
|
}, [options]);
|
|
560
561
|
|
|
561
562
|
// --- RENDER FUNCTIONS BEGIN --- //
|
|
563
|
+
|
|
562
564
|
const getMarkupForElement = item => {
|
|
563
565
|
var _item$customMobileIco;
|
|
564
566
|
const {
|
|
@@ -630,13 +632,15 @@ const TagsDropdown = _ref => {
|
|
|
630
632
|
const filteredOptions = getFilteredOptions(options);
|
|
631
633
|
const arrToPrint = [];
|
|
632
634
|
for (const option of filteredOptions) {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
635
|
+
if (option.groupName) {
|
|
636
|
+
var _option$groupName, _option$list2;
|
|
637
|
+
arrToPrint.push( /*#__PURE__*/_react.default.createElement("div", {
|
|
638
|
+
key: (_option$groupName = option.groupName) === null || _option$groupName === void 0 || (_option$groupName = _option$groupName.toString()) === null || _option$groupName === void 0 ? void 0 : _option$groupName.replace(/ /g, "_").concat(Date.now()),
|
|
639
|
+
className: (0, _classnames.default)("".concat(RC, "-group"), option.className)
|
|
640
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
641
|
+
className: "".concat(RC, "-group__name")
|
|
642
|
+
}, option.groupName), (_option$list2 = option.list) === null || _option$list2 === void 0 ? void 0 : _option$list2.map(item => getMarkupForElement(item))));
|
|
643
|
+
} else arrToPrint.push(getMarkupForElement(option));
|
|
640
644
|
}
|
|
641
645
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
642
646
|
className: (0, _classnames.default)("".concat(RC, "__container-wrapper")),
|
|
@@ -879,11 +883,15 @@ const TagsDropdown = _ref => {
|
|
|
879
883
|
}, [chosenOptions, isUseLocalOptionsStore]);
|
|
880
884
|
(0, _react.useEffect)(() => {
|
|
881
885
|
var _selectAllButtonRef$c, _unselectAllButtonRef;
|
|
886
|
+
const windowScrollEventHandler = e => {
|
|
887
|
+
setWindowScrollTop(window.scrollY);
|
|
888
|
+
};
|
|
882
889
|
const fn = isOpen ? "addEventListener" : "removeEventListener";
|
|
883
890
|
selectAllButtonRef === null || selectAllButtonRef === void 0 || (_selectAllButtonRef$c = selectAllButtonRef.current) === null || _selectAllButtonRef$c === void 0 || _selectAllButtonRef$c[fn]("click", selectAllItems, true);
|
|
884
891
|
unselectAllButtonRef === null || unselectAllButtonRef === void 0 || (_unselectAllButtonRef = unselectAllButtonRef.current) === null || _unselectAllButtonRef === void 0 || _unselectAllButtonRef[fn]("click", unselectAllItems, true);
|
|
885
892
|
if (isOpen) {
|
|
886
893
|
var _getListContainer5;
|
|
894
|
+
if (!isMobile || !withMobileLogic) window.removeEventListener("scroll", windowScrollEventHandler);
|
|
887
895
|
if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
|
|
888
896
|
customTriggerRef.current.style.pointerEvents = "none";
|
|
889
897
|
}
|
|
@@ -897,6 +905,7 @@ const TagsDropdown = _ref => {
|
|
|
897
905
|
}
|
|
898
906
|
} else {
|
|
899
907
|
var _getListContainer6;
|
|
908
|
+
if (!isMobile || !withMobileLogic) window.addEventListener("scroll", windowScrollEventHandler);
|
|
900
909
|
if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
|
|
901
910
|
customTriggerRef.current.style.pointerEvents = "auto";
|
|
902
911
|
}
|
|
@@ -910,6 +919,12 @@ const TagsDropdown = _ref => {
|
|
|
910
919
|
const setScrollTopValue = e => {
|
|
911
920
|
setScrollTop(parseInt(e.target.scrollTop, 10));
|
|
912
921
|
};
|
|
922
|
+
const preventWindowScrolling = e => {
|
|
923
|
+
e.preventDefault();
|
|
924
|
+
window.scrollTo({
|
|
925
|
+
top: windowScrollTop
|
|
926
|
+
});
|
|
927
|
+
};
|
|
913
928
|
if (isOpen && isMobile && dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
914
929
|
var _dropdownListRef$curr, _dropdownListRef$curr2, _dropdownListRef$curr3;
|
|
915
930
|
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr = dropdownListRef.current) === null || _dropdownListRef$curr === void 0 || _dropdownListRef$curr.addEventListener("scroll", setScrollTopValue);
|
|
@@ -921,17 +936,19 @@ const TagsDropdown = _ref => {
|
|
|
921
936
|
}
|
|
922
937
|
if (isOpen && dropdownListRef && dropdownListRef.current) {
|
|
923
938
|
dropdownListRef.current.addEventListener("scroll", doScrollCallback);
|
|
939
|
+
if (!isMobile || !withMobileLogic) window.addEventListener("scroll", preventWindowScrolling);
|
|
924
940
|
}
|
|
925
941
|
return () => {
|
|
926
|
-
var _dropdownListRef$curr6;
|
|
927
|
-
removeEventListener("scroll",
|
|
928
|
-
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr6 = dropdownListRef.current) === null || _dropdownListRef$curr6 === void 0 || _dropdownListRef$curr6.removeEventListener("scroll",
|
|
942
|
+
var _dropdownListRef$curr6, _dropdownListRef$curr7;
|
|
943
|
+
if (!isMobile || !withMobileLogic) window.removeEventListener("scroll", preventWindowScrolling);
|
|
944
|
+
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr6 = dropdownListRef.current) === null || _dropdownListRef$curr6 === void 0 || _dropdownListRef$curr6.removeEventListener("scroll", doScrollCallback);
|
|
945
|
+
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr7 = dropdownListRef.current) === null || _dropdownListRef$curr7 === void 0 || _dropdownListRef$curr7.removeEventListener("scroll", setScrollTopValue);
|
|
929
946
|
};
|
|
930
|
-
}, [isOpen, isMobile, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$
|
|
947
|
+
}, [isOpen, isMobile, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr8 = dropdownListRef.current) === null || _dropdownListRef$curr8 === void 0 ? void 0 : _dropdownListRef$curr8.scrollHeight, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr9 = dropdownListRef.current) === null || _dropdownListRef$curr9 === void 0 ? void 0 : _dropdownListRef$curr9.clientHeight]);
|
|
931
948
|
(0, _react.useEffect)(() => {
|
|
932
949
|
if (dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
933
|
-
var _dropdownListRef$
|
|
934
|
-
setScrollHeight(parseInt((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$
|
|
950
|
+
var _dropdownListRef$curr10, _dropdownListRef$curr11;
|
|
951
|
+
setScrollHeight(parseInt((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr10 = dropdownListRef.current) === null || _dropdownListRef$curr10 === void 0 ? void 0 : _dropdownListRef$curr10.scrollHeight) - (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr11 = dropdownListRef.current) === null || _dropdownListRef$curr11 === void 0 ? void 0 : _dropdownListRef$curr11.clientHeight), 10));
|
|
935
952
|
}
|
|
936
953
|
}, [scrollTop, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current]);
|
|
937
954
|
(0, _react.useEffect)(() => {
|
|
@@ -65,6 +65,10 @@ class RESTAPI extends _ApiBase.default {
|
|
|
65
65
|
//? При вызове getRequestInstance передадим контекст API
|
|
66
66
|
//? В результате вызова получим экземпляр класса AbortableFetch...
|
|
67
67
|
const instance = await _utils.getInstanceOfFetchSystem.call(this);
|
|
68
|
+
if (!instance) {
|
|
69
|
+
throw new Error('It is impossible to make a request!');
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
//? ... который еще немного донастроим сеттерами экзепляра
|
|
69
73
|
instance.setIsResponseAsObject(isResponseAsObject !== null && isResponseAsObject !== void 0 ? isResponseAsObject : true);
|
|
70
74
|
if (callback) instance.setCallback(callback);
|
|
@@ -201,9 +201,14 @@ class CredentialsProcessing {
|
|
|
201
201
|
return CONTEXT.refreshCredentials(cred, response => CONTEXT.saveCredentials(response)).then(() => {
|
|
202
202
|
return new Promise(resolve => {
|
|
203
203
|
setTimeout(async () => {
|
|
204
|
-
var _CONTEXT$callbackAfte;
|
|
205
204
|
const newCredentials = await CONTEXT.getCredentials();
|
|
206
|
-
if (!(newCredentials !== null && newCredentials !== void 0 && newCredentials.token))
|
|
205
|
+
if (!(newCredentials !== null && newCredentials !== void 0 && newCredentials.token)) {
|
|
206
|
+
newCredentials.isRefreshFailed = true;
|
|
207
|
+
setTimeout(() => {
|
|
208
|
+
var _CONTEXT$callbackAfte;
|
|
209
|
+
CONTEXT === null || CONTEXT === void 0 || (_CONTEXT$callbackAfte = CONTEXT.callbackAfterRejectRefresh) === null || _CONTEXT$callbackAfte === void 0 || _CONTEXT$callbackAfte.call(CONTEXT);
|
|
210
|
+
}, 0);
|
|
211
|
+
}
|
|
207
212
|
resolve(newCredentials);
|
|
208
213
|
}, 0);
|
|
209
214
|
});
|
|
@@ -41,6 +41,10 @@ async function getInstanceOfFetchSystem(isGetBody) {
|
|
|
41
41
|
const cred = await CREDENTIALS_CONTEXT.getCredentials();
|
|
42
42
|
credentials = CREDENTIALS_CONTEXT.isUseRefreshTokensPropcessing ? await CREDENTIALS_CONTEXT.waitRefresh(cred.isNeedRefresh && !CREDENTIALS_CONTEXT.getIsTokenStartRefresh()).then(async () => CREDENTIALS_CONTEXT.processCredentials(await CREDENTIALS_CONTEXT.getCredentials())) : cred;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
//? На уровне получения instance может уже сложиться ситуация, что сходили на рефреш и он неудачный.
|
|
46
|
+
//? Прерываем получение instance, даем возможность отработать callbackAfterRejectRefresh (смотри class CredentialsProcessing)
|
|
47
|
+
if (credentials.isRefreshFailed) return null;
|
|
44
48
|
if (API_CONTEXT.addAsCommon && typeof API_CONTEXT.addAsCommon !== "function") {
|
|
45
49
|
throw new Error("addAsCommon must be function [getInstanceOfFetchSystem]");
|
|
46
50
|
}
|
|
@@ -104,11 +108,10 @@ async function getInstanceOfFetchSystem(isGetBody) {
|
|
|
104
108
|
const isDoRefresh = !(CREDENTIALS_CONTEXT !== null && CREDENTIALS_CONTEXT !== void 0 && (_CREDENTIALS_CONTEXT$6 = CREDENTIALS_CONTEXT.getIsTokenStartRefresh) !== null && _CREDENTIALS_CONTEXT$6 !== void 0 && _CREDENTIALS_CONTEXT$6.call(CREDENTIALS_CONTEXT));
|
|
105
109
|
return CREDENTIALS_CONTEXT === null || CREDENTIALS_CONTEXT === void 0 ? void 0 : CREDENTIALS_CONTEXT.waitRefresh(isDoRefresh).then(async () => {
|
|
106
110
|
//? Пробуем зарефрешить
|
|
107
|
-
await (CREDENTIALS_CONTEXT === null || CREDENTIALS_CONTEXT === void 0 ? void 0 : CREDENTIALS_CONTEXT.processCredentials({
|
|
111
|
+
const newCredentials = await (CREDENTIALS_CONTEXT === null || CREDENTIALS_CONTEXT === void 0 ? void 0 : CREDENTIALS_CONTEXT.processCredentials({
|
|
108
112
|
...(await (CREDENTIALS_CONTEXT === null || CREDENTIALS_CONTEXT === void 0 ? void 0 : CREDENTIALS_CONTEXT.getCredentials(true))),
|
|
109
113
|
isCatchCallbackProcess: isDoRefresh
|
|
110
114
|
}));
|
|
111
|
-
const newCredentials = await CREDENTIALS_CONTEXT.getCredentials();
|
|
112
115
|
ABORTABLE_FETCH_INSTANCE.setHeaders({
|
|
113
116
|
...ABORTABLE_FETCH_INSTANCE.getHeaders(),
|
|
114
117
|
...(newCredentials !== null && newCredentials !== void 0 && newCredentials.token ? {
|