intelicoreact 1.4.20 → 1.4.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.
|
@@ -65,8 +65,6 @@ const TagListToDropdown = _ref => {
|
|
|
65
65
|
setIsEditMode(false);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const onDropdownClose = () => {};
|
|
69
|
-
|
|
70
68
|
(0, _react.useEffect)(() => {
|
|
71
69
|
setNewValue(preparedValue); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
70
|
}, [isEditMode]);
|
|
@@ -80,6 +78,7 @@ const TagListToDropdown = _ref => {
|
|
|
80
78
|
chosenOptions: newValue,
|
|
81
79
|
renderOptionsAsTags: true,
|
|
82
80
|
withCreateLogic: true,
|
|
81
|
+
isUseLocalOptionsStore: false,
|
|
83
82
|
onOptionEdit: option => {
|
|
84
83
|
var _dropdownProps$onOpti;
|
|
85
84
|
|
|
@@ -80,6 +80,7 @@ const TagsDropdown = _ref => {
|
|
|
80
80
|
useLiveSearch,
|
|
81
81
|
doRequest: doLiveSearchRequest,
|
|
82
82
|
attributesOfNativeInput = {},
|
|
83
|
+
isUseLocalOptionsStore = true,
|
|
83
84
|
withMobileLogic,
|
|
84
85
|
withCreateLogic,
|
|
85
86
|
withActions,
|
|
@@ -119,6 +120,7 @@ const TagsDropdown = _ref => {
|
|
|
119
120
|
searchValue,
|
|
120
121
|
delay: 600
|
|
121
122
|
});
|
|
123
|
+
const [isValueDeleted, setIsValueDeleted] = (0, _react.useState)(false);
|
|
122
124
|
|
|
123
125
|
const setSearchValueInterceptor = value => {
|
|
124
126
|
setSearchValue(value);
|
|
@@ -128,7 +130,6 @@ const TagsDropdown = _ref => {
|
|
|
128
130
|
|
|
129
131
|
const [options, setOptions] = (0, _react.useState)([]);
|
|
130
132
|
const [editingOption, setEditingOption] = (0, _react.useState)(null);
|
|
131
|
-
const [isValueDeleted, setIsValueDeleted] = (0, _react.useState)(false);
|
|
132
133
|
const [localOptionsStore, setLocalOptionsStore] = (0, _react.useState)({});
|
|
133
134
|
const randomColorForNewOption = (0, _react.useMemo)(() => {
|
|
134
135
|
const getRandomIndex = (min, max) => {
|
|
@@ -163,10 +164,10 @@ const TagsDropdown = _ref => {
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
return acc;
|
|
166
|
-
}, (_Object$keys = Object.keys(localOptionsStore)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(value => ({
|
|
167
|
+
}, isUseLocalOptionsStore ? (_Object$keys = Object.keys(localOptionsStore)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(value => ({
|
|
167
168
|
value,
|
|
168
169
|
label: localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[value]
|
|
169
|
-
}))); // --- GENERAL FUNCTIONS BEGIN --- //
|
|
170
|
+
})) : []); // --- GENERAL FUNCTIONS BEGIN --- //
|
|
170
171
|
|
|
171
172
|
const handleClickOutside = e => {
|
|
172
173
|
var _editOptionModalRef$c, _getListContainer, _customTriggerRef$cur, _customTriggerRef$cur2;
|
|
@@ -194,7 +195,7 @@ const TagsDropdown = _ref => {
|
|
|
194
195
|
var _target$className, _target$className$ind, _target$className2, _target$className2$in;
|
|
195
196
|
|
|
196
197
|
if ((target === null || target === void 0 ? void 0 : target.tagName) === "svg" && (target === null || target === void 0 ? void 0 : target.parentNodclassName) === "tag__button" || (target === null || target === void 0 ? void 0 : target.tagName) === "line") return false;
|
|
197
|
-
if ((target === null || target === void 0 ? void 0 : target.tagName) === "svg" && (target === null || target === void 0 ? void 0 : target.parentNodclassName) !== "tag__button" || (target === null || target === void 0 ? void 0 : (_target$className = target.className) === null || _target$className === void 0 ? void 0 : (_target$className$ind = _target$className.indexOf) === null || _target$className$ind === void 0 ? void 0 : _target$className$ind.call(_target$className, "tag__label")) !== -1 || (target === null || target === void 0 ? void 0 : (_target$className2 = target.className) === null || _target$className2 === void 0 ? void 0 : (_target$className2$in = _target$className2.indexOf) === null || _target$className2$in === void 0 ? void 0 : _target$className2$in.call(_target$className2, "tag-list_wrapper")) !== -1 || (target === null || target === void 0 ? void 0 : target.className
|
|
198
|
+
if ((target === null || target === void 0 ? void 0 : target.tagName) === "svg" && (target === null || target === void 0 ? void 0 : target.parentNodclassName) !== "tag__button" || (target === null || target === void 0 ? void 0 : (_target$className = target.className) === null || _target$className === void 0 ? void 0 : (_target$className$ind = _target$className.indexOf) === null || _target$className$ind === void 0 ? void 0 : _target$className$ind.call(_target$className, "tag__label")) !== -1 || (target === null || target === void 0 ? void 0 : (_target$className2 = target.className) === null || _target$className2 === void 0 ? void 0 : (_target$className2$in = _target$className2.indexOf) === null || _target$className2$in === void 0 ? void 0 : _target$className2$in.call(_target$className2, "tag-list_wrapper")) !== -1 || (target === null || target === void 0 ? void 0 : target.className.indexOf("".concat(RC, "__trigger"))) !== -1 || (target === null || target === void 0 ? void 0 : target.className) === "tags-dropdown__arrow") return true;
|
|
198
199
|
return false;
|
|
199
200
|
};
|
|
200
201
|
|
|
@@ -242,9 +243,13 @@ const TagsDropdown = _ref => {
|
|
|
242
243
|
|
|
243
244
|
const deleteChosen = value => {
|
|
244
245
|
if (isMobile ? closeOnRemoveMobile : closeOnRemove) setIsOpen(false);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
|
|
247
|
+
if (isUseLocalOptionsStore) {
|
|
248
|
+
setLocalOptionsStore(options => ({ ...options,
|
|
249
|
+
[value]: undefined
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
|
|
248
253
|
onChange(chosenOptions.filter(item => item !== value), "chosenOptions");
|
|
249
254
|
};
|
|
250
255
|
|
|
@@ -262,9 +267,12 @@ const TagsDropdown = _ref => {
|
|
|
262
267
|
return null;
|
|
263
268
|
}
|
|
264
269
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
270
|
+
if (isUseLocalOptionsStore) {
|
|
271
|
+
setLocalOptionsStore(options => ({ ...options,
|
|
272
|
+
[item === null || item === void 0 ? void 0 : item.value]: item === null || item === void 0 ? void 0 : item.label
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
|
|
268
276
|
onChange([...chosenOptions, item.value], "chosenOptions");
|
|
269
277
|
return null;
|
|
270
278
|
};
|
|
@@ -293,14 +301,18 @@ const TagsDropdown = _ref => {
|
|
|
293
301
|
} = _ref3;
|
|
294
302
|
return !isFreezed && !(chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.includes(value)) && value !== "open_modal";
|
|
295
303
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
|
|
305
|
+
if (isUseLocalOptionsStore) {
|
|
306
|
+
setLocalOptionsStore(options => preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.reduce((result, _ref4) => {
|
|
307
|
+
let {
|
|
308
|
+
value,
|
|
309
|
+
label
|
|
310
|
+
} = _ref4;
|
|
311
|
+
result[value] = label;
|
|
312
|
+
return result;
|
|
313
|
+
}, options));
|
|
314
|
+
}
|
|
315
|
+
|
|
304
316
|
onChange([...chosenOptions, ...((preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(_ref5 => {
|
|
305
317
|
let {
|
|
306
318
|
value
|
|
@@ -311,7 +323,7 @@ const TagsDropdown = _ref => {
|
|
|
311
323
|
};
|
|
312
324
|
|
|
313
325
|
const unselectAllItems = () => {
|
|
314
|
-
setLocalOptionsStore({});
|
|
326
|
+
if (isUseLocalOptionsStore) setLocalOptionsStore({});
|
|
315
327
|
onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(item => {
|
|
316
328
|
var _prepareOptions2, _prepareOptions2$find;
|
|
317
329
|
|
|
@@ -791,7 +803,10 @@ const TagsDropdown = _ref => {
|
|
|
791
803
|
let {
|
|
792
804
|
target
|
|
793
805
|
} = _ref14;
|
|
794
|
-
|
|
806
|
+
|
|
807
|
+
if ((target === null || target === void 0 ? void 0 : target.tagName) === "INPUT") {
|
|
808
|
+
setIsOpen(true);
|
|
809
|
+
} else if (isTargetInParent(target)) {
|
|
795
810
|
setIsOpen(isOpen => !isOpen);
|
|
796
811
|
}
|
|
797
812
|
}
|
|
@@ -893,7 +908,7 @@ const TagsDropdown = _ref => {
|
|
|
893
908
|
setEditOptionModalStyles();
|
|
894
909
|
}, [isOpen, chosenOptions, isMobile, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperR2 = dropdownListWrapperRef.current) === null || _dropdownListWrapperR2 === void 0 ? void 0 : (_dropdownListWrapperR3 = _dropdownListWrapperR2.getBoundingClientRect()) === null || _dropdownListWrapperR3 === void 0 ? void 0 : _dropdownListWrapperR3.height, recalculateListContainerStylesTrigger]);
|
|
895
910
|
(0, _react.useEffect)(() => {
|
|
896
|
-
if (chosenOptions.length !== Object.keys(localOptionsStore).length) {
|
|
911
|
+
if (isUseLocalOptionsStore && chosenOptions.length !== Object.keys(localOptionsStore).length) {
|
|
897
912
|
options.map(option => {
|
|
898
913
|
if (!(localOptionsStore !== null && localOptionsStore !== void 0 && localOptionsStore[option === null || option === void 0 ? void 0 : option.value])) {
|
|
899
914
|
setLocalOptionsStore(options => ({ ...options,
|
|
@@ -902,7 +917,7 @@ const TagsDropdown = _ref => {
|
|
|
902
917
|
}
|
|
903
918
|
});
|
|
904
919
|
}
|
|
905
|
-
}, [chosenOptions]);
|
|
920
|
+
}, [chosenOptions, isUseLocalOptionsStore]);
|
|
906
921
|
(0, _react.useEffect)(() => {
|
|
907
922
|
var _selectAllButtonRef$c, _unselectAllButtonRef;
|
|
908
923
|
|