react-core-ts 1.2.30 → 1.2.32

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.
@@ -81,7 +81,6 @@ const AutoCompleteWithSelectedList = forwardRef<
81
81
  const [nextPage, setNextPage] = useState<number | undefined>(1);
82
82
  const [dropOpen, setDropOpen] = useState<boolean>(false);
83
83
  const [selectedItems, setSelectedItems] = useState<ValueProps[]>([]);
84
-
85
84
  const [showAllSelected, setShowAllSelected] = useState<boolean>(false);
86
85
  const [expandArrowClick, setExpandArrowClick] = useState<
87
86
  number | undefined
@@ -92,8 +91,8 @@ const AutoCompleteWithSelectedList = forwardRef<
92
91
  const dropRef = useRef(null);
93
92
  const inputSearchRef = useRef(null);
94
93
  useImperativeHandle(ref, () => inputRef.current);
95
- const [dropdownStyle, setDropdownStyle] = useState<any>({
96
- top: undefined,
94
+ const [dropdownStyle, setDropdownStyle] = useState({
95
+ top: 0,
97
96
  left: 0,
98
97
  width: 200,
99
98
  });
@@ -109,27 +108,24 @@ const AutoCompleteWithSelectedList = forwardRef<
109
108
  // Check if there's enough space below the input for the dropdown
110
109
  const spaceBelow = window.innerHeight - inputRect.bottom;
111
110
  const spaceAbove = inputRect.top + window.scrollY;
112
- let dropdownHeight = viewMode ? 160 : 380; // Assume a fixed height or calculate based on content
113
111
 
114
- if (countOnly && !viewMode) {
115
- // if (dropdownSelectedRef?.current) {
116
- // dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
117
- // }
118
- dropdownHeight += type === 'auto_suggestion' ? 220 : 192;
112
+ let dropdownHeight = viewMode ? 160 : 300; // Assume a fixed height or calculate based on content
113
+ if (countOnly) {
114
+ if (dropdownSelectedRef?.current)
115
+ dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
119
116
  }
120
117
 
121
118
  if (tab.length > 0) {
122
119
  if (tabRef?.current) dropdownHeight += tabRef?.current?.clientHeight;
123
120
  }
124
- console.log(dropdownHeight);
125
121
  if (spaceBelow >= dropdownHeight) {
126
122
  dropdownPosition.top =
127
123
  inputRect.top + window.scrollY + inputRect.height;
128
124
  } else {
129
- dropdownPosition.top = viewMode
130
- ? inputRect.top + window.scrollY - dropdownHeight + 18 + topMargin
131
- : inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
125
+ dropdownPosition.top =
126
+ inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
132
127
  }
128
+
133
129
  setDropdownStyle({
134
130
  ...dropdownPosition,
135
131
  });
@@ -143,7 +139,7 @@ const AutoCompleteWithSelectedList = forwardRef<
143
139
  return () => {
144
140
  window.removeEventListener('resize', adjustDropdownPosition);
145
141
  };
146
- }, [selectedItems, expandArrowClick, dropOpen]);
142
+ }, [dropOpen, selectedItems, expandArrowClick]);
147
143
 
