react-core-ts 1.2.31 → 1.3.0

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,19 +81,19 @@ 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
88
87
  >(1);
88
+ const [visible, setVisible] = useState<boolean>(false);
89
89
  const [activeTab, setActiveTab] = useState<number>(currentTab);
90
90
  // API call for suggestions through a custom hook
91
91
  const inputRef = useRef(null);
92
92
  const dropRef = useRef(null);
93
93
  const inputSearchRef = useRef(null);
94
94
  useImperativeHandle(ref, () => inputRef.current);
95
- const [dropdownStyle, setDropdownStyle] = useState<any>({
96
- top: undefined,
95
+ const [dropdownStyle, setDropdownStyle] = useState({
96
+ top: 0,
97
97
  left: 0,
98
98
  width: 200,
99
99
  });
@@ -108,32 +108,28 @@ const AutoCompleteWithSelectedList = forwardRef<
108
108
  };
109
109
  // Check if there's enough space below the input for the dropdown
110
110
  const spaceBelow = window.innerHeight - inputRect.bottom;
111
- let dropdownHeight = viewMode ? 160 : 380; // Assume a fixed height or calculate based on content
111
+ const spaceAbove = inputRect.top + window.scrollY;
112
112
 
113
- if (countOnly && !viewMode) {
114
- // if (dropdownSelectedRef?.current) {
115
- // dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
116
- // }
117
- dropdownHeight += type === 'auto_suggestion' ? 220 : 192;
113
+ let dropdownHeight = viewMode ? 160 : 300; // Assume a fixed height or calculate based on content
114
+ if (countOnly) {
115
+ if (dropdownSelectedRef?.current)
116
+ dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
118
117
  }
119
118
 
120
119
  if (tab.length > 0) {
121
120
  if (tabRef?.current) dropdownHeight += tabRef?.current?.clientHeight;
122
121
  }
123
- console.log(dropdownHeight);
124
122
  if (spaceBelow >= dropdownHeight) {
125
123
  dropdownPosition.top =
126
124
  inputRect.top + window.scrollY + inputRect.height;
127
125
  } else {
128
- dropdownPosition.top = viewMode
129
- ? inputRect.top + window.scrollY - dropdownHeight + 18 + topMargin
130
- : inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
126
+ dropdownPosition.top =
127
+ inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
131
128
  }
132
- setTimeout(() => {
133
- setDropdownStyle({
134
- ...dropdownPosition,
135
- });
136
- }, 100);
129
+
130
+ setDropdownStyle({
131
+ ...dropdownPosition,
132
+ });
137
133
  }
138
134
  };
139
135
 
@@ -144,7 +140,7 @@ const AutoCompleteWithSelectedList = forwardRef<
144
140
  return () => {
145
141
  window.removeEventListener('resize', adjustDropdownPosition);
146
142
  };
147
- }, [selectedItems, expandArrowClick, dropOpen]);
143
+ }, [dropOpen, selectedItems, expandArrowClick]);
148
144
 
