intelicoreact 1.4.21 → 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,14 +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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
value,
|
|
171
|
-
label: localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[value]
|
|
172
|
-
};
|
|
173
|
-
})); // --- GENERAL FUNCTIONS BEGIN --- //
|
|
167
|
+
}, isUseLocalOptionsStore ? (_Object$keys = Object.keys(localOptionsStore)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(value => ({
|
|
168
|
+
value,
|
|
169
|
+
label: localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[value]
|
|
170
|
+
})) : []); // --- GENERAL FUNCTIONS BEGIN --- //
|
|
174
171
|
|
|
175
172
|
const handleClickOutside = e => {
|
|
176
173
|
var _editOptionModalRef$c, _getListContainer, _customTriggerRef$cur, _customTriggerRef$cur2;
|
|
@@ -198,7 +195,7 @@ const TagsDropdown = _ref => {
|
|
|
198
195
|
var _target$className, _target$className$ind, _target$className2, _target$className2$in;
|
|
199
196
|
|
|
200
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;
|
|
201
|
-
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;
|
|
202
199
|
return false;
|
|
203
200
|
};
|
|
204
201
|
|
|
@@ -246,9 +243,13 @@ const TagsDropdown = _ref => {
|
|
|
246
243
|
|
|
247
244
|
const deleteChosen = value => {
|
|
248
245
|
if (isMobile ? closeOnRemoveMobile : closeOnRemove) setIsOpen(false);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
|
|
247
|
+
if (isUseLocalOptionsStore) {
|
|
248
|
+
setLocalOptionsStore(options => ({ ...options,
|
|
249
|
+
[value]: undefined
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
|
|
252
253
|
onChange(chosenOptions.filter(item => item !== value), "chosenOptions");
|
|
253
254
|
};
|
|
254
255
|
|
|
@@ -266,9 +267,12 @@ const TagsDropdown = _ref => {
|
|
|
266
267
|
return null;
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
+
|
|
272
276
|
onChange([...chosenOptions, item.value], "chosenOptions");
|
|
273
277
|
return null;
|
|
274
278
|
};
|
|
@@ -297,14 +301,18 @@ const TagsDropdown = _ref => {
|
|
|
297
301
|
} = _ref3;
|
|
298
302
|
return !isFreezed && !(chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.includes(value)) && value !== "open_modal";
|
|
299
303
|
});
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
+
|
|
308
316
|
onChange([...chosenOptions, ...((preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(_ref5 => {
|
|
309
317
|
let {
|
|
310
318
|
value
|
|
@@ -315,7 +323,7 @@ const TagsDropdown = _ref => {
|
|
|
315
323
|
};
|
|
316
324
|
|
|
317
325
|
const unselectAllItems = () => {
|
|
318
|
-
setLocalOptionsStore({});
|
|
326
|
+
if (isUseLocalOptionsStore) setLocalOptionsStore({});
|
|
319
327
|
onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(item => {
|
|
320
328
|
var _prepareOptions2, _prepareOptions2$find;
|
|
321
329
|
|
|
@@ -795,7 +803,10 @@ const TagsDropdown = _ref => {
|
|
|
795
803
|
let {
|
|
796
804
|
target
|
|
797
805
|
} = _ref14;
|
|
798
|
-
|
|
806
|
+
|
|
807
|
+
if ((target === null || target === void 0 ? void 0 : target.tagName) === "INPUT") {
|
|
808
|
+
setIsOpen(true);
|
|
809
|
+
} else if (isTargetInParent(target)) {
|
|
799
810
|
setIsOpen(isOpen => !isOpen);
|
|
800
811
|
}
|
|
801
812
|
}
|
|
@@ -897,7 +908,7 @@ const TagsDropdown = _ref => {
|
|
|
897
908
|
setEditOptionModalStyles();
|
|
898
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]);
|
|
899
910
|
(0, _react.useEffect)(() => {
|
|
900
|
-
if (chosenOptions.length !== Object.keys(localOptionsStore).length) {
|
|
911
|
+
if (isUseLocalOptionsStore && chosenOptions.length !== Object.keys(localOptionsStore).length) {
|
|
901
912
|
options.map(option => {
|
|
902
913
|
if (!(localOptionsStore !== null && localOptionsStore !== void 0 && localOptionsStore[option === null || option === void 0 ? void 0 : option.value])) {
|
|
903
914
|
setLocalOptionsStore(options => ({ ...options,
|
|
@@ -906,7 +917,7 @@ const TagsDropdown = _ref => {
|
|
|
906
917
|
}
|
|
907
918
|
});
|
|
908
919
|
}
|
|
909
|
-
}, [chosenOptions]);
|
|
920
|
+
}, [chosenOptions, isUseLocalOptionsStore]);
|
|
910
921
|
(0, _react.useEffect)(() => {
|
|
911
922
|
var _selectAllButtonRef$c, _unselectAllButtonRef;
|
|
912
923
|
|