148
144
  const { suggestions, isLoading, handlePickSuggestions } = useSuggestions(
149
145
  getData,
@@ -230,7 +226,7 @@ const AutoCompleteWithSelectedList = forwardRef<
230
226
 
231
227
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
232
228
  const { value } = e.target;
233
- // setDropOpen(true);
229
+ setDropOpen(true);
234
230
  setSearchValue(value);
235
231
  handleChangeWithDebounce(value);
236
232
  if (!value) {
@@ -287,8 +283,9 @@ const AutoCompleteWithSelectedList = forwardRef<
287
283
  if (
288
284
  dropRef.current &&
289
285
  event.target instanceof Node &&
290
- !dropRef.current.contains(event.target) &&
291
- event.target.nodeName !== 'svg'
286
+ !dropRef.current.contains(event.target)
287
+ // &&
288
+ // event.target.nodeName !== "svg"
292
289
  ) {
293
290
  setTimeout(() => {
294
291
  setDropOpen(false);
@@ -300,7 +297,7 @@ const AutoCompleteWithSelectedList = forwardRef<
300
297
  window.addEventListener('scroll', handleClickOutside as any);
301
298
 
302
299
  const scrollableDivs = document.querySelectorAll(
303
- 'div[style*="overflow"], .overflow-auto '
300
+ 'div[style*="overflow"], .overflow-auto ,overflow-y-auto overflow-x-auto'
304
301
  );
305
302
  scrollableDivs.forEach((div) =>
306
303
  div.addEventListener('scroll', handleClickOutside as any)
@@ -365,7 +362,7 @@ const AutoCompleteWithSelectedList = forwardRef<
365
362
  if (countOnly) {
366
363
  setTimeout(() => {
367
364
  if (inputSearchRef.current) inputSearchRef.current.focus();
368
- }, 100);
365
+ }, 10);
369
366
  } else {
370
367
  if (inputRef.current) inputRef.current.focus();
371
368
  }
@@ -395,13 +392,11 @@ const AutoCompleteWithSelectedList = forwardRef<
395
392
  .join(', ')
396
393
  : '';
397
394
 
398
- const handleDropOpen = async (e: any) => {
399
- e.stopPropagation();
395
+ const handleDropOpen = (e: any) => {
400
396
  if (!dropOpen) setDropOpen(true);
401
397
  };
402
398
 
403
399
  const handleDropClose = (e: any) => {
404
- e.stopPropagation();
405
400
  if (dropOpen) setDropOpen(false);
406
401
  };
407
402
 
@@ -613,14 +608,7 @@ const AutoCompleteWithSelectedList = forwardRef<
613
608
  ReactDOM.createPortal(
614
609
  <div
615
610
  ref={dropRef}
616
- style={{
617
- ...dropdownStyle,
618
- minHeight: viewMode
619
- ? 160
620
- : type === 'auto_suggestion'
621
- ? 164
622
- : 192,
623
- }}
611
+ style={{ ...dropdownStyle, minHeight: viewMode ? 100 : 192 }}
624
612
  className={`qbs-autocomplete-suggestions qbs-autocomplete-selected-suggestions ${
625
613
  viewMode ? 'qbs-dropdown-selected-preview' : ''
626
614
  } ${viewMode && selectedItems?.length === 0 ? 'hidden' : ''}`}
@@ -701,17 +689,12 @@ const AutoCompleteWithSelectedList = forwardRef<
701
689
  )}
702
690
  </div>
703
691
  <>
704
- {/* {countOnly && selectedItems?.length > 0 && ( */}
705
- <>
706
- <div
707
- style={{
708
- minHeight: viewMode ? 160 : 192,
709
- maxHeight: viewMode ? 160 : 192,
710
- }}
711
- className={`qbs-expandable-container qbs-dropdown-selected-container`}
712
- ref={dropdownSelectedRef}
713
- >
714
- {selectedItems?.length > 0 ? (
692
+ {countOnly && selectedItems?.length > 0 && (
693
+ <>
694
+ <div
695
+ className={`qbs-expandable-container qbs-dropdown-selected-container`}
696
+ ref={dropdownSelectedRef}
697
+ >
715
698
  <div className={`qbs-flex qbs-w-full qbs-text-xs`}>
716
699
  <div className="qbs-selected-lbs qbs-flex-grow">
717
700
  Selected Items
@@ -725,30 +708,27 @@ const AutoCompleteWithSelectedList = forwardRef<
725
708
  Clear all
726
709
  </div>
727
710
  </div>
728
- ) : (
729
- <div> No Items Selected</div>
730
- )}
731
711
 
732
- {getSelectedItems(true)}
733
-
734
- <>
735
- {selectedItems?.length > itemCount &&
736
- showAllSelected && (
737
- <div className="qbs-readmore-collapse">
738
- <div
739
- className="qbs-more-collapse"
740
- onClick={() => {
741
- handleCollapseArrowClick();
742
- }}
743
- >
744
- <DropArrow className={`icon-button-rotate`} />
712
+ {getSelectedItems(true)}
713
+
714
+ <>
715
+ {selectedItems?.length > itemCount &&
716
+ showAllSelected && (
717
+ <div className="qbs-readmore-collapse">
718
+ <div
719
+ className="qbs-more-collapse"
720
+ onClick={() => {
721
+ handleCollapseArrowClick();
722
+ }}
723
+ >
724
+ <DropArrow className={`icon-button-rotate`} />
725
+ </div>
745
726
  </div>
746
- </div>
747
- )}
748
- </>
749
- </div>
750
- </>
751
- {/* )} */}
727
+ )}
728
+ </>
729
+ </div>
730
+ </>
731
+ )}
752
732
  </>
753
733
  </div>,
754
734
  document.body
@@ -245,7 +245,7 @@ const AutoCompleteWithTreeStructure = forwardRef<
245
245
  window.addEventListener("scroll", handleClickOutside as any);
246
246
 
247
247
  const scrollableDivs = document.querySelectorAll(
248
- 'div[style*="overflow"], .overflow-auto'
248
+ 'div[style*="overflow"], .overflow-auto ,overflow-y-auto overflow-x-auto'
249
249
  );
250
250
  scrollableDivs.forEach((div) =>
251
251
  div.addEventListener("scroll", handleClickOutside as any)
@@ -262,7 +262,7 @@ const ExpandableAutoComplete = forwardRef<
262
262
  window.addEventListener("scroll", handleClickOutside as any);
263
263
 
264
264
  const scrollableDivs = document.querySelectorAll(
265
- 'div[style*="overflow"], .overflow-auto'
265
+ 'div[style*="overflow"], .overflow-auto ,overflow-y-auto overflow-x-auto'
266
266
  );
267
267
  scrollableDivs.forEach((div) =>
268
268
  div.addEventListener("scroll", handleClickOutside as any)