react-core-ts 2.1.10 → 2.1.12
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/ExpandableAutoComplete.js +58 -47
- package/dist/ExpandableAutoComplete.js.map +1 -1
- package/dist/styles/styles/components/autocomplete.css +749 -0
- package/dist/styles/styles/components/selectedautocomplete.css +221 -0
- package/dist/styles/styles/components/tooltip.css +497 -0
- package/dist/styles/styles/components/treedropdown.css +97 -0
- package/dist/styles/styles/global.css +8 -0
- package/package.json +1 -1
- package/src/ExpandableAutoComplete.tsx +69 -53
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
.qbs-tree-list-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
}
|
|
5
|
+
.qbs-tree-list-container-sub {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
gap: 7px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.qbs-tree-list-container-sub .no-children {
|
|
13
|
+
margin-left: 1.75rem; /* Corresponds to ml-7 in Tailwind */
|
|
14
|
+
}
|
|
15
|
+
.qbs-tree-list-container-sub-icon {
|
|
16
|
+
margin-top: 0.25rem; /* Corresponds to mt-1 in Tailwind */
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
padding-top: 0.5rem; /* Corresponds to py-2 in Tailwind */
|
|
19
|
+
padding-bottom: 0.5rem;
|
|
20
|
+
transition: transform 0.3s ease; /* Smooth rotation transition */
|
|
21
|
+
color: #003c71;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.qbs-tree-list-container-sub-icon.expanded {
|
|
25
|
+
transform: rotate(90deg); /* Corresponds to rotate-90 in Tailwind */
|
|
26
|
+
}
|
|
27
|
+
.qbs-tree-list-container-sub-container {
|
|
28
|
+
display: flex;
|
|
29
|
+
gap: 15px; /* Corresponds to gap-2 in Tailwind */
|
|
30
|
+
padding: 0.5rem; /* Corresponds to p-2 in Tailwind */
|
|
31
|
+
flex-direction: row; /* Corresponds to flex-row in Tailwind */
|
|
32
|
+
width: 100%; /* Corresponds to w-full in Tailwind */
|
|
33
|
+
color: #3d414a;
|
|
34
|
+
}
|
|
35
|
+
.qbs-tree-list-container-sub-container-hideicon {
|
|
36
|
+
display: flex;
|
|
37
|
+
gap: 6px; /* Corresponds to gap-2 in Tailwind */
|
|
38
|
+
padding: 0.5rem; /* Corresponds to p-2 in Tailwind */
|
|
39
|
+
flex-direction: row; /* Corresponds to flex-row in Tailwind */
|
|
40
|
+
width: 100%; /* Corresponds to w-full in Tailwind */
|
|
41
|
+
color: #3d414a;
|
|
42
|
+
}
|
|
43
|
+
.qbs-tree-list-container-sub-container-hideicon:hover {
|
|
44
|
+
color: #003c71;
|
|
45
|
+
background-color: rgba(141, 194, 240, 0.15) !important;
|
|
46
|
+
}
|
|
47
|
+
.qbs-tree-list-container-sub-container:hover {
|
|
48
|
+
color: #003c71;
|
|
49
|
+
background-color: rgba(141, 194, 240, 0.15) !important;
|
|
50
|
+
}
|
|
51
|
+
.qbs-tree-list-container-sub-container.qbs-expanded-child {
|
|
52
|
+
color: #003c71;
|
|
53
|
+
}
|
|
54
|
+
.qbs-tree-list-container-sub-text.qbs-expanded-child {
|
|
55
|
+
color: #003c71;
|
|
56
|
+
}
|
|
57
|
+
.qbs-tree-list-container-sub-text:hover {
|
|
58
|
+
color: #003c71;
|
|
59
|
+
/* background-color: rgba(141, 194, 240, 0.15) !important; */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.qbs-tree-list-container-sub-container.checked,
|
|
63
|
+
.qbs-tree-list-container-sub-container-hideicon.checked {
|
|
64
|
+
color: #003c71;
|
|
65
|
+
background-color: rgba(
|
|
66
|
+
141,
|
|
67
|
+
194,
|
|
68
|
+
240,
|
|
69
|
+
0.15
|
|
70
|
+
) !important; /* Corresponds to bg-green-200 in Tailwind */
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.marginLeft {
|
|
74
|
+
margin-left: 28px; /* Corresponds to ml-2 in Tailwind */
|
|
75
|
+
}
|
|
76
|
+
.lightmarginLeft {
|
|
77
|
+
margin-left: 19px; /* Corresponds to ml-2 in Tailwind */
|
|
78
|
+
}
|
|
79
|
+
.qbs-tree-list-container-sub- {
|
|
80
|
+
line-height: 18px; /* Corresponds to leading-[18px] in Tailwind */
|
|
81
|
+
font-size: 0.875rem; /* Corresponds to text-sm in Tailwind (14px) */
|
|
82
|
+
}
|
|
83
|
+
.qbs-tree-list-container-child {
|
|
84
|
+
margin-left: 1rem; /* Corresponds to ml-4 in Tailwind */
|
|
85
|
+
margin-top: 0.5rem; /* Corresponds to mt-2 in Tailwind */
|
|
86
|
+
display: flex; /* Corresponds to flex in Tailwind */
|
|
87
|
+
flex-direction: column; /* Corresponds to flex-col in Tailwind */
|
|
88
|
+
gap: 0.5rem; /* Corresponds to gap-2 in Tailwind */
|
|
89
|
+
}
|
|
90
|
+
.qbs-tree-list-container-sub-text {
|
|
91
|
+
line-height: 18px; /* Corresponds to leading-[18px] in Tailwind */
|
|
92
|
+
font-size: 14px; /* Corresponds to text-sm in Tailwind (14px) */
|
|
93
|
+
font-weight: 500;
|
|
94
|
+
letter-spacing: 0.28px;
|
|
95
|
+
font-family: 'Noto Sans';
|
|
96
|
+
/* color: #3d414a; */
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -97,50 +97,12 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
97
97
|
const dropRef = useRef(null);
|
|
98
98
|
const typeRef = useRef(0);
|
|
99
99
|
useImperativeHandle(ref, () => inputRef.current);
|
|
100
|
-
const [dropdownStyle, setDropdownStyle] = useState
|
|
101
|
-
top:
|
|
102
|
-
left:
|
|
103
|
-
width:
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const adjustDropdownPosition = () => {
|
|
107
|
-
if (dropdownRef.current) {
|
|
108
|
-
const inputRect = dropdownRef.current.getBoundingClientRect();
|
|
109
|
-
const dropdownPosition = {
|
|
110
|
-
left: inputRect.left + window.scrollX,
|
|
111
|
-
width: inputRect.width,
|
|
112
|
-
top: 0,
|
|
113
|
-
};
|
|
114
|
-
// Check if there's enough space below the input for the dropdown
|
|
115
|
-
const spaceBelow = window.innerHeight - inputRect.bottom;
|
|
116
|
-
const spaceAbove = inputRect.top + window.scrollY;
|
|
117
|
-
|
|
118
|
-
let dropdownHeight = 275; // Assume a fixed height or calculate based on content
|
|
119
|
-
if (spaceBelow >= dropdownHeight) {
|
|
120
|
-
dropdownPosition.top =
|
|
121
|
-
inputRect.top + window.scrollY + inputRect.height;
|
|
122
|
-
} else {
|
|
123
|
-
dropdownHeight =
|
|
124
|
-
dropdownHeight +
|
|
125
|
-
(filteredData?.length > 0 && enableSelectAll && isMultiple
|
|
126
|
-
? 32
|
|
127
|
-
: 0);
|
|
128
|
-
dropdownPosition.top =
|
|
129
|
-
inputRect.top + window.scrollY - dropdownHeight + 73;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
setDropdownStyle((prev) => {
|
|
133
|
-
if (
|
|
134
|
-
prev.top === dropdownPosition.top &&
|
|
135
|
-
prev.left === dropdownPosition.left &&
|
|
136
|
-
prev.width === dropdownPosition.width
|
|
137
|
-
) {
|
|
138
|
-
return prev;
|
|
139
|
-
}
|
|
140
|
-
return dropdownPosition;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
};
|
|
100
|
+
const [dropdownStyle, setDropdownStyle] = useState<{
|
|
101
|
+
top: number;
|
|
102
|
+
left: number;
|
|
103
|
+
width: number;
|
|
104
|
+
} | null>(null);
|
|
105
|
+
const isPositionCalculatedRef = useRef(false);
|
|
144
106
|
|
|
145
107
|
const { suggestions, isLoading, handlePickSuggestions } = useSuggestions(
|
|
146
108
|
getData,
|
|
@@ -359,24 +321,78 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
359
321
|
matchFromStart,
|
|
360
322
|
]);
|
|
361
323
|
|
|
362
|
-
|
|
324
|
+
const adjustDropdownPosition = useCallback(() => {
|
|
325
|
+
if (dropdownRef.current) {
|
|
326
|
+
const inputRect = dropdownRef.current.getBoundingClientRect();
|
|
327
|
+
const dropdownPosition = {
|
|
328
|
+
left: inputRect.left + window.scrollX,
|
|
329
|
+
width: inputRect.width,
|
|
330
|
+
top: 0,
|
|
331
|
+
};
|
|
332
|
+
// Check if there's enough space below the input for the dropdown
|
|
333
|
+
const spaceBelow = window.innerHeight - inputRect.bottom;
|
|
334
|
+
const spaceAbove = inputRect.top + window.scrollY;
|
|
335
|
+
|
|
336
|
+
let dropdownHeight = 275; // Assume a fixed height or calculate based on content
|
|
337
|
+
if (spaceBelow >= dropdownHeight) {
|
|
338
|
+
dropdownPosition.top =
|
|
339
|
+
inputRect.top + window.scrollY + inputRect.height;
|
|
340
|
+
} else {
|
|
341
|
+
dropdownHeight =
|
|
342
|
+
dropdownHeight +
|
|
343
|
+
(filteredData?.length > 0 && enableSelectAll && isMultiple
|
|
344
|
+
? 32
|
|
345
|
+
: 0);
|
|
346
|
+
dropdownPosition.top =
|
|
347
|
+
inputRect.top + window.scrollY - dropdownHeight + 73;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
setDropdownStyle((prev) => {
|
|
351
|
+
if (
|
|
352
|
+
prev &&
|
|
353
|
+
prev.top === dropdownPosition.top &&
|
|
354
|
+
prev.left === dropdownPosition.left &&
|
|
355
|
+
prev.width === dropdownPosition.width
|
|
356
|
+
) {
|
|
357
|
+
return prev;
|
|
358
|
+
}
|
|
359
|
+
isPositionCalculatedRef.current = true;
|
|
360
|
+
return dropdownPosition;
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}, [filteredData?.length, enableSelectAll, isMultiple]);
|
|
364
|
+
|
|
365
|
+
// Use useLayoutEffect to calculate position synchronously before paint to prevent flicker
|
|
366
|
+
useLayoutEffect(() => {
|
|
363
367
|
if (!dropOpen) {
|
|
368
|
+
isPositionCalculatedRef.current = false;
|
|
369
|
+
setDropdownStyle(null);
|
|
364
370
|
return;
|
|
365
371
|
}
|
|
366
|
-
|
|
372
|
+
// Calculate position immediately when dropdown opens
|
|
373
|
+
isPositionCalculatedRef.current = false;
|
|
367
374
|
adjustDropdownPosition();
|
|
368
|
-
|
|
369
|
-
return () => {
|
|
370
|
-
window.removeEventListener('resize', adjustDropdownPosition);
|
|
371
|
-
};
|
|
372
375
|
}, [
|
|
373
376
|
dropOpen,
|
|
374
377
|
selectedItems?.length,
|
|
375
378
|
filteredData?.length,
|
|
376
379
|
enableSelectAll,
|
|
377
380
|
isMultiple,
|
|
381
|
+
adjustDropdownPosition,
|
|
378
382
|
]);
|
|
379
383
|
|
|
384
|
+
// Separate effect for resize listener (only when dropdown is open)
|
|
385
|
+
useEffect(() => {
|
|
386
|
+
if (!dropOpen) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
window.addEventListener('resize', adjustDropdownPosition);
|
|
390
|
+
|
|
391
|
+
return () => {
|
|
392
|
+
window.removeEventListener('resize', adjustDropdownPosition);
|
|
393
|
+
};
|
|
394
|
+
}, [dropOpen, adjustDropdownPosition]);
|
|
395
|
+
|
|
380
396
|
useEffect(() => {
|
|
381
397
|
// Handle keyboard navigation
|
|
382
398
|
const handleKeyDown = (e: any) => {
|
|
@@ -593,9 +609,9 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
593
609
|
const borderBottom = parseFloat(computedStyle.borderBottomWidth) || 0;
|
|
594
610
|
const lineHeight = parseFloat(computedStyle.lineHeight) || 20;
|
|
595
611
|
|
|
596
|
-
const singleLineThreshold = paddingTop + paddingBottom + borderTop + borderBottom + lineHeight +
|
|
612
|
+
const singleLineThreshold = paddingTop + paddingBottom + borderTop + borderBottom + lineHeight + 20;
|
|
597
613
|
const isSingle = el.scrollHeight <= singleLineThreshold;
|
|
598
|
-
|
|
614
|
+
|
|
599
615
|
// Only update if value changed
|
|
600
616
|
if (isExpandableSingleLineRef.current !== isSingle) {
|
|
601
617
|
isExpandableSingleLineRef.current = isSingle;
|
|
@@ -765,7 +781,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
765
781
|
|
|
766
782
|
{/* Suggestions Dropdown */}
|
|
767
783
|
|
|
768
|
-
{dropOpen &&
|
|
784
|
+
{dropOpen && dropdownStyle &&
|
|
769
785
|
ReactDOM.createPortal(
|
|
770
786
|
<ul
|
|
771
787
|
ref={dropRef}
|