react-core-ts 1.2.31 → 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
  });
@@ -108,32 +107,28 @@ const AutoCompleteWithSelectedList = forwardRef<
108
107
  };
109
108
  // Check if there's enough space below the input for the dropdown
110
109
  const spaceBelow = window.innerHeight - inputRect.bottom;
111
- let dropdownHeight = viewMode ? 160 : 380; // Assume a fixed height or calculate based on content
110
+ const spaceAbove = inputRect.top + window.scrollY;
112
111
 
113
- if (countOnly && !viewMode) {
114
- // if (dropdownSelectedRef?.current) {
115
- // dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
116
- // }
117
- 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;
118
116
  }
119
117
 
120
118
  if (tab.length > 0) {
121
119
  if (tabRef?.current) dropdownHeight += tabRef?.current?.clientHeight;
122
120
  }
123
- console.log(dropdownHeight);
124
121
  if (spaceBelow >= dropdownHeight) {
125
122
  dropdownPosition.top =
126
123
  inputRect.top + window.scrollY + inputRect.height;
127
124
  } else {
128
- dropdownPosition.top = viewMode
129
- ? inputRect.top + window.scrollY - dropdownHeight + 18 + topMargin
130
- : inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
125
+ dropdownPosition.top =
126
+ inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
131
127
  }
132
- setTimeout(() => {
133
- setDropdownStyle({
134
- ...dropdownPosition,
135
- });
136
- }, 100);
128
+
129
+ setDropdownStyle({
130
+ ...dropdownPosition,
131
+ });
137
132
  }
138
133
  };
139
134
 
@@ -144,7 +139,7 @@ const AutoCompleteWithSelectedList = forwardRef<
144
139
  return () => {
145
140
  window.removeEventListener('resize', adjustDropdownPosition);
146
141
  };
147
- }, [selectedItems, expandArrowClick, dropOpen]);
142
+ }, [dropOpen, selectedItems, expandArrowClick]);
148
143
 
149
144
  const { suggestions, isLoading, handlePickSuggestions } = useSuggestions(
150
145
  getData,
@@ -231,7 +226,7 @@ const AutoCompleteWithSelectedList = forwardRef<
231
226
 
232
227
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
233
228
  const { value } = e.target;
234
- // setDropOpen(true);
229
+ setDropOpen(true);
235
230
  setSearchValue(value);
236
231
  handleChangeWithDebounce(value);
237
232
  if (!value) {
@@ -288,8 +283,9 @@ const AutoCompleteWithSelectedList = forwardRef<
288
283
  if (
289
284
  dropRef.current &&
290
285
  event.target instanceof Node &&
291
- !dropRef.current.contains(event.target) &&
292
- event.target.nodeName !== 'svg'
286
+ !dropRef.current.contains(event.target)
287
+ // &&
288
+ // event.target.nodeName !== "svg"
293
289
  ) {
294
290
  setTimeout(() => {
295
291
  setDropOpen(false);
@@ -301,7 +297,7 @@ const AutoCompleteWithSelectedList = forwardRef<
301
297
  window.addEventListener('scroll', handleClickOutside as any);
302
298
 
303
299
  const scrollableDivs = document.querySelectorAll(
304
- 'div[style*="overflow"], .overflow-auto '
300
+ 'div[style*="overflow"], .overflow-auto ,overflow-y-auto overflow-x-auto'
305
301
  );
306
302
  scrollableDivs.forEach((div) =>
307
303
  div.addEventListener('scroll', handleClickOutside as any)
@@ -366,7 +362,7 @@ const AutoCompleteWithSelectedList = forwardRef<
366
362
  if (countOnly) {
367
363
  setTimeout(() => {
368
364
  if (inputSearchRef.current) inputSearchRef.current.focus();
369
- }, 100);
365
+ }, 10);
370
366
  } else {
371
367
  if (inputRef.current) inputRef.current.focus();
372
368
  }
@@ -396,13 +392,11 @@ const AutoCompleteWithSelectedList = forwardRef<
396
392
  .join(', ')
397
393
  : '';
398
394
 
399
- const handleDropOpen = async (e: any) => {
400
- e.stopPropagation();
395
+ const handleDropOpen = (e: any) => {
401
396
  if (!dropOpen) setDropOpen(true);
402
397
  };
403
398
 
404
399
  const handleDropClose = (e: any) => {
405
- e.stopPropagation();
406
400
  if (dropOpen) setDropOpen(false);
407
401
  };
408
402
 
@@ -614,14 +608,7 @@ const AutoCompleteWithSelectedList = forwardRef<
614
608
  ReactDOM.createPortal(
615
609
  <div
616
610
  ref={dropRef}
617
- style={{
618
- ...dropdownStyle,
619
- minHeight: viewMode
620
- ? 160
621
- : type === 'auto_suggestion'
622
- ? 164
623
- : 192,
624
- }}
611
+ style={{ ...dropdownStyle, minHeight: viewMode ? 100 : 192 }}
625
612
  className={`qbs-autocomplete-suggestions qbs-autocomplete-selected-suggestions ${
626
613
  viewMode ? 'qbs-dropdown-selected-preview' : ''
627
614
  } ${viewMode && selectedItems?.length === 0 ? 'hidden' : ''}`}
@@ -702,20 +689,13 @@ const AutoCompleteWithSelectedList = forwardRef<
702
689
  )}
703
690
  </div>
704
691
  <>
705
- {/* {countOnly && selectedItems?.length > 0 && ( */}
706
- <>
707
- <div
708
- style={{
709
- minHeight: viewMode ? 160 : 192,
710
- maxHeight: viewMode ? 160 : 192,
711
- }}
712
- className={`qbs-expandable-container qbs-dropdown-selected-container`}
713
- ref={dropdownSelectedRef}
714
- >
715
- {selectedItems?.length > 0 ? (
716
- <div
717
- className={`qbs-flex qbs-w-full qbs-text-xs items-center`}
718
- >
692
+ {countOnly && selectedItems?.length > 0 && (
693
+ <>
694
+ <div
695
+ className={`qbs-expandable-container qbs-dropdown-selected-container`}
696
+ ref={dropdownSelectedRef}
697
+ >
698
+ <div className={`qbs-flex qbs-w-full qbs-text-xs`}>
719
699
  <div className="qbs-selected-lbs qbs-flex-grow">
720
700
  Selected Items
721
701
  </div>
@@ -728,33 +708,27 @@ const AutoCompleteWithSelectedList = forwardRef<
728
708
  Clear all
729
709
  </div>
730
710
  </div>
731
- ) : (
732
- <div className="w-full flex items-center justify-center">
733
- {' '}
734
- No Items Selected
735
- </div>
736
- )}
737
711
 
738
- {getSelectedItems(true)}
739
-
740
- <>
741
- {selectedItems?.length > itemCount &&
742
- showAllSelected && (
743
- <div className="qbs-readmore-collapse">
744
- <div
745
- className="qbs-more-collapse"
746
- onClick={() => {
747
- handleCollapseArrowClick();
748
- }}
749
- >
750
- <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>
751
726
  </div>
752
- </div>
753
- )}
754
- </>
755
- </div>
756
- </>
757
- {/* )} */}
727
+ )}
728
+ </>
729
+ </div>
730
+ </>
731
+ )}
758
732
  </>
759
733
  </div>,
760
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)