react-core-ts 1.9.5 → 1.9.7
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 +63 -20
- package/dist/AutoCompleteWithSelectedList.js.map +1 -1
- package/dist/ExpandableAutoComplete.js +59 -18
- package/dist/ExpandableAutoComplete.js.map +1 -1
- package/dist/styles/styles/components/autocomplete.css +699 -0
- package/dist/styles/styles/components/selectedautocomplete.css +168 -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/AutoCompleteWithSelectedList.tsx +61 -25
- package/src/ExpandableAutoComplete.tsx +52 -19
|
@@ -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
|
@@ -115,7 +115,6 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
115
115
|
const [refetchData, setRefetchData] = useState(false);
|
|
116
116
|
const [allDataLoaded, setAllDataLoaded] = useState(false);
|
|
117
117
|
|
|
118
|
-
|
|
119
118
|
let originalOverflow = '';
|
|
120
119
|
let hasScrollbar = false;
|
|
121
120
|
|
|
@@ -148,7 +147,12 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
148
147
|
|
|
149
148
|
setSelHeight(defaultHeight);
|
|
150
149
|
} else if (spaceAbove >= dropdownHeight) {
|
|
151
|
-
|
|
150
|
+
let sHeight = tabInlineSearch ? 73 : 113;
|
|
151
|
+
sHeight =
|
|
152
|
+
sHeight -
|
|
153
|
+
(filteredData?.length > 0 && enableSelectAll && isMultiple
|
|
154
|
+
? 32
|
|
155
|
+
: 0);
|
|
152
156
|
dropLevelRef.current = 'top';
|
|
153
157
|
dropdownPosition.top =
|
|
154
158
|
inputRect.top +
|
|
@@ -214,10 +218,18 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
214
218
|
setSelectedItems((prev) => {
|
|
215
219
|
const isAdded =
|
|
216
220
|
prev && prev.length > 0
|
|
217
|
-
? prev.some(
|
|
221
|
+
? prev.some(
|
|
222
|
+
(item) =>
|
|
223
|
+
item[descId]?.toString().toLowerCase() ===
|
|
224
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
225
|
+
)
|
|
218
226
|
: false;
|
|
219
227
|
if (isAdded) {
|
|
220
|
-
return prev.filter(
|
|
228
|
+
return prev.filter(
|
|
229
|
+
(item) =>
|
|
230
|
+
item[descId]?.toString().toLowerCase() !==
|
|
231
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
232
|
+
);
|
|
221
233
|
} else {
|
|
222
234
|
return [...prev, suggestion];
|
|
223
235
|
}
|
|
@@ -257,7 +269,9 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
257
269
|
} else {
|
|
258
270
|
setSelectedItems((prev) => {
|
|
259
271
|
return prev.filter(
|
|
260
|
-
(item, i) =>
|
|
272
|
+
(item, i) =>
|
|
273
|
+
item[descId]?.toString().toLowerCase() !==
|
|
274
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
261
275
|
);
|
|
262
276
|
});
|
|
263
277
|
}
|
|
@@ -299,7 +313,7 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
299
313
|
const trimStart = value.trimStart();
|
|
300
314
|
setSearchValue(trimStart);
|
|
301
315
|
handleChangeWithDebounce(trimStart);
|
|
302
|
-
setAllDataLoaded(false)
|
|
316
|
+
setAllDataLoaded(false);
|
|
303
317
|
};
|
|
304
318
|
|
|
305
319
|
const handleClear = () => {
|
|
@@ -319,6 +333,7 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
319
333
|
setShowAllSelected(false);
|
|
320
334
|
setSearchValue('');
|
|
321
335
|
if (isMultiple) onChange([]);
|
|
336
|
+
if (async) resetSuggections?.();
|
|
322
337
|
else onChange({ [descId]: '', [desc]: '' });
|
|
323
338
|
};
|
|
324
339
|
|
|
@@ -333,18 +348,6 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
333
348
|
});
|
|
334
349
|
};
|
|
335
350
|
|
|
336
|
-
useEffect(() => {
|
|
337
|
-
if (isInitialRender) {
|
|
338
|
-
setIsInitialRender(false);
|
|
339
|
-
} else {
|
|
340
|
-
onChange(selectedItems);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
adjustDropdownPosition();
|
|
344
|
-
setTimeout(() => {
|
|
345
|
-
adjustDropdownPosition();
|
|
346
|
-
}, 200);
|
|
347
|
-
}, [selectedItems]);
|
|
348
351
|
const uniqueDropArrowId = `${name}-drop-arrow-selected-list-icon`;
|
|
349
352
|
useEffect(() => {
|
|
350
353
|
const handleClickOutside = (event: any) => {
|
|
@@ -412,6 +415,19 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
412
415
|
matchFromStart
|
|
413
416
|
);
|
|
414
417
|
|
|
418
|
+
useEffect(() => {
|
|
419
|
+
if (isInitialRender) {
|
|
420
|
+
setIsInitialRender(false);
|
|
421
|
+
} else {
|
|
422
|
+
onChange(selectedItems);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
adjustDropdownPosition();
|
|
426
|
+
setTimeout(() => {
|
|
427
|
+
adjustDropdownPosition();
|
|
428
|
+
}, 200);
|
|
429
|
+
}, [selectedItems, filteredData]);
|
|
430
|
+
|
|
415
431
|
useEffect(() => {
|
|
416
432
|
// Handle keyboard navigation
|
|
417
433
|
const handleKeyDown = (e: any) => {
|
|
@@ -477,10 +493,19 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
477
493
|
): boolean => {
|
|
478
494
|
if (Array.isArray(selectedItems)) {
|
|
479
495
|
return selectedItems.some(
|
|
480
|
-
(selectedItem) =>
|
|
496
|
+
(selectedItem) =>
|
|
497
|
+
selectedItem[desc]?.toString().toLowerCase() ===
|
|
498
|
+
item[desc]?.toString().toLowerCase() ||
|
|
499
|
+
selectedItem[descId]?.toString().toLowerCase() ===
|
|
500
|
+
item[descId]?.toString().toLowerCase()
|
|
481
501
|
);
|
|
482
502
|
} else {
|
|
483
|
-
return
|
|
503
|
+
return (
|
|
504
|
+
item[desc]?.toString().toLowerCase() ===
|
|
505
|
+
selectedItems?.toString().toLowerCase() ||
|
|
506
|
+
item[descId]?.toString().toLowerCase() ===
|
|
507
|
+
selectedItems?.toString().toLowerCase()
|
|
508
|
+
);
|
|
484
509
|
}
|
|
485
510
|
};
|
|
486
511
|
|
|
@@ -680,14 +705,21 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
680
705
|
if (selectAll) {
|
|
681
706
|
setSelectedItems((prev) =>
|
|
682
707
|
prev.filter(
|
|
683
|
-
(item) =>
|
|
708
|
+
(item) =>
|
|
709
|
+
!filteredData.some(
|
|
710
|
+
(f) =>
|
|
711
|
+
f[descId]?.toString().toLowerCase() ===
|
|
712
|
+
item[descId]?.toString().toLowerCase()
|
|
713
|
+
)
|
|
684
714
|
)
|
|
685
715
|
);
|
|
686
716
|
} else {
|
|
687
717
|
filteredData.map((suggestion: ValueProps) =>
|
|
688
718
|
setSelectedItems((prev) => {
|
|
689
719
|
const isAdded = prev.some(
|
|
690
|
-
(item) =>
|
|
720
|
+
(item) =>
|
|
721
|
+
item[descId]?.toString().toLowerCase() ===
|
|
722
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
691
723
|
);
|
|
692
724
|
if (isAdded) {
|
|
693
725
|
return prev;
|
|
@@ -705,11 +737,11 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
705
737
|
if (autoDropdown && (inputValue === '' || inputValue.trim() === '')) {
|
|
706
738
|
handlePickSuggestions('*', 1);
|
|
707
739
|
setRefetchData(false);
|
|
708
|
-
setAllDataLoaded(true)
|
|
740
|
+
setAllDataLoaded(true);
|
|
709
741
|
} else if (!refetchData && inputValue !== '') {
|
|
710
742
|
handlePickSuggestions(inputValue, 1);
|
|
711
743
|
setRefetchData(true);
|
|
712
|
-
setAllDataLoaded(false)
|
|
744
|
+
setAllDataLoaded(false);
|
|
713
745
|
}
|
|
714
746
|
}
|
|
715
747
|
};
|
|
@@ -718,7 +750,11 @@ const AutoCompleteWithSelectedList = forwardRef<
|
|
|
718
750
|
const allSelected =
|
|
719
751
|
filteredData.length > 0 &&
|
|
720
752
|
filteredData.every((item) =>
|
|
721
|
-
selectedItems.some(
|
|
753
|
+
selectedItems.some(
|
|
754
|
+
(s) =>
|
|
755
|
+
s[descId]?.toString().toLowerCase() ===
|
|
756
|
+
item[descId]?.toString().toLowerCase()
|
|
757
|
+
)
|
|
722
758
|
);
|
|
723
759
|
|
|
724
760
|
setSelectAll(allSelected);
|
|
@@ -14,7 +14,7 @@ import InputActions from './components/InputActions';
|
|
|
14
14
|
import { useSuggestions } from './utilities/autosuggestions';
|
|
15
15
|
import { debounce } from './utilities/debounce';
|
|
16
16
|
import { deepEqual } from './utilities/deepEqual';
|
|
17
|
-
import { default as Tooltip } from './utilities/
|
|
17
|
+
import { default as Tooltip } from './utilities/NewTooltip';
|
|
18
18
|
import { filterSuggestions } from './utilities/filterSuggestions';
|
|
19
19
|
import { AllDropArrow, Search, Spinner } from './utilities/icons';
|
|
20
20
|
|
|
@@ -108,11 +108,16 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
108
108
|
const spaceBelow = window.innerHeight - inputRect.bottom;
|
|
109
109
|
const spaceAbove = inputRect.top + window.scrollY;
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
let dropdownHeight = 275; // Assume a fixed height or calculate based on content
|
|
112
112
|
if (spaceBelow >= dropdownHeight) {
|
|
113
113
|
dropdownPosition.top =
|
|
114
114
|
inputRect.top + window.scrollY + inputRect.height;
|
|
115
115
|
} else {
|
|
116
|
+
dropdownHeight =
|
|
117
|
+
dropdownHeight +
|
|
118
|
+
(filteredData?.length > 0 && enableSelectAll && isMultiple
|
|
119
|
+
? 32
|
|
120
|
+
: 0);
|
|
116
121
|
dropdownPosition.top =
|
|
117
122
|
inputRect.top + window.scrollY - dropdownHeight + 73;
|
|
118
123
|
}
|
|
@@ -123,15 +128,6 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
123
128
|
}
|
|
124
129
|
};
|
|
125
130
|
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
window.addEventListener('resize', adjustDropdownPosition);
|
|
128
|
-
adjustDropdownPosition();
|
|
129
|
-
|
|
130
|
-
return () => {
|
|
131
|
-
window.removeEventListener('resize', adjustDropdownPosition);
|
|
132
|
-
};
|
|
133
|
-
}, [dropOpen, selectedItems]);
|
|
134
|
-
|
|
135
131
|
const { suggestions, isLoading, handlePickSuggestions } = useSuggestions(
|
|
136
132
|
getData,
|
|
137
133
|
data,
|
|
@@ -154,10 +150,16 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
154
150
|
setFocusedIndex(idx);
|
|
155
151
|
setSelectedItems((prev) => {
|
|
156
152
|
const isAdded = prev.some(
|
|
157
|
-
(item) =>
|
|
153
|
+
(item) =>
|
|
154
|
+
item[descId]?.toString().toLowerCase() ===
|
|
155
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
158
156
|
);
|
|
159
157
|
if (isAdded) {
|
|
160
|
-
return prev.filter(
|
|
158
|
+
return prev.filter(
|
|
159
|
+
(item) =>
|
|
160
|
+
item[descId]?.toString().toLowerCase() !==
|
|
161
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
162
|
+
);
|
|
161
163
|
} else {
|
|
162
164
|
return [...prev, suggestion];
|
|
163
165
|
}
|
|
@@ -196,7 +198,9 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
196
198
|
} else {
|
|
197
199
|
setSelectedItems((prev) => {
|
|
198
200
|
return prev.filter(
|
|
199
|
-
(item, i) =>
|
|
201
|
+
(item, i) =>
|
|
202
|
+
item[descId]?.toString().toLowerCase() !==
|
|
203
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
200
204
|
);
|
|
201
205
|
});
|
|
202
206
|
}
|
|
@@ -327,6 +331,15 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
327
331
|
matchFromStart
|
|
328
332
|
);
|
|
329
333
|
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
window.addEventListener('resize', adjustDropdownPosition);
|
|
336
|
+
adjustDropdownPosition();
|
|
337
|
+
|
|
338
|
+
return () => {
|
|
339
|
+
window.removeEventListener('resize', adjustDropdownPosition);
|
|
340
|
+
};
|
|
341
|
+
}, [dropOpen, selectedItems, filteredData]);
|
|
342
|
+
|
|
330
343
|
useEffect(() => {
|
|
331
344
|
// Handle keyboard navigation
|
|
332
345
|
const handleKeyDown = (e: any) => {
|
|
@@ -391,10 +404,19 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
391
404
|
): boolean => {
|
|
392
405
|
if (Array.isArray(selectedItems)) {
|
|
393
406
|
return selectedItems.some(
|
|
394
|
-
(selectedItem) =>
|
|
407
|
+
(selectedItem) =>
|
|
408
|
+
selectedItem[desc]?.toString().toLowerCase() ===
|
|
409
|
+
item[desc]?.toString().toLowerCase() ||
|
|
410
|
+
selectedItem[descId]?.toString().toLowerCase() ===
|
|
411
|
+
item[descId]?.toString().toLowerCase()
|
|
395
412
|
);
|
|
396
413
|
} else {
|
|
397
|
-
return
|
|
414
|
+
return (
|
|
415
|
+
item[desc]?.toString().toLowerCase() ===
|
|
416
|
+
selectedItems?.toString().toLowerCase() ||
|
|
417
|
+
item[descId]?.toString().toLowerCase() ===
|
|
418
|
+
selectedItems?.toString().toLowerCase()
|
|
419
|
+
);
|
|
398
420
|
}
|
|
399
421
|
};
|
|
400
422
|
|
|
@@ -441,14 +463,21 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
441
463
|
if (selectAll) {
|
|
442
464
|
setSelectedItems((prev) =>
|
|
443
465
|
prev.filter(
|
|
444
|
-
(item) =>
|
|
466
|
+
(item) =>
|
|
467
|
+
!filteredData.some(
|
|
468
|
+
(f) =>
|
|
469
|
+
f[descId]?.toString().toLowerCase() ===
|
|
470
|
+
item[descId]?.toString().toLowerCase()
|
|
471
|
+
)
|
|
445
472
|
)
|
|
446
473
|
);
|
|
447
474
|
} else {
|
|
448
475
|
filteredData.map((suggestion: ValueProps) =>
|
|
449
476
|
setSelectedItems((prev) => {
|
|
450
477
|
const isAdded = prev.some(
|
|
451
|
-
(item) =>
|
|
478
|
+
(item) =>
|
|
479
|
+
item[descId]?.toString().toLowerCase() ===
|
|
480
|
+
suggestion[descId]?.toString().toLowerCase()
|
|
452
481
|
);
|
|
453
482
|
if (isAdded) {
|
|
454
483
|
return prev;
|
|
@@ -480,7 +509,11 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
480
509
|
const allSelected =
|
|
481
510
|
filteredData.length > 0 &&
|
|
482
511
|
filteredData.every((item) =>
|
|
483
|
-
selectedItems.some(
|
|
512
|
+
selectedItems.some(
|
|
513
|
+
(s) =>
|
|
514
|
+
s[descId]?.toString().toLowerCase() ===
|
|
515
|
+
item[descId]?.toString().toLowerCase()
|
|
516
|
+
)
|
|
484
517
|
);
|
|
485
518
|
|
|
486
519
|
setSelectAll(allSelected);
|