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.
- package/dist/AutoCompleteWithSelectedList.js +28 -43
- package/dist/AutoCompleteWithSelectedList.js.map +1 -1
- package/dist/AutoCompleteWithTreeStructure.js +1 -1
- package/dist/AutoCompleteWithTreeStructure.js.map +1 -1
- package/dist/ExpandableAutoComplete.js +1 -1
- package/dist/ExpandableAutoComplete.js.map +1 -1
- package/dist/dummyAutoCompleteWithSelectedList.d.ts +4 -0
- package/dist/dummyAutoCompleteWithSelectedList.js +456 -0
- package/dist/dummyAutoCompleteWithSelectedList.js.map +1 -0
- package/dist/index.d.ts +15 -15
- package/dist/styles/components/autocomplete.css +1 -1
- package/package.json +1 -1
- package/src/AutoCompleteWithSelectedList.tsx +48 -74
- package/src/AutoCompleteWithTreeStructure.tsx +1 -1
- package/src/ExpandableAutoComplete.tsx +1 -1
- package/src/dummyAutoCompleteWithSelectedList.tsx +778 -0
- package/src/index.tsx +15 -15
- package/src/styles/components/autocomplete.css +1 -1
|
@@ -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
|
|
96
|
-
top:
|
|
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
|
-
|
|
110
|
+
const spaceAbove = inputRect.top + window.scrollY;
|
|
112
111
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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 =
|
|
129
|
-
|
|
130
|
-
: inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
|
|
125
|
+
dropdownPosition.top =
|
|
126
|
+
inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
|
|
131
127
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
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 =
|
|
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
|
-
{
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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)
|