149
145
  const { suggestions, isLoading, handlePickSuggestions } = useSuggestions(
150
146
  getData,
@@ -231,7 +227,7 @@ const AutoCompleteWithSelectedList = forwardRef<
231
227
 
232
228
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
233
229
  const { value } = e.target;
234
- // setDropOpen(true);
230
+ setDropOpen(true);
235
231
  setSearchValue(value);
236
232
  handleChangeWithDebounce(value);
237
233
  if (!value) {
@@ -288,8 +284,9 @@ const AutoCompleteWithSelectedList = forwardRef<
288
284
  if (
289
285
  dropRef.current &&
290
286
  event.target instanceof Node &&
291
- !dropRef.current.contains(event.target) &&
292
- event.target.nodeName !== 'svg'
287
+ !dropRef.current.contains(event.target)
288
+ // &&
289
+ // event.target.nodeName !== "svg"
293
290
  ) {
294
291
  setTimeout(() => {
295
292
  setDropOpen(false);
@@ -301,7 +298,7 @@ const AutoCompleteWithSelectedList = forwardRef<
301
298
  window.addEventListener('scroll', handleClickOutside as any);
302
299
 
303
300
  const scrollableDivs = document.querySelectorAll(
304
- 'div[style*="overflow"], .overflow-auto '
301
+ 'div[style*="overflow"], .overflow-auto ,overflow-y-auto overflow-x-auto'
305
302
  );
306
303
  scrollableDivs.forEach((div) =>
307
304
  div.addEventListener('scroll', handleClickOutside as any)
@@ -366,7 +363,7 @@ const AutoCompleteWithSelectedList = forwardRef<
366
363
  if (countOnly) {
367
364
  setTimeout(() => {
368
365
  if (inputSearchRef.current) inputSearchRef.current.focus();
369
- }, 100);
366
+ }, 10);
370
367
  } else {
371
368
  if (inputRef.current) inputRef.current.focus();
372
369
  }
@@ -396,13 +393,15 @@ const AutoCompleteWithSelectedList = forwardRef<
396
393
  .join(', ')
397
394
  : '';
398
395
 
399
- const handleDropOpen = async (e: any) => {
400
- e.stopPropagation();
396
+ const handleDropOpen = (e: any) => {
397
+ setVisible(false);
401
398
  if (!dropOpen) setDropOpen(true);
399
+ setTimeout(() => {
400
+ setVisible(true);
401
+ }, 100);
402
402
  };
403
403
 
404
404
  const handleDropClose = (e: any) => {
405
- e.stopPropagation();
406
405
  if (dropOpen) setDropOpen(false);
407
406
  };
408
407
 
@@ -616,11 +615,8 @@ const AutoCompleteWithSelectedList = forwardRef<
616
615
  ref={dropRef}
617
616
  style={{
618
617
  ...dropdownStyle,
619
- minHeight: viewMode
620
- ? 160
621
- : type === 'auto_suggestion'
622
- ? 164
623
- : 192,
618
+ minHeight: viewMode ? 100 : 192,
619
+ visibility: visible ? 'visible' : 'hidden',
624
620
  }}
625
621
  className={`qbs-autocomplete-suggestions qbs-autocomplete-selected-suggestions ${
626
622
  viewMode ? 'qbs-dropdown-selected-preview' : ''
@@ -702,20 +698,13 @@ const AutoCompleteWithSelectedList = forwardRef<
702
698
  )}
703
699
  </div>
704
700
  <>
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
- >
701
+ {countOnly && selectedItems?.length > 0 && (
702
+ <>
703
+ <div
704
+ className={`qbs-expandable-container qbs-dropdown-selected-container`}
705
+ ref={dropdownSelectedRef}
706
+ >
707
+ <div className={`qbs-flex qbs-w-full qbs-text-xs`}>
719
708
  <div className="qbs-selected-lbs qbs-flex-grow">
720
709
  Selected Items
721
710
  </div>
@@ -728,33 +717,27 @@ const AutoCompleteWithSelectedList = forwardRef<
728
717
  Clear all
729
718
  </div>
730
719
  </div>
731
- ) : (
732
- <div className="w-full flex items-center justify-center">
733
- {' '}
734
- No Items Selected
735
- </div>
736
- )}
737
720
 
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`} />
721
+ {getSelectedItems(true)}
722
+
723
+ <>
724
+ {selectedItems?.length > itemCount &&
725
+ showAllSelected && (
726
+ <div className="qbs-readmore-collapse">
727
+ <div
728
+ className="qbs-more-collapse"
729
+ onClick={() => {
730
+ handleCollapseArrowClick();
731
+ }}
732
+ >
733
+ <DropArrow className={`icon-button-rotate`} />
734
+ </div>
751
735
  </div>
752
- </div>
753
- )}
754
- </>
755
- </div>
756
- </>
757
- {/* )} */}
736
+ )}
737
+ </>
738
+ </div>
739
+ </>
740
+ )}
758
741
  </>
759
742
  </div>,
760
743
  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)