react-core-ts 1.9.0 → 1.9.2
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 +54 -36
- package/dist/ExpandableAutoComplete.js.map +1 -1
- package/dist/commontypes.d.ts +1 -0
- package/dist/styles/styles/components/autocomplete.css +694 -0
- package/dist/styles/styles/components/selectedautocomplete.css +151 -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 +135 -80
- package/src/commontypes.ts +2 -1
- package/src/styles/components/autocomplete.css +6 -0
- package/src/styles/components/selectedautocomplete.css +18 -0
|
@@ -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
|
@@ -64,6 +64,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
64
64
|
labelCode = '',
|
|
65
65
|
typeOnlyFetch = false,
|
|
66
66
|
autoDropdown = false,
|
|
67
|
+
enableSelectAll = false,
|
|
67
68
|
},
|
|
68
69
|
ref
|
|
69
70
|
) => {
|
|
@@ -81,6 +82,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
81
82
|
const itemsRef = useRef<HTMLDivElement>(null);
|
|
82
83
|
const dropBtnRef = useRef<HTMLButtonElement>(null);
|
|
83
84
|
const [refetchData, setRefetchData] = useState(false);
|
|
85
|
+
const [selectAll, setSelectAll] = useState(false);
|
|
84
86
|
|
|
85
87
|
// API call for suggestions through a custom hook
|
|
86
88
|
const inputRef = useRef(null);
|
|
@@ -433,25 +435,33 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
433
435
|
|
|
434
436
|
const handleSelectAll = () => {
|
|
435
437
|
if (isMultiple) {
|
|
436
|
-
|
|
437
|
-
setSelectedItems((prev) =>
|
|
438
|
-
|
|
439
|
-
(item) =>
|
|
440
|
-
)
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
438
|
+
if (selectAll) {
|
|
439
|
+
setSelectedItems((prev) =>
|
|
440
|
+
prev.filter(
|
|
441
|
+
(item) => !filteredData.some((f) => f[descId] === item[descId])
|
|
442
|
+
)
|
|
443
|
+
);
|
|
444
|
+
} else {
|
|
445
|
+
filteredData.map((suggestion: ValueProps) =>
|
|
446
|
+
setSelectedItems((prev) => {
|
|
447
|
+
const isAdded = prev.some(
|
|
448
|
+
(item) => item[descId] === suggestion[descId]
|
|
449
|
+
);
|
|
450
|
+
if (isAdded) {
|
|
451
|
+
return prev;
|
|
452
|
+
} else {
|
|
453
|
+
return [...prev, suggestion];
|
|
454
|
+
}
|
|
455
|
+
})
|
|
456
|
+
);
|
|
457
|
+
}
|
|
448
458
|
}
|
|
449
459
|
};
|
|
450
460
|
|
|
451
461
|
const handleOpenDropdown = (e: any) => {
|
|
452
462
|
if (!suggestions || suggestions?.length === 0 || refetchData) {
|
|
453
463
|
if (autoDropdown && (inputValue === '' || inputValue.trim() === '')) {
|
|
454
|
-
handlePickSuggestions('
|
|
464
|
+
handlePickSuggestions('*', 1);
|
|
455
465
|
setRefetchData(false);
|
|
456
466
|
} else if (!refetchData && inputValue !== '') {
|
|
457
467
|
handlePickSuggestions(inputValue, 1);
|
|
@@ -463,6 +473,16 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
463
473
|
}
|
|
464
474
|
};
|
|
465
475
|
|
|
476
|
+
useEffect(() => {
|
|
477
|
+
const allSelected =
|
|
478
|
+
filteredData.length > 0 &&
|
|
479
|
+
filteredData.every((item) =>
|
|
480
|
+
selectedItems.some((s) => s[descId] === item[descId])
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
setSelectAll(allSelected);
|
|
484
|
+
}, [filteredData, selectedItems, descId]);
|
|
485
|
+
|
|
466
486
|
return (
|
|
467
487
|
<div
|
|
468
488
|
id={id ? `expandable-container-${id}` : `expandable-container-${name}`}
|
|
@@ -579,7 +599,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
579
599
|
<button
|
|
580
600
|
disabled={disabled ?? readOnly}
|
|
581
601
|
onClick={(e) => handleOpenDropdown(e)}
|
|
582
|
-
className="
|
|
602
|
+
className="text-[#667085] focus-visible:outline-slate-100 absolute right-2 qbs-all-dropdown-btn"
|
|
583
603
|
data-testid="drop-arrow"
|
|
584
604
|
type="button"
|
|
585
605
|
id="autocomplete-drop-icon"
|
|
@@ -628,7 +648,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
628
648
|
<ul
|
|
629
649
|
ref={dropRef}
|
|
630
650
|
style={{ ...dropdownStyle, minHeight: 192 }}
|
|
631
|
-
className={`qbs-autocomplete-suggestions`}
|
|
651
|
+
className={`qbs-autocomplete-suggestions qbs-autocomplete-suggestions-expandable`}
|
|
632
652
|
id={
|
|
633
653
|
id
|
|
634
654
|
? `autocomplete-dropdown-${id}`
|
|
@@ -653,77 +673,112 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
653
673
|
</div>
|
|
654
674
|
)}
|
|
655
675
|
|
|
656
|
-
|
|
657
|
-
className={`qbs-autocomplete-suggestions-sub `}
|
|
658
|
-
ref={itemsRef}
|
|
659
|
-
>
|
|
660
|
-
{filteredData?.length > 0 ? (
|
|
661
|
-
filteredData.map((suggestion: ValueProps, idx: number) => (
|
|
662
|
-
<DropdownList
|
|
663
|
-
idx={idx}
|
|
664
|
-
suggestion={suggestion}
|
|
665
|
-
isSelected={isSelected}
|
|
666
|
-
handleSuggestionClick={() =>
|
|
667
|
-
handleSuggestionClick(suggestion, idx)
|
|
668
|
-
}
|
|
669
|
-
handleMultiSelect={handleMultiSelect}
|
|
670
|
-
selected={selected}
|
|
671
|
-
isMultiple={isMultiple}
|
|
672
|
-
singleSelect={singleSelect}
|
|
673
|
-
desc={desc}
|
|
674
|
-
shortCode={shortCode}
|
|
675
|
-
labelCode={labelCode}
|
|
676
|
-
focusedIndex={focusedIndex}
|
|
677
|
-
setItemRef={(index, ref) => {
|
|
678
|
-
itemRefs.current[index] = ref; // Store each ref properly
|
|
679
|
-
}}
|
|
680
|
-
/>
|
|
681
|
-
))
|
|
682
|
-
) : (
|
|
683
|
-
<>
|
|
684
|
-
{isLoading ? (
|
|
685
|
-
<div
|
|
686
|
-
style={{ display: 'flex', justifyContent: 'center' }}
|
|
687
|
-
className="qbs-autocomplete-loader"
|
|
688
|
-
>
|
|
689
|
-
<span>
|
|
690
|
-
<Spinner />
|
|
691
|
-
</span>
|
|
692
|
-
</div>
|
|
693
|
-
) : (
|
|
694
|
-
<li
|
|
695
|
-
className="qbs-autocomplete-notfound"
|
|
696
|
-
onClick={handleBlur}
|
|
697
|
-
>
|
|
698
|
-
{notDataMessage ??
|
|
699
|
-
(searchValue === '' || typeRef.current === 1)
|
|
700
|
-
? 'Start typing to see suggestions'
|
|
701
|
-
: 'No Results Found'}
|
|
702
|
-
</li>
|
|
703
|
-
)}
|
|
704
|
-
</>
|
|
705
|
-
)}
|
|
706
|
-
{paginationEnabled &&
|
|
707
|
-
nextBlock !== 0 &&
|
|
708
|
-
nextBlock !== undefined &&
|
|
709
|
-
filteredData?.length > 0 && (
|
|
710
|
-
<div
|
|
711
|
-
className="loadMoreSection"
|
|
712
|
-
onClick={() => handleLoadMore()}
|
|
713
|
-
>
|
|
714
|
-
<p style={{ margin: 2 }}>Load More</p>
|
|
715
|
-
</div>
|
|
716
|
-
)}
|
|
717
|
-
</div>
|
|
718
|
-
{filteredData?.length > 0 && (
|
|
676
|
+
{filteredData?.length > 0 && enableSelectAll && isMultiple && (
|
|
719
677
|
<div
|
|
720
678
|
id="select-all"
|
|
721
|
-
className={`qbs-select-all-link qbs-
|
|
679
|
+
className={`qbs-select-all-link qbs-cursor-pointer qbs-text-xs`}
|
|
722
680
|
onClick={handleSelectAll}
|
|
723
681
|
>
|
|
724
|
-
|
|
682
|
+
<div
|
|
683
|
+
className={`qbs-autocomplete-listitem-container qbs-autocomplete-checkbox-container`}
|
|
684
|
+
>
|
|
685
|
+
<div className="qbs-autocomplete-checkbox">
|
|
686
|
+
<input
|
|
687
|
+
type="checkbox"
|
|
688
|
+
checked={selectAll}
|
|
689
|
+
id={`qbs-checkbox-all`}
|
|
690
|
+
/>
|
|
691
|
+
<label htmlFor={`qbs-checkbox-all`}>
|
|
692
|
+
<svg
|
|
693
|
+
width="8"
|
|
694
|
+
height="6"
|
|
695
|
+
viewBox="0 0 8 6"
|
|
696
|
+
fill="none"
|
|
697
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
698
|
+
>
|
|
699
|
+
<path
|
|
700
|
+
d="M0 3.21739L2.89883 6L8 1.06994L6.89494 0L2.89883 3.86768L1.09728 2.14745L0 3.21739Z"
|
|
701
|
+
fill="white"
|
|
702
|
+
/>
|
|
703
|
+
</svg>
|
|
704
|
+
</label>
|
|
705
|
+
</div>
|
|
706
|
+
<div className={`qbs-autocomplete-suggestions-item`}>
|
|
707
|
+
Select All
|
|
708
|
+
</div>
|
|
709
|
+
</div>
|
|
725
710
|
</div>
|
|
726
711
|
)}
|
|
712
|
+
|
|
713
|
+
<div className="qbs-autocomplete-suggestions-expandable-container">
|
|
714
|
+
<div
|
|
715
|
+
className={`qbs-autocomplete-suggestions-sub qbs-autocomplete-suggestions-outer`}
|
|
716
|
+
ref={itemsRef}
|
|
717
|
+
>
|
|
718
|
+
{filteredData?.length > 0 ? (
|
|
719
|
+
filteredData.map(
|
|
720
|
+
(suggestion: ValueProps, idx: number) => (
|
|
721
|
+
<DropdownList
|
|
722
|
+
idx={idx}
|
|
723
|
+
suggestion={suggestion}
|
|
724
|
+
isSelected={isSelected}
|
|
725
|
+
handleSuggestionClick={() =>
|
|
726
|
+
handleSuggestionClick(suggestion, idx)
|
|
727
|
+
}
|
|
728
|
+
handleMultiSelect={handleMultiSelect}
|
|
729
|
+
selected={selected}
|
|
730
|
+
isMultiple={isMultiple}
|
|
731
|
+
singleSelect={singleSelect}
|
|
732
|
+
desc={desc}
|
|
733
|
+
shortCode={shortCode}
|
|
734
|
+
labelCode={labelCode}
|
|
735
|
+
focusedIndex={focusedIndex}
|
|
736
|
+
setItemRef={(index, ref) => {
|
|
737
|
+
itemRefs.current[index] = ref; // Store each ref properly
|
|
738
|
+
}}
|
|
739
|
+
/>
|
|
740
|
+
)
|
|
741
|
+
)
|
|
742
|
+
) : (
|
|
743
|
+
<>
|
|
744
|
+
{isLoading ? (
|
|
745
|
+
<div
|
|
746
|
+
style={{
|
|
747
|
+
display: 'flex',
|
|
748
|
+
justifyContent: 'center',
|
|
749
|
+
}}
|
|
750
|
+
className="qbs-autocomplete-loader"
|
|
751
|
+
>
|
|
752
|
+
<span>
|
|
753
|
+
<Spinner />
|
|
754
|
+
</span>
|
|
755
|
+
</div>
|
|
756
|
+
) : (
|
|
757
|
+
<li
|
|
758
|
+
className="qbs-autocomplete-notfound"
|
|
759
|
+
onClick={handleBlur}
|
|
760
|
+
>
|
|
761
|
+
{notDataMessage ??
|
|
762
|
+
(searchValue === '' || typeRef.current === 1)
|
|
763
|
+
? 'Start typing to see suggestions'
|
|
764
|
+
: 'No Results Found'}
|
|
765
|
+
</li>
|
|
766
|
+
)}
|
|
767
|
+
</>
|
|
768
|
+
)}
|
|
769
|
+
{paginationEnabled &&
|
|
770
|
+
nextBlock !== 0 &&
|
|
771
|
+
nextBlock !== undefined &&
|
|
772
|
+
filteredData?.length > 0 && (
|
|
773
|
+
<div
|
|
774
|
+
className="loadMoreSection"
|
|
775
|
+
onClick={() => handleLoadMore()}
|
|
776
|
+
>
|
|
777
|
+
<p style={{ margin: 2 }}>Load More</p>
|
|
778
|
+
</div>
|
|
779
|
+
)}
|
|
780
|
+
</div>
|
|
781
|
+
</div>
|
|
727
782
|
</ul>,
|
|
728
783
|
document.body
|
|
729
784
|
)}
|
package/src/commontypes.ts
CHANGED
|
@@ -81,7 +81,8 @@ export interface AutoSuggestionInputProps {
|
|
|
81
81
|
labelCode?: string,
|
|
82
82
|
tabInlineSearch?: boolean // tab dropdown search
|
|
83
83
|
matchFromStart?: boolean // match data's from the starting position
|
|
84
|
-
autoDropdown?: boolean;
|
|
84
|
+
autoDropdown?: boolean; // enable all items list items
|
|
85
|
+
enableSelectAll?: boolean // enable select all option
|
|
85
86
|
}
|
|
86
87
|
export interface IconsProps {
|
|
87
88
|
name: any;
|
|
@@ -111,6 +111,12 @@ body * {
|
|
|
111
111
|
|
|
112
112
|
/* Ensure content doesn't overflow during transition */
|
|
113
113
|
}
|
|
114
|
+
.qbs-autocomplete-suggestions-expandable{
|
|
115
|
+
padding: 8px 0px;
|
|
116
|
+
}
|
|
117
|
+
.qbs-autocomplete-suggestions-expandable .qbs-autocomplete-suggestions-expandable-container {
|
|
118
|
+
padding: 0px 8px;
|
|
119
|
+
}
|
|
114
120
|
.qbs-autocomplete-suggestions.bottom {
|
|
115
121
|
top: 100%; /* Position below the input */
|
|
116
122
|
/* Other styling */
|
|
@@ -130,4 +130,22 @@
|
|
|
130
130
|
}
|
|
131
131
|
.qbs-bottom-0{
|
|
132
132
|
bottom: 0;
|
|
133
|
+
}
|
|
134
|
+
.qbs-select-all-link{
|
|
135
|
+
border-bottom: 1px solid var(--border-card-color-default, #d6d8dc);
|
|
136
|
+
padding: 0px 8px;
|
|
137
|
+
}
|
|
138
|
+
.qbs-select-all-link .qbs-autocomplete-suggestions-item {
|
|
139
|
+
margin-top: 5px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.qbs-select-all-link .qbs-autocomplete-checkbox-container:hover,
|
|
143
|
+
.qbs-select-all-link .qbs-autocomplete-checkbox-container.is-selected,
|
|
144
|
+
.qbs-select-all-link .qbs-autocomplete-suggestions-item:hover
|
|
145
|
+
{
|
|
146
|
+
background: #fff;
|
|
147
|
+
border-radius: 0px;
|
|
148
|
+
}
|
|
149
|
+
.qbs-select-all-link .qbs-autocomplete-listitem-container:hover {
|
|
150
|
+
background-color:#fff !important;
|
|
133
151
|
}
|