intelicoreact 1.4.44 → 1.4.46

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.
@@ -428,7 +428,7 @@ const Dropdown = _ref => {
428
428
  (0, _react.useEffect)(() => {
429
429
  if (!isDoNotPullOutListOfMainContainer || dropdownRef.current) {
430
430
  initListContainer();
431
- if (isDefaultOpened) setIsOpen(true);
431
+ if (isDefaultOpened && !isMobileProp) setIsOpen(true);
432
432
  }
433
433
  }, [isDoNotPullOutListOfMainContainer, dropdownRef.current]);
434
434
  (0, _react.useLayoutEffect)(() => {
@@ -90,6 +90,7 @@ const TagsDropdown = _ref => {
90
90
  const isMobile = isMobileProp && withMobileLogic && window.screen.width <= 768;
91
91
  const [dropdownId] = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2));
92
92
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
93
+ const [listPos, setListPos] = (0, _react.useState)(null);
93
94
  const [initListHeight, setInitListHeight] = (0, _react.useState)(null);
94
95
  const [isScrollableList, setIsScrollableList] = (0, _react.useState)(null);
95
96
  const [isFixedMaxHeight, setIsFixedMaxHeight] = (0, _react.useState)(false);
@@ -232,18 +233,28 @@ const TagsDropdown = _ref => {
232
233
  let selectorWrapperHeight = selectorWrapper === null || selectorWrapper === void 0 || (_selectorWrapper$getB = selectorWrapper.getBoundingClientRect()) === null || _selectorWrapper$getB === void 0 ? void 0 : _selectorWrapper$getB.height;
233
234
  const maxSelectorWrapperHeight = 500 - ((_listHeader$getBoundi = listHeader === null || listHeader === void 0 || (_listHeader$getBoundi2 = listHeader.getBoundingClientRect()) === null || _listHeader$getBoundi2 === void 0 ? void 0 : _listHeader$getBoundi2.height) !== null && _listHeader$getBoundi !== void 0 ? _listHeader$getBoundi : 0) - ((_listFooter$getBoundi = listFooter === null || listFooter === void 0 || (_listFooter$getBoundi2 = listFooter.getBoundingClientRect()) === null || _listFooter$getBoundi2 === void 0 ? void 0 : _listFooter$getBoundi2.height) !== null && _listFooter$getBoundi !== void 0 ? _listFooter$getBoundi : 0);
234
235
  if (!isMobile || !withMobileLogic) {
235
- var _getComputedStyle2, _dropdownListMaxHeigh;
236
+ var _getComputedStyle2, _dropdownListMaxHeigh, _customTriggerRef$cur, _customTriggerRef$cur2;
236
237
  const dropdownListMaxHeightInPx = (_getComputedStyle2 = getComputedStyle(dropdownList)) === null || _getComputedStyle2 === void 0 ? void 0 : _getComputedStyle2.maxHeight;
237
238
  const maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_dropdownListMaxHeigh = dropdownListMaxHeightInPx === null || dropdownListMaxHeightInPx === void 0 ? void 0 : dropdownListMaxHeightInPx.replace("px", "")) !== null && _dropdownListMaxHeigh !== void 0 ? _dropdownListMaxHeigh : 0, 10);
238
239
  if (initListHeight === null && !isNaN(maxHeight)) setInitListHeight(maxHeight);
239
240
  if (selectorWrapperHeight > maxHeight && !isNaN(maxHeight)) selectorWrapperHeight = maxHeight - 2 * margin;
240
- const toTop = top - margin;
241
+ const toTop = renderCustomTrigger ? top - margin - ((_customTriggerRef$cur = customTriggerRef === null || customTriggerRef === void 0 || (_customTriggerRef$cur2 = customTriggerRef.current) === null || _customTriggerRef$cur2 === void 0 || (_customTriggerRef$cur2 = _customTriggerRef$cur2.getBoundingClientRect()) === null || _customTriggerRef$cur2 === void 0 ? void 0 : _customTriggerRef$cur2.height) !== null && _customTriggerRef$cur !== void 0 ? _customTriggerRef$cur : 0) : top - margin;
241
242
  const toBottom = windowHeight - top - height - margin * 2;
242
- const listPos = toTop < toBottom || toBottom >= selectorWrapperHeight ? "bottom" : "top";
243
- if (selectorWrapperHeight > (listPos === "top" ? toTop : toBottom)) selectorWrapperHeight = (listPos === "top" ? toTop : toBottom) - 3 * margin;
243
+ let listPosition = listPos;
244
+ if (!listPos && options.length) {
245
+ listPosition = toTop < toBottom || toBottom >= selectorWrapperHeight ? "bottom" : "top";
246
+ setListPos(listPosition);
247
+ }
248
+ if (selectorWrapperHeight > (listPosition === "top" ? toTop : toBottom)) {
249
+ selectorWrapperHeight = (listPosition === "top" ? toTop : toBottom) - 3 * margin;
250
+ if (selectorWrapperHeight < 200) {
251
+ selectorWrapperHeight = 200;
252
+ }
253
+ selectorWrapper.style.maxHeight = "".concat(selectorWrapperHeight, "px");
254
+ }
244
255
  listContainer.style.minWidth = "".concat(width, "px");
245
256
  listContainer.style.left = "".concat(left, "px");
246
- listContainer.style.top = "".concat(listPos === "bottom" ? top + height : top - selectorWrapperHeight - 2 * margin, "px");
257
+ listContainer.style.top = "".concat(listPosition === "bottom" ? top + height : top - selectorWrapperHeight - 2 * margin, "px");
247
258
  } else {
248
259
  dropdownList.style.maxHeight = "".concat(maxSelectorWrapperHeight, "px");
249
260
  }
@@ -813,7 +824,7 @@ const TagsDropdown = _ref => {
813
824
 
814
825
  (0, _react.useLayoutEffect)(() => {
815
826
  initListContainer();
816
- if (isDefaultOpened) setIsOpen(true);
827
+ if (isDefaultOpened && !isMobileProp) setIsOpen(true);
817
828
  return () => {
818
829
  var _getListContainer2, _getListContainerWrap;
819
830
  (_getListContainer2 = getListContainer()) === null || _getListContainer2 === void 0 || _getListContainer2.remove();
@@ -822,38 +833,33 @@ const TagsDropdown = _ref => {
822
833
  }, []);
823
834
  (0, _react.useLayoutEffect)(() => {
824
835
  var _getListContainer3;
825
- const onResize = () => {
826
- setListContainerStyles();
827
- setEditOptionModalStyles();
828
- };
829
836
  if (!isMobile) {
830
- window.addEventListener("resize", onResize);
831
837
  window.addEventListener("mousewheel", closeList);
832
- window.addEventListener("scroll", closeList);
838
+ window.addEventListener("wheel", closeList);
833
839
  window.addEventListener("touchmove", closeList);
834
840
  window.addEventListener("mouseup", handleClickOutside);
835
841
  } else {
836
- window.removeEventListener("resize", onResize);
837
842
  window.removeEventListener("mousewheel", closeList);
838
- window.removeEventListener("scroll", closeList);
843
+ window.removeEventListener("wheel", closeList);
839
844
  window.removeEventListener("touchmove", closeList);
840
845
  window.removeEventListener("mouseup", handleClickOutside);
841
846
  }
842
847
  (_getListContainer3 = getListContainer()) === null || _getListContainer3 === void 0 || _getListContainer3.addEventListener("click", closeList);
843
848
  return () => {
844
849
  var _getListContainer4;
845
- window.removeEventListener("resize", onResize);
846
850
  window.removeEventListener("mousewheel", closeList);
847
851
  window.removeEventListener("mouseup", handleClickOutside);
848
- window.removeEventListener("scroll", closeList);
852
+ window.removeEventListener("wheel", closeList);
849
853
  window.removeEventListener("touchmove", closeList);
850
854
  (_getListContainer4 = getListContainer()) === null || _getListContainer4 === void 0 || _getListContainer4.removeEventListener("click", closeList);
851
855
  };
852
856
  }, [getListContainer, isMobile]);
853
857
  (0, _react.useLayoutEffect)(() => {
854
- setListContainerStyles();
855
- setEditOptionModalStyles();
856
- }, [isOpen, optionsProp, chosenOptions, isMobile, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 || (_dropdownListWrapperR2 = dropdownListWrapperRef.current) === null || _dropdownListWrapperR2 === void 0 || (_dropdownListWrapperR2 = _dropdownListWrapperR2.getBoundingClientRect()) === null || _dropdownListWrapperR2 === void 0 ? void 0 : _dropdownListWrapperR2.height, recalculateListContainerStylesTrigger]);
858
+ if (isOpen) {
859
+ setListContainerStyles();
860
+ setEditOptionModalStyles();
861
+ }
862
+ }, [isOpen, optionsProp, chosenOptions, searchValue, isMobile, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 || (_dropdownListWrapperR2 = dropdownListWrapperRef.current) === null || _dropdownListWrapperR2 === void 0 || (_dropdownListWrapperR2 = _dropdownListWrapperR2.getBoundingClientRect()) === null || _dropdownListWrapperR2 === void 0 ? void 0 : _dropdownListWrapperR2.height, recalculateListContainerStylesTrigger]);
857
863
  (0, _react.useEffect)(() => {
858
864
  if (isUseLocalOptionsStore && chosenOptions.length !== Object.keys(localOptionsStore).length) {
859
865
  options.map(option => {
@@ -891,6 +897,8 @@ const TagsDropdown = _ref => {
891
897
  }
892
898
  (_getListContainer6 = getListContainer()) === null || _getListContainer6 === void 0 || _getListContainer6.classList.remove("tags-dropdown__container--opened");
893
899
  if (withSearchInputInList) setSearchValueInterceptor("");
900
+ setListPos(null);
901
+ setSearchValue("");
894
902
  }
895
903
  }, [isOpen]);
896
904
  (0, _react.useEffect)(() => {
@@ -311,6 +311,10 @@
311
311
  padding: 2px;
312
312
  align-items: flex-start;
313
313
  gap: 4px;
314
+ width: 20px;
315
+ height: 20px;
316
+ min-width: 20px;
317
+ min-height: 20px;
314
318
 
315
319
  &:hover {
316
320
  background-color: #EBEFF2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.4.44",
3
+ "version": "1.4.46",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [