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.
- package/dist/AutoCompleteWithSelectedList.js +38 -48
- 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/dist/styles/styles/components/autocomplete.css +616 -0
- package/dist/styles/styles/components/selectedautocomplete.css +128 -0
- package/dist/styles/styles/components/tooltip.css +496 -0
- package/dist/styles/styles/components/treedropdown.css +63 -0
- package/dist/styles/styles/global.css +8 -0
- package/package.json +1 -1
- package/src/AutoCompleteWithSelectedList.tsx +54 -71
- 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,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
|
|
96
|
-
top:
|
|
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
|
-
|
|
111
|
+
const spaceAbove = inputRect.top + window.scrollY;
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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 =
|
|
129
|
-
|
|
130
|
-
: inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
|
|
126
|
+
dropdownPosition.top =
|
|
127
|
+
inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
|
|
131
128
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
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 =
|
|
400
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
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
|
-
>
|
|
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
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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)
|