intelicoreact 1.4.22 → 1.4.24

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.
@@ -21,7 +21,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
21
21
 
22
22
  const TagListToDropdown = _ref => {
23
23
  let {
24
- options: optionsProp,
24
+ options,
25
25
  value = [],
26
26
  dropdownProps = {},
27
27
  listProps = {},
@@ -37,74 +37,55 @@ const TagListToDropdown = _ref => {
37
37
  const [isEditMode, setIsEditMode] = (0, _react.useState)(false);
38
38
  const [isRenderAllTags, setIsRenderAllTags] = (0, _react.useState)(false);
39
39
  const [newValue, setNewValue] = (0, _react.useState)(preparedValue);
40
- const [options, setOptions] = (0, _react.useState)([]);
40
+ const [isValueChanged, setIsValueChanged] = (0, _react.useState)(false);
41
+ const [isLoading, setIsLoading] = (0, _react.useState)(false);
41
42
  const tagListRef = (0, _react.useRef)(null);
42
43
 
43
- const onOptionCreate = newOption => {
44
- setOptions(state => [...state, newOption]);
45
- };
46
-
47
- const onOptionEdit = option => {
48
- setOptions(state => state.map(item => {
49
- if (item.value === option.value) return option;
50
- return item;
51
- }));
52
- };
53
-
54
- const onOptionDelete = option => {
55
- setOptions(state => state.filter(item => item.value !== option.value));
56
- };
57
-
58
44
  const onConfirmChangesClick = () => {
59
- onChange(options.filter(_ref3 => {
60
- let {
61
- value
62
- } = _ref3;
63
- return newValue.includes(value);
64
- }));
65
- setIsEditMode(false);
45
+ if (isValueChanged) {
46
+ var _onChange;
47
+
48
+ setIsLoading(true);
49
+ setIsValueChanged(false);
50
+ (_onChange = onChange(options.filter(_ref3 => {
51
+ let {
52
+ value
53
+ } = _ref3;
54
+ return newValue.includes(value);
55
+ }))) === null || _onChange === void 0 ? void 0 : _onChange.finally(() => {
56
+ setIsEditMode(false);
57
+ setIsLoading(false);
58
+ });
59
+ }
66
60
  };
67
61
 
68
62
  (0, _react.useEffect)(() => {
69
63
  setNewValue(preparedValue); // eslint-disable-next-line react-hooks/exhaustive-deps
70
64
  }, [isEditMode]);
71
- (0, _react.useEffect)(() => {
72
- if (optionsProp) setOptions(optionsProp);
73
- }, [optionsProp]);
74
65
 
75
66
  const renderTagsDropdown = props => {
76
67
  return /*#__PURE__*/_react.default.createElement(_TagsDropdown.default, (0, _extends2.default)({}, dropdownProps, {
68
+ disabled: isLoading,
77
69
  options: options,
78
70
  chosenOptions: newValue,
79
71
  renderOptionsAsTags: true,
80
72
  withCreateLogic: true,
81
73
  isUseLocalOptionsStore: false,
82
- onOptionEdit: option => {
83
- var _dropdownProps$onOpti;
84
-
85
- onOptionEdit(option);
86
- dropdownProps === null || dropdownProps === void 0 ? void 0 : (_dropdownProps$onOpti = dropdownProps.onOptionEdit) === null || _dropdownProps$onOpti === void 0 ? void 0 : _dropdownProps$onOpti.call(dropdownProps, option);
87
- },
88
- onOptionDelete: option => {
89
- var _dropdownProps$onOpti2;
90
-
91
- onOptionDelete(option);
92
- dropdownProps === null || dropdownProps === void 0 ? void 0 : (_dropdownProps$onOpti2 = dropdownProps.onOptionDelete) === null || _dropdownProps$onOpti2 === void 0 ? void 0 : _dropdownProps$onOpti2.call(dropdownProps, option);
93
- },
94
- onOptionCreate: option => {
95
- var _dropdownProps$onOpti3;
96
-
97
- onOptionCreate(option);
98
- dropdownProps === null || dropdownProps === void 0 ? void 0 : (_dropdownProps$onOpti3 = dropdownProps.onOptionCreate) === null || _dropdownProps$onOpti3 === void 0 ? void 0 : _dropdownProps$onOpti3.call(dropdownProps, option);
99
- },
74
+ onOptionEdit: dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.onOptionEdit,
75
+ onOptionDelete: dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.onOptionDelete,
76
+ onOptionCreate: dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.onOptionCreate,
100
77
  onActionConfirmClick: onConfirmChangesClick,
101
78
  onActionCancelClick: () => setIsEditMode(v => !v),
102
- onChange: setNewValue
79
+ onChange: data => {
80
+ setNewValue(data);
81
+ setIsValueChanged(true);
82
+ }
103
83
  }, props));
104
84
  };
105
85
 
106
86
  const renderTagsList = props => {
107
87
  return /*#__PURE__*/_react.default.createElement(_TagList.default, (0, _extends2.default)({
88
+ disabled: isLoading,
108
89
  refProp: tagListRef
109
90
  }, listProps, {
110
91
  items: value,
@@ -129,7 +129,29 @@ const TagsDropdown = _ref => {
129
129
  };
130
130
 
131
131
  const [options, setOptions] = (0, _react.useState)([]);
132
- const [editingOption, setEditingOption] = (0, _react.useState)(null);
132
+ const [editingOption, setEditingOptionState] = (0, _react.useState)(null);
133
+
134
+ const setEditingOption = data => {
135
+ setEditingOptionState(editingOption => !data ? data : { ...(editingOption !== null && editingOption !== void 0 ? editingOption : {}),
136
+ ...(typeof data === "function" ? data === null || data === void 0 ? void 0 : data(editingOption) : data),
137
+ isChanged: Boolean(editingOption)
138
+ });
139
+ };
140
+
141
+ const isEditingOptionError = (0, _react.useMemo)(() => {
142
+ if (!editingOption) return false;
143
+ return options.filter(_ref2 => {
144
+ let {
145
+ value
146
+ } = _ref2;
147
+ return value !== editingOption.value;
148
+ }).some(_ref3 => {
149
+ let {
150
+ label
151
+ } = _ref3;
152
+ return label === editingOption.label;
153
+ }) ? true : null;
154
+ }, [options, editingOption]);
133
155
  const [localOptionsStore, setLocalOptionsStore] = (0, _react.useState)({});
134
156
  const randomColorForNewOption = (0, _react.useMemo)(() => {
135
157
  const getRandomIndex = (min, max) => {
@@ -141,10 +163,10 @@ const TagsDropdown = _ref => {
141
163
  }, [options.length]);
142
164
  const singleLevelOptions = options === null || options === void 0 ? void 0 : options.reduce((acc, item) => {
143
165
  const checkUniqAndPush = (acc, item) => {
144
- const isExist = acc === null || acc === void 0 ? void 0 : acc.findIndex(_ref2 => {
166
+ const isExist = acc === null || acc === void 0 ? void 0 : acc.findIndex(_ref4 => {
145
167
  let {
146
168
  value
147
- } = _ref2;
169
+ } = _ref4;
148
170
  return value === (item === null || item === void 0 ? void 0 : item.value);
149
171
  });
150
172
 
@@ -167,79 +189,7 @@ const TagsDropdown = _ref => {
167
189
  }, isUseLocalOptionsStore ? (_Object$keys = Object.keys(localOptionsStore)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(value => ({
168
190
  value,
169
191
  label: localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[value]
170
- })) : []); // --- GENERAL FUNCTIONS BEGIN --- //
171
-
172
- const handleClickOutside = e => {
173
- var _editOptionModalRef$c, _getListContainer, _customTriggerRef$cur, _customTriggerRef$cur2;
174
-
175
- const {
176
- target
177
- } = e;
178
-
179
- if (editOptionModalRef.current && !((_editOptionModalRef$c = editOptionModalRef.current) !== null && _editOptionModalRef$c !== void 0 && _editOptionModalRef$c.contains(target)) && !document.getElementById(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value).contains(target)) {
180
- saveEditingOption();
181
- } else if (!((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(target)) && isOpen && (!(customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) || !(customTriggerRef !== null && customTriggerRef !== void 0 && (_customTriggerRef$cur = customTriggerRef.current) !== null && _customTriggerRef$cur !== void 0 && _customTriggerRef$cur.contains(target))) || customTriggerRef !== null && customTriggerRef !== void 0 && (_customTriggerRef$cur2 = customTriggerRef.current) !== null && _customTriggerRef$cur2 !== void 0 && _customTriggerRef$cur2.isEqualNode(target)) {
182
- setIsOpen(false);
183
- onDropdownListClose === null || onDropdownListClose === void 0 ? void 0 : onDropdownListClose(e);
184
- }
185
- };
186
-
187
- const closeList = e => {
188
- var _inputRef$current;
189
-
190
- handleClickOutside(e);
191
- if (!e.target.isEqualNode(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)) inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.blur();
192
- };
193
-
194
- const isTargetInParent = target => {
195
- var _target$className, _target$className$ind, _target$className2, _target$className2$in;
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;
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;
199
- return false;
200
- };
201
-
202
- const isItemMatchesSearch = item => {
203
- const title = item.title || item.label;
204
- return searchValue.length ? title === null || title === void 0 ? void 0 : title.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || "") : true;
205
- }; // --- GENERAL FUNCTIONS END --- //
206
-
207
-
208
- const prepareOptions = options => {
209
- return options === null || options === void 0 ? void 0 : options.map(option => option !== null && option !== void 0 && option.groupName ? option === null || option === void 0 ? void 0 : option.list : option).flat();
210
- };
211
-
212
- const getFilteredOptions = options => options === null || options === void 0 ? void 0 : options.reduce((result, option) => {
213
- if (option.groupName) {
214
- var _option$list;
215
-
216
- const filteredGroupItems = option === null || option === void 0 ? void 0 : (_option$list = option.list) === null || _option$list === void 0 ? void 0 : _option$list.filter(item => isItemMatchesSearch(item));
217
-
218
- if (filteredGroupItems !== null && filteredGroupItems !== void 0 && filteredGroupItems.length) {
219
- result.push({ ...option,
220
- list: filteredGroupItems
221
- });
222
- }
223
- } else if (isItemMatchesSearch(option)) {
224
- result.push(option);
225
- }
226
-
227
- return result;
228
- }, []);
229
-
230
- const getTotalOptions = (0, _react.useCallback)(() => {
231
- return options === null || options === void 0 ? void 0 : options.reduce((result, item) => {
232
- if (item !== null && item !== void 0 && item.list) {
233
- var _item$list2;
234
-
235
- result += (item === null || item === void 0 ? void 0 : (_item$list2 = item.list) === null || _item$list2 === void 0 ? void 0 : _item$list2.length) || 0;
236
- } else {
237
- ++result;
238
- }
239
-
240
- return result;
241
- }, 0);
242
- }, [options]);
192
+ })) : []);
243
193
 
244
194
  const deleteChosen = value => {
245
195
  if (isMobile ? closeOnRemoveMobile : closeOnRemove) setIsOpen(false);
@@ -251,104 +201,13 @@ const TagsDropdown = _ref => {
251
201
  }
252
202
 
253
203
  onChange(chosenOptions.filter(item => item !== value), "chosenOptions");
254
- };
255
-
256
- const onChangeHandler = item => {
257
- if (item !== null && item !== void 0 && item.isFreezed) return false;
258
-
259
- if ((item === null || item === void 0 ? void 0 : item.closeOnOptionSelect) !== undefined) {
260
- if (item.closeOnOptionSelect) setIsOpen(false);
261
- } else if (isMobile ? closeOnSelectMobile : closeOnSelect) setIsOpen(false);
204
+ }; // --- LIST CONTAINER FUNCTIONS BEGIN --- //
262
205
 
263
- setSearchValueInterceptor("");
264
-
265
- if (chosenOptions.some(el => el === item.value)) {
266
- deleteChosen(item.value);
267
- return null;
268
- }
269
-
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
-
276
- onChange([...chosenOptions, item.value], "chosenOptions");
277
- return null;
278
- };
279
-
280
- const onSearchHandler = name => {
281
- let inputValue = name;
282
- if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
283
- setSearchValueInterceptor(inputValue);
284
- };
285
-
286
- const onWrapperClick = e => {
287
- if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
288
- e.stopPropagation();
289
- e.preventDefault();
290
- setIsOpen(false);
291
- }
292
- };
293
-
294
- const selectAllItems = () => {
295
- var _prepareOptions;
296
-
297
- const preparedOptions = (_prepareOptions = prepareOptions(options)) === null || _prepareOptions === void 0 ? void 0 : _prepareOptions.filter(_ref3 => {
298
- let {
299
- isFreezed,
300
- value
301
- } = _ref3;
302
- return !isFreezed && !(chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.includes(value)) && value !== "open_modal";
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
-
316
- onChange([...chosenOptions, ...((preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(_ref5 => {
317
- let {
318
- value
319
- } = _ref5;
320
- return value;
321
- })) || [])], "chosenOptions");
322
- if (isMobile ? closeOnSelectAllMobile : closeOnSelectAll) setIsOpen(false);
323
- };
324
-
325
- const unselectAllItems = () => {
326
- if (isUseLocalOptionsStore) setLocalOptionsStore({});
327
- onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(item => {
328
- var _prepareOptions2, _prepareOptions2$find;
329
-
330
- return (_prepareOptions2 = prepareOptions(options)) === null || _prepareOptions2 === void 0 ? void 0 : (_prepareOptions2$find = _prepareOptions2.find(_ref6 => {
331
- let {
332
- value
333
- } = _ref6;
334
- return value === item;
335
- })) === null || _prepareOptions2$find === void 0 ? void 0 : _prepareOptions2$find.isFreezed;
336
- }), "chosenOptions");
337
- if (isMobile ? closeOnRemoveAllMobile : closeOnRemoveAll) setIsOpen(false);
338
- };
339
-
340
- const doScrollCallback = (0, _react.useCallback)(e => {
341
- if (doLiveSearchRequest && typeof doLiveSearchRequest === "function") {
342
- if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
343
- doLiveSearchRequest(searchValueRef.current, true);
344
- }
345
- }
346
- }, [options]); // --- LIST CONTAINER FUNCTIONS BEGIN --- //
347
206
 
348
207
  const getParentNode = () => {
349
- var _ref7, _document$querySelect;
208
+ var _ref5, _document$querySelect;
350
209
 
351
- return (_ref7 = (_document$querySelect = document.querySelector("div#root")) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector("div#app")) !== null && _ref7 !== void 0 ? _ref7 : document.querySelector("div#storybook-root");
210
+ return (_ref5 = (_document$querySelect = document.querySelector("div#root")) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector("div#app")) !== null && _ref5 !== void 0 ? _ref5 : document.querySelector("div#storybook-root");
352
211
  };
353
212
 
354
213
  const initListContainer = () => {
@@ -392,7 +251,7 @@ const TagsDropdown = _ref => {
392
251
  };
393
252
 
394
253
  const setListContainerStyles = () => {
395
- var _dropdownRef$current$, _dropdownRef$current, _getComputedStyle$mar, _getComputedStyle, _getComputedStyle$mar2, _getComputedStyle$max, _getComputedStyle2, _getComputedStyle2$ma, _dl$getBoundingClient, _sw$getBoundingClient, _sw$getBoundingClient2, _lh$getBoundingClient, _lf$getBoundingClient;
254
+ var _dropdownRef$current$, _dropdownRef$current, _getComputedStyle$mar, _getComputedStyle, _getComputedStyle$mar2, _getComputedStyle$max, _getComputedStyle2, _getComputedStyle2$ma, _sw$getBoundingClient, _sw$getBoundingClient2, _lh$getBoundingClient, _lf$getBoundingClient;
396
255
 
397
256
  const lc = getListContainer();
398
257
  if (!lc || !isOpen) return false;
@@ -412,9 +271,7 @@ const TagsDropdown = _ref => {
412
271
  if (initListHeight === null) setInitListHeight(maxHeight);
413
272
  const toTop = top - margin;
414
273
  const toBottom = windowHeight - top - height - margin * 2;
415
- const dlHeight = dl === null || dl === void 0 ? void 0 : (_dl$getBoundingClient = dl.getBoundingClientRect()) === null || _dl$getBoundingClient === void 0 ? void 0 : _dl$getBoundingClient.height;
416
274
  let swHeight = sw === null || sw === void 0 ? void 0 : (_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height;
417
- const controlsHeight = swHeight - dlHeight;
418
275
  if (swHeight > maxHeight) swHeight = maxHeight - 2 * margin;
419
276
  const maxSwHeight = (sw === null || sw === void 0 ? void 0 : (_sw$getBoundingClient2 = sw.getBoundingClientRect()) === null || _sw$getBoundingClient2 === void 0 ? void 0 : _sw$getBoundingClient2.height) - (lh === null || lh === void 0 ? void 0 : (_lh$getBoundingClient = lh.getBoundingClientRect()) === null || _lh$getBoundingClient === void 0 ? void 0 : _lh$getBoundingClient.height) - (lf === null || lf === void 0 ? void 0 : (_lf$getBoundingClient = lf.getBoundingClientRect()) === null || _lf$getBoundingClient === void 0 ? void 0 : _lf$getBoundingClient.height);
420
277
  const listPos = toTop < toBottom || toBottom >= swHeight ? "bottom" : "top";
@@ -447,7 +304,8 @@ const TagsDropdown = _ref => {
447
304
  },
448
305
  isEditable: true,
449
306
  ref: /*#__PURE__*/(0, _react.createRef)()
450
- };
307
+ }; // eslint-disable-next-line no-promise-executor-return
308
+
451
309
  ((_onOptionCreate = onOptionCreate === null || onOptionCreate === void 0 ? void 0 : onOptionCreate(newOption)) !== null && _onOptionCreate !== void 0 ? _onOptionCreate : new Promise(r => r())).then(result => {
452
310
  var _result$id;
453
311
 
@@ -455,10 +313,7 @@ const TagsDropdown = _ref => {
455
313
  newOption.value = (_result$id = result === null || result === void 0 ? void 0 : result.id) !== null && _result$id !== void 0 ? _result$id : tempId;
456
314
  setOptions(state => [...state, newOption]);
457
315
  setSearchValue("");
458
- onChangeHandler({
459
- value: tempId,
460
- label: searchValue
461
- });
316
+ onChangeHandler(newOption);
462
317
  });
463
318
  };
464
319
 
@@ -471,12 +326,13 @@ const TagsDropdown = _ref => {
471
326
  const onOptionDeleteClick = () => {
472
327
  var _onOptionDelete;
473
328
 
329
+ // eslint-disable-next-line no-promise-executor-return
474
330
  ((_onOptionDelete = onOptionDelete === null || onOptionDelete === void 0 ? void 0 : onOptionDelete(editingOption)) !== null && _onOptionDelete !== void 0 ? _onOptionDelete : new Promise(r => r())).then(() => {
475
331
  deleteChosen(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value);
476
- setOptions(options => options.filter(_ref8 => {
332
+ setOptions(options => options.filter(_ref6 => {
477
333
  let {
478
334
  value
479
- } = _ref8;
335
+ } = _ref6;
480
336
  return value !== (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value);
481
337
  }));
482
338
  setEditingOption(null);
@@ -484,6 +340,11 @@ const TagsDropdown = _ref => {
484
340
  };
485
341
 
486
342
  const saveEditingOption = () => {
343
+ if (!(editingOption !== null && editingOption !== void 0 && editingOption.isChanged) || isEditingOptionError) {
344
+ setEditingOption(null);
345
+ return false;
346
+ }
347
+
487
348
  onOptionEdit === null || onOptionEdit === void 0 ? void 0 : onOptionEdit(editingOption);
488
349
  setOptions(options => options.map(option => {
489
350
  if (editingOption && option.value === (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value)) {
@@ -498,49 +359,37 @@ const TagsDropdown = _ref => {
498
359
  };
499
360
 
500
361
  const setEditOptionModalStyles = () => {
501
- var _editingOption$ref, _el$getBoundingClient, _dropdownListWrapperR;
362
+ var _editingOption$ref, _el$getBoundingClient, _dropdownListWrapperR, _positionClasses;
502
363
 
503
364
  if (!editingOption || !(editOptionModalRef !== null && editOptionModalRef !== void 0 && editOptionModalRef.current)) return null;
504
- const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
365
+ const {
366
+ scrollX,
367
+ scrollY
368
+ } = window;
369
+ const positionClasses = {
370
+ left: "modal-left",
371
+ right: "modal-right"
372
+ };
505
373
  const windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
506
- console.log({
507
- windowHeight,
508
- windowWidth
509
- });
510
374
  const el = editingOption === null || editingOption === void 0 ? void 0 : (_editingOption$ref = editingOption.ref) === null || _editingOption$ref === void 0 ? void 0 : _editingOption$ref.current;
511
375
  const {
512
- top,
513
- bottom,
514
- left,
515
- right,
376
+ x,
377
+ y,
516
378
  width,
517
379
  height
518
380
  } = (_el$getBoundingClient = el === null || el === void 0 ? void 0 : el.getBoundingClientRect()) !== null && _el$getBoundingClient !== void 0 ? _el$getBoundingClient : {};
519
381
  const containerPosition = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperR = dropdownListWrapperRef.current) === null || _dropdownListWrapperR === void 0 ? void 0 : _dropdownListWrapperR.getBoundingClientRect();
520
-
521
- if ((containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.right) > (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.left) || (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.right) >= 182) {
522
- editOptionModalRef.current.style.left = "".concat(width - 50, "px");
523
- } else {
524
- editOptionModalRef.current.style.right = "".concat(right - width - 12, "px");
525
- } // console.log(containerPosition.top, {
526
- // top,
527
- // bottom,
528
- // left,
529
- // right,
530
- // width,
531
- // height,
532
- // });
533
-
534
-
535
- editOptionModalRef.current.style.top = "".concat(top - height, "px"); // if (containerPosition?.top + top <= 173) {
536
- // editOptionModalRef.current.style.top = `${top - height}px`;
537
- // } else {
538
- // editOptionModalRef.current.style.bottom = `${bottom - height}px`;
539
- // }
382
+ const widthToRight = windowWidth - (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.x) - (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.width);
383
+ Object.values(positionClasses).map(className => editOptionModalRef.current.classList.remove(className));
384
+ editOptionModalRef.current.classList.add((_positionClasses = positionClasses === null || positionClasses === void 0 ? void 0 : positionClasses[widthToRight < 182 ? "left" : "right"]) !== null && _positionClasses !== void 0 ? _positionClasses : "");
385
+ editOptionModalRef.current.style.left = "".concat(x + scrollX + width, "px");
386
+ editOptionModalRef.current.style.top = "".concat(y + scrollY + height + 10, "px");
387
+ editOptionModalRef.current.style.transform = widthToRight < 182 ? "translateX(calc(-100% + 7px))" : "translateX(-35px)";
540
388
  };
541
389
 
542
390
  const renderEditOptionModal = () => {
543
391
  return /*#__PURE__*/_react.default.createElement("div", {
392
+ key: "editOptionModal".concat(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value),
544
393
  ref: editOptionModalRef,
545
394
  className: (0, _classnames.default)("".concat(RC, "__edit-option-modal"))
546
395
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -550,9 +399,11 @@ const TagsDropdown = _ref => {
550
399
  onChange: v => setEditingOption(state => ({ ...state,
551
400
  label: v
552
401
  })),
402
+ error: isEditingOptionError,
553
403
  onKeyDown: keyCode => {
554
404
  if (keyCode === 13) saveEditingOption();
555
- }
405
+ },
406
+ symbolsLimit: "50"
556
407
  }), /*#__PURE__*/_react.default.createElement(_Button.default, {
557
408
  variant: "link",
558
409
  icon: /*#__PURE__*/_react.default.createElement(_reactFeather.Trash2, null),
@@ -568,6 +419,7 @@ const TagsDropdown = _ref => {
568
419
  var _editingOption$style;
569
420
 
570
421
  return /*#__PURE__*/_react.default.createElement("div", {
422
+ key: color,
571
423
  className: "color-block",
572
424
  style: {
573
425
  backgroundColor: color
@@ -580,8 +432,178 @@ const TagsDropdown = _ref => {
580
432
  }, (editingOption === null || editingOption === void 0 ? void 0 : (_editingOption$style = editingOption.style) === null || _editingOption$style === void 0 ? void 0 : _editingOption$style.backgroundColor) === color ? /*#__PURE__*/_react.default.createElement(_reactFeather.Check, null) : null);
581
433
  }))));
582
434
  }; // --- CREATABLE LOGIC END --- //
583
- // --- RENDER FUNCTIONS BEGIN --- //
435
+ // --- GENERAL FUNCTIONS BEGIN --- //
436
+
437
+
438
+ const handleClickOutside = e => {
439
+ var _getListContainer, _editOptionModalRef$c;
440
+
441
+ const {
442
+ target
443
+ } = e;
444
+
445
+ if (isOpen && !((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(target)) && !editOptionModalRef.current // &&
446
+ // (
447
+ // customTriggerRef?.current ? customTriggerRef?.current?.contains(target) : true
448
+ // )
449
+ ) {
450
+ setIsOpen(false);
451
+ onDropdownListClose === null || onDropdownListClose === void 0 ? void 0 : onDropdownListClose(e);
452
+ } else if (editOptionModalRef.current && !((_editOptionModalRef$c = editOptionModalRef.current) !== null && _editOptionModalRef$c !== void 0 && _editOptionModalRef$c.contains(target))) {
453
+ var _document, _document$getElementB2, _document$getElementB3, _document$getElementB4;
454
+
455
+ if (!((_document = document) !== null && _document !== void 0 && (_document$getElementB2 = _document.getElementById) !== null && _document$getElementB2 !== void 0 && (_document$getElementB3 = _document$getElementB2.call(_document, "editTrigger".concat(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value))) !== null && _document$getElementB3 !== void 0 && (_document$getElementB4 = _document$getElementB3.contains) !== null && _document$getElementB4 !== void 0 && _document$getElementB4.call(_document$getElementB3, target))) saveEditingOption();
456
+ }
457
+ };
458
+
459
+ const closeList = e => {
460
+ var _inputRef$current;
461
+
462
+ handleClickOutside(e);
463
+ if (!e.target.isEqualNode(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)) inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.blur();
464
+ };
465
+
466
+ const isTargetInParent = target => {
467
+ var _target$className, _target$className$ind, _target$className2, _target$className2$in;
468
+
469
+ 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;
470
+ 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;
471
+ return false;
472
+ };
473
+
474
+ const isItemMatchesSearch = item => {
475
+ const title = item.title || item.label;
476
+ return searchValue.length ? title === null || title === void 0 ? void 0 : title.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || "") : true;
477
+ }; // --- GENERAL FUNCTIONS END --- //
478
+
479
+
480
+ const prepareOptions = options => {
481
+ return options === null || options === void 0 ? void 0 : options.map(option => option !== null && option !== void 0 && option.groupName ? option === null || option === void 0 ? void 0 : option.list : option).flat();
482
+ };
483
+
484
+ const getFilteredOptions = options => options === null || options === void 0 ? void 0 : options.reduce((result, option) => {
485
+ if (option.groupName) {
486
+ var _option$list;
487
+
488
+ const filteredGroupItems = option === null || option === void 0 ? void 0 : (_option$list = option.list) === null || _option$list === void 0 ? void 0 : _option$list.filter(item => isItemMatchesSearch(item));
489
+
490
+ if (filteredGroupItems !== null && filteredGroupItems !== void 0 && filteredGroupItems.length) {
491
+ result.push({ ...option,
492
+ list: filteredGroupItems
493
+ });
494
+ }
495
+ } else if (isItemMatchesSearch(option)) {
496
+ result.push(option);
497
+ }
498
+
499
+ return result;
500
+ }, []);
501
+
502
+ const getTotalOptions = (0, _react.useCallback)(() => {
503
+ return options === null || options === void 0 ? void 0 : options.reduce((result, item) => {
504
+ if (item !== null && item !== void 0 && item.list) {
505
+ var _item$list2;
506
+
507
+ result += (item === null || item === void 0 ? void 0 : (_item$list2 = item.list) === null || _item$list2 === void 0 ? void 0 : _item$list2.length) || 0;
508
+ } else {
509
+ ++result;
510
+ }
511
+
512
+ return result;
513
+ }, 0);
514
+ }, [options]);
515
+
516
+ const onChangeHandler = item => {
517
+ if (item !== null && item !== void 0 && item.isFreezed) return false;
518
+
519
+ if ((item === null || item === void 0 ? void 0 : item.closeOnOptionSelect) !== undefined) {
520
+ if (item.closeOnOptionSelect) setIsOpen(false);
521
+ } else if (isMobile ? closeOnSelectMobile : closeOnSelect) setIsOpen(false);
584
522
 
523
+ setSearchValueInterceptor("");
524
+
525
+ if (chosenOptions.some(el => el === item.value)) {
526
+ deleteChosen(item.value);
527
+ return null;
528
+ }
529
+
530
+ if (isUseLocalOptionsStore) {
531
+ setLocalOptionsStore(options => ({ ...options,
532
+ [item === null || item === void 0 ? void 0 : item.value]: item === null || item === void 0 ? void 0 : item.label
533
+ }));
534
+ }
535
+
536
+ onChange([...chosenOptions, item.value], "chosenOptions");
537
+ return null;
538
+ };
539
+
540
+ const onSearchHandler = name => {
541
+ let inputValue = name;
542
+ if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
543
+ setSearchValueInterceptor(inputValue);
544
+ };
545
+
546
+ const onWrapperClick = e => {
547
+ if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
548
+ e.stopPropagation();
549
+ e.preventDefault();
550
+ setIsOpen(false);
551
+ }
552
+ };
553
+
554
+ const selectAllItems = () => {
555
+ var _prepareOptions;
556
+
557
+ const preparedOptions = (_prepareOptions = prepareOptions(options)) === null || _prepareOptions === void 0 ? void 0 : _prepareOptions.filter(_ref7 => {
558
+ let {
559
+ isFreezed,
560
+ value
561
+ } = _ref7;
562
+ return !isFreezed && !(chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.includes(value)) && value !== "open_modal";
563
+ });
564
+
565
+ if (isUseLocalOptionsStore) {
566
+ setLocalOptionsStore(options => preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.reduce((result, _ref8) => {
567
+ let {
568
+ value,
569
+ label
570
+ } = _ref8;
571
+ result[value] = label;
572
+ return result;
573
+ }, options));
574
+ }
575
+
576
+ onChange([...chosenOptions, ...((preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(_ref9 => {
577
+ let {
578
+ value
579
+ } = _ref9;
580
+ return value;
581
+ })) || [])], "chosenOptions");
582
+ if (isMobile ? closeOnSelectAllMobile : closeOnSelectAll) setIsOpen(false);
583
+ };
584
+
585
+ const unselectAllItems = () => {
586
+ if (isUseLocalOptionsStore) setLocalOptionsStore({});
587
+ onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(item => {
588
+ var _prepareOptions2, _prepareOptions2$find;
589
+
590
+ return (_prepareOptions2 = prepareOptions(options)) === null || _prepareOptions2 === void 0 ? void 0 : (_prepareOptions2$find = _prepareOptions2.find(_ref10 => {
591
+ let {
592
+ value
593
+ } = _ref10;
594
+ return value === item;
595
+ })) === null || _prepareOptions2$find === void 0 ? void 0 : _prepareOptions2$find.isFreezed;
596
+ }), "chosenOptions");
597
+ if (isMobile ? closeOnRemoveAllMobile : closeOnRemoveAll) setIsOpen(false);
598
+ };
599
+
600
+ const doScrollCallback = (0, _react.useCallback)(e => {
601
+ if (doLiveSearchRequest && typeof doLiveSearchRequest === "function") {
602
+ if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
603
+ doLiveSearchRequest(searchValueRef.current, true);
604
+ }
605
+ }
606
+ }, [options]); // --- RENDER FUNCTIONS BEGIN --- //
585
607
 
586
608
  const getMarkupForElement = item => {
587
609
  var _title$toString, _item$customMobileIco;
@@ -643,7 +665,7 @@ const TagsDropdown = _ref => {
643
665
  }, hightlightSearchValue(title)), description && /*#__PURE__*/_react.default.createElement("span", {
644
666
  className: (0, _classnames.default)("".concat(RC, "__list-item-description"))
645
667
  }, description)), !isMobile && (item === null || item === void 0 ? void 0 : item.isEditable) && /*#__PURE__*/_react.default.createElement("div", {
646
- id: item === null || item === void 0 ? void 0 : item.value,
668
+ id: "editTrigger".concat(item === null || item === void 0 ? void 0 : item.value),
647
669
  className: (0, _classnames.default)("".concat(RC, "__list-item-edit-trigger")),
648
670
  onClick: e => onOptionEditClick(e, item)
649
671
  }, /*#__PURE__*/_react.default.createElement(_reactFeather.MoreHorizontal, null)), isMobile ? (_item$customMobileIco = item === null || item === void 0 ? void 0 : item.customMobileIcon) !== null && _item$customMobileIco !== void 0 ? _item$customMobileIco : /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, {
@@ -655,7 +677,7 @@ const TagsDropdown = _ref => {
655
677
  };
656
678
 
657
679
  const getListMarkUp = () => {
658
- var _filteredOptions$filt, _filteredOptions$filt2;
680
+ var _filteredOptions$filt, _filteredOptions$filt2, _document$getElementB5;
659
681
 
660
682
  const filteredOptions = getFilteredOptions(options);
661
683
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -704,10 +726,10 @@ const TagsDropdown = _ref => {
704
726
  className: (0, _classnames.default)("".concat(RC, "__header-row"))
705
727
  }, headerContent)) : null, withSearchInputInList && /*#__PURE__*/_react.default.createElement("div", {
706
728
  className: (0, _classnames.default)("".concat(RC, "__input-list-wrapper"))
707
- }, renderSearchInput()), withCreateLogic && searchValue && filteredOptions.length && singleLevelOptions.every(_ref9 => {
729
+ }, renderSearchInput()), withCreateLogic && searchValue && filteredOptions.length && singleLevelOptions.every(_ref11 => {
708
730
  let {
709
731
  label
710
- } = _ref9;
732
+ } = _ref11;
711
733
  return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
712
734
  }) ? /*#__PURE__*/_react.default.createElement("div", {
713
735
  className: (0, _classnames.default)("".concat(RC, "__creatable-helper"))
@@ -723,17 +745,17 @@ const TagsDropdown = _ref => {
723
745
  }, /*#__PURE__*/_react.default.createElement("span", {
724
746
  className: "".concat(RC, "-group__name")
725
747
  }, option.groupName), (_option$list2 = option.list) === null || _option$list2 === void 0 ? void 0 : _option$list2.map(item => getMarkupForElement(item))) : getMarkupForElement(option);
726
- }), ((_filteredOptions$filt = filteredOptions.filter(_ref10 => {
748
+ }), ((_filteredOptions$filt = filteredOptions.filter(_ref12 => {
727
749
  let {
728
750
  value
729
- } = _ref10;
751
+ } = _ref12;
730
752
  return value !== "open_modal";
731
753
  })) === null || _filteredOptions$filt === void 0 ? void 0 : _filteredOptions$filt.length) === 0 && (!withCreateLogic || !searchValue) ? /*#__PURE__*/_react.default.createElement("div", {
732
754
  className: "".concat(RC, "__no-options")
733
- }, noOptionsText) : null), (footerContent || isMobile) && ((_filteredOptions$filt2 = filteredOptions.filter(_ref11 => {
755
+ }, noOptionsText) : null), (footerContent || isMobile) && ((_filteredOptions$filt2 = filteredOptions.filter(_ref13 => {
734
756
  let {
735
757
  value
736
- } = _ref11;
758
+ } = _ref13;
737
759
  return value !== "open_modal";
738
760
  })) === null || _filteredOptions$filt2 === void 0 ? void 0 : _filteredOptions$filt2.length) > 0 ? /*#__PURE__*/_react.default.createElement("div", {
739
761
  className: (0, _classnames.default)("".concat(RC, "__footer"), {
@@ -742,10 +764,10 @@ const TagsDropdown = _ref => {
742
764
  })
743
765
  }, footerContent, isMobile && /*#__PURE__*/_react.default.createElement("button", {
744
766
  onClick: () => setIsOpen(false)
745
- }, "Apply", chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.length ? "(".concat(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.length, ")") : "")) : null, editingOption && renderEditOptionModal(), withCreateLogic && searchValue && singleLevelOptions.every(_ref12 => {
767
+ }, "Apply", chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.length ? "(".concat(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.length, ")") : "")) : null, editingOption && /*#__PURE__*/(0, _reactDom.createPortal)(renderEditOptionModal(), (_document$getElementB5 = document.getElementById("app")) !== null && _document$getElementB5 !== void 0 ? _document$getElementB5 : document.body), withCreateLogic && searchValue && singleLevelOptions.every(_ref14 => {
746
768
  let {
747
769
  label
748
- } = _ref12;
770
+ } = _ref14;
749
771
  return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
750
772
  }) && /*#__PURE__*/_react.default.createElement("div", {
751
773
  className: (0, _classnames.default)("".concat(RC, "__create-option")),
@@ -770,10 +792,10 @@ const TagsDropdown = _ref => {
770
792
  placeholder: placeholder || "Select from list",
771
793
  attributesOfNativeInput: { ...attributesOfNativeInput,
772
794
  onKeyDown: e => {
773
- if (e.keyCode === 13 && withCreateLogic && singleLevelOptions.every(_ref13 => {
795
+ if (e.keyCode === 13 && withCreateLogic && singleLevelOptions.every(_ref15 => {
774
796
  let {
775
797
  label
776
- } = _ref13;
798
+ } = _ref15;
777
799
  return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
778
800
  })) {
779
801
  onOptionCreateClick();
@@ -799,10 +821,10 @@ const TagsDropdown = _ref => {
799
821
  "tags-dropdown__error": error,
800
822
  ["".concat(RC, "__trigger--with-actions")]: withActions
801
823
  }),
802
- onClick: _ref14 => {
824
+ onClick: _ref16 => {
803
825
  let {
804
826
  target
805
- } = _ref14;
827
+ } = _ref16;
806
828
 
807
829
  if ((target === null || target === void 0 ? void 0 : target.tagName) === "INPUT") {
808
830
  setIsOpen(true);
@@ -928,11 +950,19 @@ const TagsDropdown = _ref => {
928
950
  if (isOpen) {
929
951
  var _getListContainer5, _inputRef$current2, _inputRef$current2$fo;
930
952
 
953
+ if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
954
+ customTriggerRef.current.style.pointerEvents = "none";
955
+ }
956
+
931
957
  (_getListContainer5 = getListContainer()) === null || _getListContainer5 === void 0 ? void 0 : _getListContainer5.classList.add("tags-dropdown__container--opened");
932
958
  inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : (_inputRef$current2$fo = _inputRef$current2.focus) === null || _inputRef$current2$fo === void 0 ? void 0 : _inputRef$current2$fo.call(_inputRef$current2);
933
959
  } else {
934
960
  var _getListContainer6;
935
961
 
962
+ if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
963
+ customTriggerRef.current.style.pointerEvents = "auto";
964
+ }
965
+
936
966
  (_getListContainer6 = getListContainer()) === null || _getListContainer6 === void 0 ? void 0 : _getListContainer6.classList.remove("tags-dropdown__container--opened");
937
967
  if (withSearchInputInList) setSearchValueInterceptor("");
938
968
  }
@@ -89,7 +89,7 @@
89
89
  &--in-list {
90
90
  width: 100%;
91
91
  box-sizing: border-box;
92
- padding: 4px 8px;
92
+ padding: 4px 8px;
93
93
  height: 28px;
94
94
 
95
95
  &:focus {
@@ -179,7 +179,7 @@
179
179
  box-shadow: 0 4px 25px rgb(0 0 0 / 25%);
180
180
  max-height: 320px;
181
181
  }
182
-
182
+
183
183
 
184
184
  &__list {
185
185
  height: 100%;
@@ -351,7 +351,7 @@
351
351
  color: #1E1E2D;
352
352
  }
353
353
  }
354
-
354
+
355
355
  &__edit-option-modal {
356
356
  position: absolute;
357
357
  display: flex;
@@ -362,7 +362,17 @@
362
362
  border-radius: 4px;
363
363
  background: var(--White, #FFF);
364
364
  box-shadow: 0px 4px 25px 0px rgba(0, 0, 0, 0.25);
365
- z-index: 3;
365
+ z-index: 999999;
366
+
367
+ &:before {
368
+ content: '';
369
+ position: absolute;
370
+ width: 12px;
371
+ height: 12px;
372
+ background: #FFFFFF;
373
+ transform: rotate(45deg);
374
+ top: -6px;
375
+ }
366
376
 
367
377
  &-section {
368
378
  display: flex;
@@ -446,6 +456,18 @@
446
456
  }
447
457
  }
448
458
 
459
+ &__edit-option-modal.modal-left {
460
+ &::before {
461
+ right: 15px;
462
+ }
463
+ }
464
+
465
+ &__edit-option-modal.modal-right {
466
+ &::before {
467
+ left: 15px;
468
+ }
469
+ }
470
+
449
471
  &__active-icon {
450
472
  position: absolute;
451
473
  top: 0;
@@ -39,10 +39,7 @@ const Textarea = _ref => {
39
39
  change: val => {
40
40
  let inputValue = val;
41
41
  if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
42
-
43
- if (inputValue !== val) {
44
- onChange(inputValue);
45
- }
42
+ onChange(inputValue);
46
43
  }
47
44
  };
48
45
 
@@ -22,6 +22,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
22
22
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
23
 
24
24
  const Tag = _ref => {
25
+ var _tagRef$current$getBo, _tagRef$current;
26
+
25
27
  let {
26
28
  value,
27
29
  className,
@@ -40,8 +42,34 @@ const Tag = _ref => {
40
42
  testId = "test-tag",
41
43
  testIdRemove = "test-tag-remove"
42
44
  } = _ref;
45
+ const tagRef = useRef();
43
46
  const [isTagHover, setIsTagHover] = (0, _react.useState)(false);
44
47
  const [isTagPopupOpened, setIsTagPopupOpened] = (0, _react.useState)(false);
48
+ const {
49
+ x,
50
+ y,
51
+ height,
52
+ width
53
+ } = (_tagRef$current$getBo = tagRef === null || tagRef === void 0 ? void 0 : (_tagRef$current = tagRef.current) === null || _tagRef$current === void 0 ? void 0 : _tagRef$current.getBoundingClientRect()) !== null && _tagRef$current$getBo !== void 0 ? _tagRef$current$getBo : {};
54
+ const {
55
+ scrollY
56
+ } = window;
57
+ const tagPopupStyles = useMemo(() => {
58
+ var _tagRef$current2;
59
+
60
+ if (!isTagPopupOpened || !(tagRef !== null && tagRef !== void 0 && tagRef.current)) return {};
61
+ const {
62
+ x,
63
+ y,
64
+ height,
65
+ width
66
+ } = tagRef === null || tagRef === void 0 ? void 0 : (_tagRef$current2 = tagRef.current) === null || _tagRef$current2 === void 0 ? void 0 : _tagRef$current2.getBoundingClientRect();
67
+ return {
68
+ left: "".concat(x, "px"),
69
+ top: "".concat(y + scrollY, "px"),
70
+ transform: "translate(calc(-1 * calc(100% - ".concat(width / 2 + 22, "px)), ").concat(height + 10, "px)")
71
+ };
72
+ }, [isTagPopupOpened, x, y, width, height, scrollY]);
45
73
  const handle = {
46
74
  onTagClick: () => {
47
75
  if (isPopup) {
@@ -81,7 +109,8 @@ const Tag = _ref => {
81
109
  "tag-warn": warning
82
110
  }),
83
111
  style: style !== null && style !== void 0 ? style : {},
84
- onClick: () => handle.onTagClick()
112
+ onClick: () => handle.onTagClick(),
113
+ ref: tagRef
85
114
  }, warning && typeof warning === "string" && /*#__PURE__*/_react.default.createElement(_reactFeather.AlertTriangle, {
86
115
  className: "advanced-tags--warning-icon mr5"
87
116
  }), warning && typeof warning === "string" && isTagHover && /*#__PURE__*/_react.default.createElement("div", {
@@ -94,11 +123,13 @@ const Tag = _ref => {
94
123
  className: "tag__button"
95
124
  }, /*#__PURE__*/_react.default.createElement(_reactFeather.X, {
96
125
  className: "color--text"
97
- })), isTagPopupOpened && /*#__PURE__*/_react.default.createElement("div", {
98
- className: (0, _classnames.default)("tag__popup", popupClassName)
126
+ })), isTagPopupOpened && createPortal( /*#__PURE__*/_react.default.createElement("div", {
127
+ id: "tagPopup".concat(value),
128
+ className: (0, _classnames.default)("tag__popup", popupClassName),
129
+ style: tagPopupStyles
99
130
  }, !popupInfo ? /*#__PURE__*/_react.default.createElement(_Spinner.default, {
100
131
  size: "small"
101
- }) : popupInfoContent));
132
+ }) : popupInfoContent), document.getElementById("app")));
102
133
  };
103
134
 
104
135
  var _default = Tag;
@@ -89,14 +89,13 @@
89
89
 
90
90
  .tag__popup {
91
91
  position: absolute;
92
- top: 34px;
93
92
  background: #FFFFFF;
94
93
  box-shadow: 0px 4px 25px 0px rgba(0, 0, 0, 0.25);
95
- z-index: 1;
96
- right: 0px;
94
+ z-index: 9999;
97
95
  border-radius: 4px;
98
96
  min-height: 60px;
99
97
  min-width: 200px;
98
+ width: fit-content;
100
99
  box-sizing: border-box;
101
100
  padding: 8px;
102
101
 
@@ -11,6 +11,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
 
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
 
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
14
16
  var _reactFeather = require("react-feather");
15
17
 
16
18
  var _utils = require("../../../Functions/utils");
@@ -25,6 +27,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
25
27
 
26
28
  const TagList = _ref => {
27
29
  let {
30
+ disabled,
28
31
  className,
29
32
  onTagClick,
30
33
  removeItem = null,
@@ -34,11 +37,9 @@ const TagList = _ref => {
34
37
  shownItemsCount = "auto",
35
38
  testId = "test-taglist",
36
39
  refProp,
40
+ renderOrder,
37
41
  onEditClick,
38
- onToggleRenderAll,
39
- isPopup,
40
- popupInfo,
41
- popupInfoContent
42
+ onToggleRenderAll
42
43
  } = _ref;
43
44
  const wrapperRef = (0, _react.useRef)(null);
44
45
  const [wrapperWidth, setWrapperWidth] = (0, _react.useState)(-1);
@@ -106,21 +107,36 @@ const TagList = _ref => {
106
107
  };
107
108
 
108
109
  const renderTags = () => {
109
- return tagList.map((item, i) => ({ ...item,
110
- isHidden: renderItemsCount !== -1 ? i >= renderItemsCount : false
111
- })).map(item => /*#__PURE__*/_react.default.createElement("div", {
112
- className: "tag-list_wrapper_item ".concat(item.isHidden ? "tag-list_wrapper_item--hidden" : ""),
113
- key: "tag-list-item-".concat(item.id),
114
- ref: (0, _utils.checkedRef)(item === null || item === void 0 ? void 0 : item.itemRef)
115
- }, /*#__PURE__*/_react.default.createElement(_Tag.default, (0, _extends2.default)({
116
- testId: "test-taglist-item-".concat(item.id)
117
- }, item, {
118
- onClick: onTagClick,
119
- removeItem: removeItem,
120
- isPopup: isPopup,
121
- popupInfo: popupInfo,
122
- popupInfoContent: popupInfoContent
123
- }))));
110
+ const tagsRenderOrder = renderOrder !== null && renderOrder !== void 0 ? renderOrder : tagList.map(_ref4 => {
111
+ let {
112
+ value,
113
+ id
114
+ } = _ref4;
115
+ return value !== null && value !== void 0 ? value : id;
116
+ });
117
+ return tagsRenderOrder.map((v, i) => {
118
+ var _item$id, _item$id2;
119
+
120
+ const item = tagList.find(_ref5 => {
121
+ let {
122
+ value,
123
+ id
124
+ } = _ref5;
125
+ return (value !== null && value !== void 0 ? value : id) === v;
126
+ });
127
+ if (!item) return null;
128
+ const isHidden = renderItemsCount !== -1 ? i >= renderItemsCount : false;
129
+ return /*#__PURE__*/_react.default.createElement("div", {
130
+ className: "tag-list_wrapper_item ".concat(isHidden ? "tag-list_wrapper_item--hidden" : ""),
131
+ key: "tag-list-item-".concat((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.value),
132
+ ref: (0, _utils.checkedRef)(item === null || item === void 0 ? void 0 : item.itemRef)
133
+ }, /*#__PURE__*/_react.default.createElement(_Tag.default, (0, _extends2.default)({
134
+ testId: "test-taglist-item-".concat((_item$id2 = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id2 !== void 0 ? _item$id2 : item === null || item === void 0 ? void 0 : item.value)
135
+ }, item, {
136
+ onClick: onTagClick,
137
+ removeItem: removeItem
138
+ })));
139
+ });
124
140
  };
125
141
 
126
142
  const renderMoreTags = () => {
@@ -184,7 +200,9 @@ const TagList = _ref => {
184
200
  if (wrapperRef !== null && wrapperRef !== void 0 && wrapperRef.current && refProp) refProp.current = wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current;
185
201
  }, [wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current]);
186
202
  return /*#__PURE__*/_react.default.createElement("div", {
187
- className: "tag-list_wrapper ".concat(renderItemsCount !== (tagList === null || tagList === void 0 ? void 0 : tagList.length) || !withToggle || staticTagsCount === -1 || staticTagsCount === (tagList === null || tagList === void 0 ? void 0 : tagList.length) ? "tag-list_wrapper--only-static-items" : "tag-list_wrapper--all-items", " ").concat(className !== null && className !== void 0 ? className : ""),
203
+ className: (0, _classnames.default)("tag-list_wrapper", "".concat(renderItemsCount !== (tagList === null || tagList === void 0 ? void 0 : tagList.length) || !withToggle || staticTagsCount === -1 || staticTagsCount === (tagList === null || tagList === void 0 ? void 0 : tagList.length) ? "tag-list_wrapper--only-static-items" : "tag-list_wrapper--all-items"), className, {
204
+ "tag-list_wrapper--disabled": disabled
205
+ }),
188
206
  ref: wrapperRef
189
207
  }, renderTags(), renderMoreTags(), renderHideTags(), typeof onEditClick === "function" && /*#__PURE__*/_react.default.createElement("div", {
190
208
  className: "tag-list__edit-trigger"
@@ -6,6 +6,13 @@
6
6
  min-width: 100%;
7
7
  max-width: 100%;
8
8
 
9
+ &--disabled {
10
+ filter: grayscale(0.2);
11
+ * {
12
+ pointer-events: none!important;
13
+ }
14
+ }
15
+
9
16
  &--only-static-items {
10
17
  display: flex;
11
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.4.22",
3
+ "version": "1.4.24",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [