react-core-ts 1.2.22 → 1.2.24
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 -109
- package/dist/AutoCompleteWithSelectedList.js.map +1 -1
- package/dist/styles/styles/components/autocomplete.css +617 -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 +39 -122
|
@@ -92,134 +92,50 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
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<any>({
|
|
96
|
+
top: undefined,
|
|
97
97
|
left: 0,
|
|
98
98
|
width: 200,
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
const adjustDropdownPosition = () => {
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (dropdownSelectedRef?.current)
|
|
118
|
-
dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (tab.length > 0) {
|
|
122
|
-
if (tabRef?.current)
|
|
123
|
-
dropdownHeight += tabRef?.current?.clientHeight;
|
|
124
|
-
}
|
|
125
|
-
if (spaceBelow >= dropdownHeight) {
|
|
126
|
-
dropdownPosition.top =
|
|
127
|
-
inputRect.top + window.scrollY + inputRect.height;
|
|
102
|
+
if (dropdownRef.current) {
|
|
103
|
+
const inputRect = dropdownRef.current.getBoundingClientRect();
|
|
104
|
+
const dropdownPosition = {
|
|
105
|
+
left: inputRect.left + window.scrollX,
|
|
106
|
+
width: inputRect.width,
|
|
107
|
+
top: 0,
|
|
108
|
+
};
|
|
109
|
+
// Check if there's enough space below the input for the dropdown
|
|
110
|
+
const spaceBelow = window.innerHeight - inputRect.bottom;
|
|
111
|
+
const spaceAbove = inputRect.top + window.scrollY;
|
|
112
|
+
let dropdownHeight = viewMode ? 160 : 300; // Assume a fixed height or calculate based on content
|
|
113
|
+
|
|
114
|
+
if (countOnly && !viewMode) {
|
|
115
|
+
if (dropdownSelectedRef?.current) {
|
|
116
|
+
dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
|
|
128
117
|
} else {
|
|
129
|
-
|
|
130
|
-
? inputRect.top + window.scrollY - dropdownHeight + 18 + topMargin
|
|
131
|
-
: inputRect.top +
|
|
132
|
-
window.scrollY -
|
|
133
|
-
dropdownHeight +
|
|
134
|
-
73 +
|
|
135
|
-
topMargin;
|
|
118
|
+
dropdownHeight += 89;
|
|
136
119
|
}
|
|
137
|
-
setDropdownStyle({
|
|
138
|
-
...dropdownPosition,
|
|
139
|
-
});
|
|
140
120
|
}
|
|
141
|
-
} else {
|
|
142
|
-
if (dropdownRef.current) {
|
|
143
|
-
const inputRect = dropdownRef.current.getBoundingClientRect();
|
|
144
|
-
const dropdownPosition = {
|
|
145
|
-
left: inputRect.left + window.scrollX,
|
|
146
|
-
width: inputRect.width,
|
|
147
|
-
top: 0,
|
|
148
|
-
};
|
|
149
|
-
// Check if there's enough space below the input for the dropdown
|
|
150
|
-
const spaceBelow = window.innerHeight - inputRect.bottom;
|
|
151
|
-
const spaceAbove = inputRect.top + window.scrollY;
|
|
152
|
-
|
|
153
|
-
let dropdownHeight = viewMode ? 160 : 300; // Assume a fixed height or calculate based on content
|
|
154
|
-
|
|
155
|
-
if (countOnly && !viewMode) {
|
|
156
|
-
if (dropdownSelectedRef?.current)
|
|
157
|
-
dropdownHeight += dropdownSelectedRef?.current?.clientHeight;
|
|
158
|
-
}
|
|
159
121
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
dropdownHeight += tabRef?.current?.clientHeight;
|
|
163
|
-
}
|
|
164
|
-
console.log(dropdownHeight);
|
|
165
|
-
if (spaceBelow >= dropdownHeight) {
|
|
166
|
-
dropdownPosition.top =
|
|
167
|
-
inputRect.top + window.scrollY + inputRect.height;
|
|
168
|
-
} else {
|
|
169
|
-
dropdownPosition.top = viewMode
|
|
170
|
-
? inputRect.top + window.scrollY - dropdownHeight + 18 + topMargin
|
|
171
|
-
: inputRect.top +
|
|
172
|
-
window.scrollY -
|
|
173
|
-
dropdownHeight +
|
|
174
|
-
73 +
|
|
175
|
-
topMargin;
|
|
176
|
-
}
|
|
177
|
-
console.log(dropdownPosition);
|
|
178
|
-
setDropdownStyle({
|
|
179
|
-
...dropdownPosition,
|
|
180
|
-
});
|
|
122
|
+
if (tab.length > 0) {
|
|
123
|
+
if (tabRef?.current) dropdownHeight += tabRef?.current?.clientHeight;
|
|
181
124
|
}
|
|
125
|
+
console.log(dropdownHeight);
|
|
126
|
+
if (spaceBelow >= dropdownHeight) {
|
|
127
|
+
dropdownPosition.top =
|
|
128
|
+
inputRect.top + window.scrollY + inputRect.height;
|
|
129
|
+
} else {
|
|
130
|
+
dropdownPosition.top = viewMode
|
|
131
|
+
? inputRect.top + window.scrollY - dropdownHeight + 18 + topMargin
|
|
132
|
+
: inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
|
|
133
|
+
}
|
|
134
|
+
setDropdownStyle({
|
|
135
|
+
...dropdownPosition,
|
|
136
|
+
});
|
|
182
137
|
}
|
|
183
138
|
};
|
|
184
|
-
// const adjustDropdownPosition = () => {
|
|
185
|
-
// if (!dropdownRef.current) return;
|
|
186
|
-
|
|
187
|
-
// const inputRect = dropdownRef.current.getBoundingClientRect();
|
|
188
|
-
// const dropdownPosition = {
|
|
189
|
-
// left: inputRect.left + window.scrollX,
|
|
190
|
-
// width: inputRect.width,
|
|
191
|
-
// top: 0,
|
|
192
|
-
// };
|
|
193
|
-
|
|
194
|
-
// const spaceBelow = window.innerHeight - inputRect.bottom;
|
|
195
|
-
// let dropdownHeight = viewMode ? 160 : 300; // Default dropdown height
|
|
196
|
-
|
|
197
|
-
// // Helper to calculate additional height from other elements
|
|
198
|
-
// const calculateAdditionalHeight = () => {
|
|
199
|
-
// let extraHeight = 0;
|
|
200
|
-
// if (countOnly && !viewMode && dropdownSelectedRef?.current) {
|
|
201
|
-
// extraHeight += dropdownSelectedRef.current.clientHeight;
|
|
202
|
-
// }
|
|
203
|
-
// if (tab.length > 0 && tabRef?.current) {
|
|
204
|
-
// extraHeight += tabRef.current.clientHeight;
|
|
205
|
-
// }
|
|
206
|
-
// return extraHeight;
|
|
207
|
-
// };
|
|
208
|
-
|
|
209
|
-
// dropdownHeight += calculateAdditionalHeight();
|
|
210
|
-
|
|
211
|
-
// // Determine top position based on available space
|
|
212
|
-
// if (spaceBelow >= dropdownHeight) {
|
|
213
|
-
// dropdownPosition.top =
|
|
214
|
-
// inputRect.top + window.scrollY + inputRect.height;
|
|
215
|
-
// } else {
|
|
216
|
-
// const adjustment = viewMode ? 18 + topMargin : 73 + topMargin;
|
|
217
|
-
// dropdownPosition.top =
|
|
218
|
-
// inputRect.top + window.scrollY - dropdownHeight + adjustment;
|
|
219
|
-
// }
|
|
220
|
-
|
|
221
|
-
// setDropdownStyle(dropdownPosition);
|
|
222
|
-
// };
|
|
223
139
|
|
|
224
140
|
useEffect(() => {
|
|
225
141
|
window.addEventListener('resize', adjustDropdownPosition);
|
|
@@ -372,9 +288,8 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
372
288
|
if (
|
|
373
289
|
dropRef.current &&
|
|
374
290
|
event.target instanceof Node &&
|
|
375
|
-
!dropRef.current.contains(event.target)
|
|
376
|
-
|
|
377
|
-
// event.target.nodeName !== "svg"
|
|
291
|
+
!dropRef.current.contains(event.target) &&
|
|
292
|
+
event.target.nodeName !== 'svg'
|
|
378
293
|
) {
|
|
379
294
|
setTimeout(() => {
|
|
380
295
|
setDropOpen(false);
|
|
@@ -386,7 +301,7 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
386
301
|
window.addEventListener('scroll', handleClickOutside as any);
|
|
387
302
|
|
|
388
303
|
const scrollableDivs = document.querySelectorAll(
|
|
389
|
-
'div[style*="overflow"], .overflow-auto'
|
|
304
|
+
'div[style*="overflow"], .overflow-auto '
|
|
390
305
|
);
|
|
391
306
|
scrollableDivs.forEach((div) =>
|
|
392
307
|
div.addEventListener('scroll', handleClickOutside as any)
|
|
@@ -487,6 +402,7 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
487
402
|
if (viewMode) {
|
|
488
403
|
adjustDropdownPosition();
|
|
489
404
|
}
|
|
405
|
+
console.log('handleDropOpen');
|
|
490
406
|
setTimeout(() => {
|
|
491
407
|
if (!dropOpen) setDropOpen(true);
|
|
492
408
|
}, 100);
|
|
@@ -494,6 +410,7 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
494
410
|
|
|
495
411
|
const handleDropClose = (e: any) => {
|
|
496
412
|
e.stopPropagation();
|
|
413
|
+
console.log('handleDropClose');
|
|
497
414
|
if (dropOpen) setDropOpen(false);
|
|
498
415
|
};
|
|
499
416
|
|
|
@@ -572,11 +489,11 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
572
489
|
);
|
|
573
490
|
};
|
|
574
491
|
useEffect(() => {
|
|
575
|
-
if (dropOpen && !viewMode
|
|
492
|
+
if (dropOpen && !viewMode) {
|
|
576
493
|
adjustDropdownPosition();
|
|
577
494
|
}
|
|
578
495
|
}, [dropOpen]);
|
|
579
|
-
|
|
496
|
+
console.log(dropdownStyle, 'dropdownStyle');
|
|
580
497
|
const getTabItems = () => {
|
|
581
498
|
return (
|
|
582
499
|
<ul
|