react-core-ts 2.1.13 → 2.1.15
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/AutoCompleteWithTabFilter.js +5 -13
- package/dist/AutoCompleteWithTabFilter.js.map +1 -1
- package/dist/ReactAutoCompleteTableView.js +17 -8
- package/dist/ReactAutoCompleteTableView.js.map +1 -1
- package/dist/dropdownFilterTabs.js +19 -39
- package/dist/dropdownFilterTabs.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/dist/utilities/autosuggestions.d.ts +2 -2
- package/dist/utilities/autosuggestions.js +2 -2
- package/dist/utilities/autosuggestions.js.map +1 -1
- package/docs/App.tsx +12 -2
- package/package.json +3 -2
- package/src/AutoCompleteWithTabFilter.tsx +5 -13
- package/src/ReactAutoCompleteTableView.tsx +18 -10
- package/src/dropdownFilterTabs.tsx +17 -29
- package/src/utilities/autosuggestions.ts +7 -4
|
@@ -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
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
type ValueProps = {
|
|
2
2
|
[key: string]: string;
|
|
3
3
|
};
|
|
4
|
-
type UseSuggestionsType = (getData: (key?: string, next?: number, tabValue?: number | string) => Promise<ValueProps[]>, initialData?: ValueProps[], dropOpen?: boolean, asyncFetch?: boolean, paginationEnabled?: boolean, typeOnlyFetch?: boolean, inputValue?: string, isMultiple?: boolean, setNextPage?: (value: number) => void, selectedItems?: any[], initialLoad?: boolean) => {
|
|
4
|
+
type UseSuggestionsType = (getData: (key?: string, next?: number, tabValue?: number | string, toolApply?: boolean) => Promise<ValueProps[]>, initialData?: ValueProps[], dropOpen?: boolean, asyncFetch?: boolean, paginationEnabled?: boolean, typeOnlyFetch?: boolean, inputValue?: string, isMultiple?: boolean, setNextPage?: (value: number) => void, selectedItems?: any[], initialLoad?: boolean) => {
|
|
5
5
|
suggestions: ValueProps[];
|
|
6
6
|
isLoading: boolean;
|
|
7
|
-
handlePickSuggestions: (value?: string, next?: number, append?: boolean, tabValue?: string | number) => Promise<void>;
|
|
7
|
+
handlePickSuggestions: (value?: string, next?: number, append?: boolean, tabValue?: string | number, toolApply?: boolean) => Promise<void>;
|
|
8
8
|
resetSuggections?: () => void;
|
|
9
9
|
};
|
|
10
10
|
export declare const useSuggestions: UseSuggestionsType;
|
|
@@ -61,7 +61,7 @@ var useSuggestions = function (getData, initialData, dropOpen, asyncFetch, pagin
|
|
|
61
61
|
var resetSuggections = function () {
|
|
62
62
|
setSuggestions([]);
|
|
63
63
|
};
|
|
64
|
-
var handlePickSuggestions = function (value, nextPage, appendData, tabValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
var handlePickSuggestions = function (value, nextPage, appendData, tabValue, toolApply) { return __awaiter(void 0, void 0, void 0, function () {
|
|
65
65
|
var data, newSuggestions, error_1;
|
|
66
66
|
return __generator(this, function (_a) {
|
|
67
67
|
switch (_a.label) {
|
|
@@ -73,7 +73,7 @@ var useSuggestions = function (getData, initialData, dropOpen, asyncFetch, pagin
|
|
|
73
73
|
return [4 /*yield*/, (asyncFetch || initialLoad
|
|
74
74
|
? typeOnlyFetch && value === ""
|
|
75
75
|
? Promise.resolve([])
|
|
76
|
-
: getData(value, nextPage, tabValue)
|
|
76
|
+
: getData(value, nextPage, tabValue, toolApply)
|
|
77
77
|
: Promise.resolve(initialData))];
|
|
78
78
|
case 2:
|
|
79
79
|
data = _a.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autosuggestions.js","sourceRoot":"","sources":["../../src/utilities/autosuggestions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4C;
|
|
1
|
+
{"version":3,"file":"autosuggestions.js","sourceRoot":"","sources":["../../src/utilities/autosuggestions.ts"],"names":[],"mappings":"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"}
|
package/docs/App.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import { ValueProps } from "../src/commontypes";
|
|
4
4
|
import { AutoComplete, AutoCompleteWithSelectedList, AutoCompleteWithTabFilter, AutoCompleteWithTreeStructure, ExpandableAutoComplete, ModernAutoComplete, ModernAutoCompleteDropdown, ModernAutoCompleteTableView, ModernAutoCompleteSuggections, ModernTextField } from "../src/index";
|
|
@@ -718,11 +718,21 @@ export default function App() {
|
|
|
718
718
|
interface MoreOptionsComponentProps {
|
|
719
719
|
onApply?: (values?: any) => void;
|
|
720
720
|
onValueChange?: (values?: any) => void;
|
|
721
|
+
resetKey?: number;
|
|
721
722
|
}
|
|
722
723
|
|
|
723
|
-
const MoreOptionsComponent = ({ onApply, onValueChange }: MoreOptionsComponentProps) => {
|
|
724
|
+
const MoreOptionsComponent = ({ onApply, onValueChange, resetKey }: MoreOptionsComponentProps) => {
|
|
724
725
|
const [checked, setChecked] = useState(false);
|
|
725
726
|
|
|
727
|
+
// Reset component state when resetKey changes
|
|
728
|
+
useEffect(() => {
|
|
729
|
+
if (resetKey !== undefined && resetKey > 0) {
|
|
730
|
+
setChecked(false);
|
|
731
|
+
// Notify parent that values have been reset
|
|
732
|
+
onValueChange?.(undefined);
|
|
733
|
+
}
|
|
734
|
+
}, [resetKey, onValueChange]);
|
|
735
|
+
|
|
726
736
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
727
737
|
const newValue = e.target.checked;
|
|
728
738
|
setChecked(newValue);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-core-ts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.15",
|
|
4
4
|
"description": "React Components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"start": "webpack serve --open --mode development",
|
|
9
9
|
"build": "tsc && cp -R src/styles dist/styles",
|
|
10
10
|
"test": "jest",
|
|
11
|
-
"prepublishOnly": "npm run build"
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"prepare": "npm run build"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
@@ -1034,7 +1034,8 @@ const AutoCompleteWithTabFilter = forwardRef<
|
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
1036
|
|
|
1037
|
-
//
|
|
1037
|
+
// Clear tabSelectedItems after applying filter and data is loaded
|
|
1038
|
+
onToolTabChange?.([]);
|
|
1038
1039
|
setShowToolsTab(false);
|
|
1039
1040
|
// Reset moreOptionTab component
|
|
1040
1041
|
setMoreOptionResetKey(prev => prev + 1);
|
|
@@ -1055,21 +1056,12 @@ const AutoCompleteWithTabFilter = forwardRef<
|
|
|
1055
1056
|
setAllDataLoaded(false);
|
|
1056
1057
|
}, [showToolsTab]);
|
|
1057
1058
|
|
|
1058
|
-
const handleApplyTabFilter = useCallback((
|
|
1059
|
-
// Call onToolTabChange with selected items data when Apply is clicked
|
|
1060
|
-
if (data?.selectedItems !== undefined) {
|
|
1061
|
-
onToolTabChange?.(data.selectedItems);
|
|
1062
|
-
// Clear tabSelectedItems after data is sent
|
|
1063
|
-
// Use setTimeout to ensure the data is sent first
|
|
1064
|
-
setTimeout(() => {
|
|
1065
|
-
onToolTabChange?.([]);
|
|
1066
|
-
}, 0);
|
|
1067
|
-
}
|
|
1059
|
+
const handleApplyTabFilter = useCallback((moreOptionValues?: any) => {
|
|
1068
1060
|
// Set flag to trigger effect when data loads
|
|
1069
1061
|
setApplyTabFilter(true);
|
|
1070
|
-
handlePickSuggestions(searchValue ? searchValue : '*', 1);
|
|
1062
|
+
handlePickSuggestions(searchValue ? searchValue : '*', 1, false, undefined, true);
|
|
1071
1063
|
// Note: onMoreOptionChange is called when values change in the component, not here
|
|
1072
|
-
}, [searchValue, handlePickSuggestions
|
|
1064
|
+
}, [searchValue, handlePickSuggestions]);
|
|
1073
1065
|
|
|
1074
1066
|
useEffect(() => {
|
|
1075
1067
|
const allSelected =
|
|
@@ -125,6 +125,7 @@ const ReactAutoCompleteTableView: React.FC<AutoSuggestionInputProps> = ({
|
|
|
125
125
|
left: 0,
|
|
126
126
|
bottom: 0,
|
|
127
127
|
right: 0,
|
|
128
|
+
maxHeight: '60vh',
|
|
128
129
|
});
|
|
129
130
|
const checkIncludes = (
|
|
130
131
|
mainString: string,
|
|
@@ -552,19 +553,25 @@ const ReactAutoCompleteTableView: React.FC<AutoSuggestionInputProps> = ({
|
|
|
552
553
|
|
|
553
554
|
const getDropPosition = (): any => {
|
|
554
555
|
if (!insideOpen && inputRef?.current) {
|
|
555
|
-
const
|
|
556
|
+
const minDropdownHeight = 200;
|
|
557
|
+
const padding = 24; // gap + margin so dropdown doesn't touch viewport edge
|
|
556
558
|
const isMobile = window.innerWidth < 768; // Mobile breakpoint
|
|
557
559
|
|
|
558
560
|
const inputRect = inputRef.current.getBoundingClientRect();
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
const spaceAbove = inputRect.top
|
|
561
|
+
const maxHeightLimit = window.innerHeight * 0.6;
|
|
562
|
+
const spaceBelow = Math.max(0, window.innerHeight - inputRect.bottom - padding);
|
|
563
|
+
const spaceAbove = Math.max(0, inputRect.top - padding);
|
|
564
|
+
const availableSpace = Math.max(spaceAbove, spaceBelow);
|
|
565
|
+
const maxHeightPx = Math.min(Math.max(minDropdownHeight, availableSpace), maxHeightLimit);
|
|
562
566
|
|
|
563
|
-
let top;
|
|
564
|
-
let bottom;
|
|
565
|
-
if
|
|
566
|
-
|
|
567
|
+
let top: number | undefined;
|
|
568
|
+
let bottom: number | undefined;
|
|
569
|
+
// Open above if there's more space above, or if there's not enough space below
|
|
570
|
+
if (spaceAbove > spaceBelow || (spaceBelow < minDropdownHeight && spaceAbove >= minDropdownHeight)) {
|
|
571
|
+
// Open above: position above input
|
|
572
|
+
bottom = window.innerHeight - inputRect.top + window.scrollY + 2;
|
|
567
573
|
} else {
|
|
574
|
+
// Open below: position below input
|
|
568
575
|
top = inputRect.top + window.scrollY + inputRect.height + 2;
|
|
569
576
|
}
|
|
570
577
|
|
|
@@ -626,6 +633,7 @@ const ReactAutoCompleteTableView: React.FC<AutoSuggestionInputProps> = ({
|
|
|
626
633
|
top,
|
|
627
634
|
bottom,
|
|
628
635
|
width,
|
|
636
|
+
maxHeight: `${maxHeightPx}px`,
|
|
629
637
|
});
|
|
630
638
|
}
|
|
631
639
|
|
|
@@ -723,13 +731,13 @@ const ReactAutoCompleteTableView: React.FC<AutoSuggestionInputProps> = ({
|
|
|
723
731
|
return (
|
|
724
732
|
(filteredData?.length > 0 || showNoResults) && (
|
|
725
733
|
<div
|
|
726
|
-
style={{ ...dropPosition,
|
|
734
|
+
style={{ ...dropPosition, overflow: 'hidden' }}
|
|
727
735
|
className="autocomplete-suggections autocomplete-suggections-tableview absolute bg-white shadow-gray-300 shadow-md border border-grey-light z-50 mt-9"
|
|
728
736
|
>
|
|
729
737
|
<ul
|
|
730
738
|
className={`h-auto overflow-auto w-full ${tableView ? '' : 'py-1.5'}`}
|
|
731
739
|
ref={scrollContainerRef}
|
|
732
|
-
style={{ maxHeight:
|
|
740
|
+
style={{ maxHeight: dropPosition.maxHeight ? `calc(${dropPosition.maxHeight} - 2rem)` : undefined }}
|
|
733
741
|
>
|
|
734
742
|
{filteredData?.length > 0 ? (
|
|
735
743
|
<>
|
|
@@ -145,14 +145,17 @@ const DropdownFilterTabs = forwardRef<
|
|
|
145
145
|
const [hasMoreOptionValues, setHasMoreOptionValues] = useState(false);
|
|
146
146
|
const [tabsScrollable, setTabsScrollable] = useState(false);
|
|
147
147
|
const scrollableDivsRef = useRef<NodeListOf<Element> | null>(null);
|
|
148
|
+
const [localResetKey, setLocalResetKey] = useState(0);
|
|
148
149
|
|
|
149
|
-
// Use external reset key if provided, otherwise
|
|
150
|
-
const currentResetKey = externalResetKey !== undefined ? externalResetKey :
|
|
150
|
+
// Use external reset key if provided, otherwise use local reset key
|
|
151
|
+
const currentResetKey = externalResetKey !== undefined ? externalResetKey : localResetKey;
|
|
151
152
|
|
|
152
153
|
// Reset hasMoreOptionValues when reset key changes
|
|
153
154
|
useEffect(() => {
|
|
154
155
|
if (externalResetKey !== undefined && externalResetKey > 0) {
|
|
155
156
|
setHasMoreOptionValues(false);
|
|
157
|
+
// Reset local reset key when external reset happens
|
|
158
|
+
setLocalResetKey(0);
|
|
156
159
|
}
|
|
157
160
|
}, [externalResetKey]);
|
|
158
161
|
|
|
@@ -635,11 +638,8 @@ const DropdownFilterTabs = forwardRef<
|
|
|
635
638
|
setIsInitialRender(false);
|
|
636
639
|
} else {
|
|
637
640
|
// Only call onChange if selectedItems actually changed
|
|
638
|
-
// Skip onChange if applyTabFilter is provided (onChange will be called on Apply button click)
|
|
639
641
|
if (!deepEqual(selectedItems, prevSelectedItemsRef.current)) {
|
|
640
|
-
|
|
641
|
-
onChange(selectedItems);
|
|
642
|
-
}
|
|
642
|
+
onChange(selectedItems);
|
|
643
643
|
prevSelectedItemsRef.current = selectedItems;
|
|
644
644
|
}
|
|
645
645
|
}
|
|
@@ -650,7 +650,7 @@ const DropdownFilterTabs = forwardRef<
|
|
|
650
650
|
});
|
|
651
651
|
});
|
|
652
652
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
653
|
-
}, [selectedItems
|
|
653
|
+
}, [selectedItems]);
|
|
654
654
|
|
|
655
655
|
useEffect(() => {
|
|
656
656
|
// Use double requestAnimationFrame to ensure DOM updates are complete
|
|
@@ -992,19 +992,12 @@ const DropdownFilterTabs = forwardRef<
|
|
|
992
992
|
setDropOpen(false);
|
|
993
993
|
setSearchValue('');
|
|
994
994
|
resetSuggections?.();
|
|
995
|
-
//
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
if (moreOpts !== undefined && moreOpts !== null) {
|
|
1002
|
-
onMoreOptionChange?.(moreOpts);
|
|
1003
|
-
}
|
|
1004
|
-
// Pass all selected items from all tabs to applyTabFilter
|
|
1005
|
-
applyTabFilter?.({ selectedItems: itemsToPass, moreOptionValues: moreOpts });
|
|
1006
|
-
// Clear all selected items after applying
|
|
1007
|
-
setSelectedItems([]);
|
|
995
|
+
// Reset moreOption data
|
|
996
|
+
setHasMoreOptionValues(false);
|
|
997
|
+
onMoreOptionChange?.(undefined);
|
|
998
|
+
// Trigger reset on moreOption component by incrementing reset key
|
|
999
|
+
setLocalResetKey(prev => prev + 1);
|
|
1000
|
+
applyTabFilter?.(values);
|
|
1008
1001
|
};
|
|
1009
1002
|
|
|
1010
1003
|
useEffect(() => {
|
|
@@ -1063,20 +1056,15 @@ const DropdownFilterTabs = forwardRef<
|
|
|
1063
1056
|
>
|
|
1064
1057
|
{React.isValidElement(moreOptionTab)
|
|
1065
1058
|
? React.cloneElement(moreOptionTab as React.ReactElement<any>, {
|
|
1066
|
-
onApply: (values?: any) =>
|
|
1067
|
-
// Include selected tab values along with moreOption values
|
|
1068
|
-
handleApplySelected({
|
|
1069
|
-
...values,
|
|
1070
|
-
selectedItems: selectedItems
|
|
1071
|
-
});
|
|
1072
|
-
},
|
|
1059
|
+
onApply: (values?: any) => handleApplySelected(values),
|
|
1073
1060
|
onValueChange: (values?: any) => {
|
|
1074
|
-
//
|
|
1075
|
-
// onMoreOptionChange is called only when Apply button is clicked
|
|
1061
|
+
// Check if values exist and update state
|
|
1076
1062
|
const hasValues = values !== undefined && values !== null &&
|
|
1077
1063
|
(typeof values === 'object' ? Object.keys(values).length > 0 : true);
|
|
1078
1064
|
setHasMoreOptionValues(hasValues);
|
|
1065
|
+
onMoreOptionChange?.(values);
|
|
1079
1066
|
},
|
|
1067
|
+
resetKey: currentResetKey,
|
|
1080
1068
|
} as any)
|
|
1081
1069
|
: moreOptionTab}
|
|
1082
1070
|
</div>
|
|
@@ -8,7 +8,8 @@ type UseSuggestionsType = (
|
|
|
8
8
|
getData: (
|
|
9
9
|
key?: string,
|
|
10
10
|
next?: number,
|
|
11
|
-
tabValue?: number | string
|
|
11
|
+
tabValue?: number | string,
|
|
12
|
+
toolApply?: boolean
|
|
12
13
|
) => Promise<ValueProps[]>,
|
|
13
14
|
initialData?: ValueProps[],
|
|
14
15
|
dropOpen?: boolean,
|
|
@@ -28,7 +29,8 @@ type UseSuggestionsType = (
|
|
|
28
29
|
value?: string,
|
|
29
30
|
next?: number,
|
|
30
31
|
append?: boolean,
|
|
31
|
-
tabValue?: string | number
|
|
32
|
+
tabValue?: string | number,
|
|
33
|
+
toolApply?: boolean
|
|
32
34
|
) => Promise<void>;
|
|
33
35
|
resetSuggections?: () => void
|
|
34
36
|
};
|
|
@@ -57,14 +59,15 @@ export const useSuggestions: UseSuggestionsType = (
|
|
|
57
59
|
value?: string,
|
|
58
60
|
nextPage?: number,
|
|
59
61
|
appendData?: boolean,
|
|
60
|
-
tabValue?: string | number
|
|
62
|
+
tabValue?: string | number,
|
|
63
|
+
toolApply?: boolean
|
|
61
64
|
) => {
|
|
62
65
|
setIsLoading(true);
|
|
63
66
|
try {
|
|
64
67
|
const data = await (asyncFetch || initialLoad
|
|
65
68
|
? typeOnlyFetch && value === ""
|
|
66
69
|
? Promise.resolve([])
|
|
67
|
-
: getData(value, nextPage, tabValue)
|
|
70
|
+
: getData(value, nextPage, tabValue, toolApply)
|
|
68
71
|
: Promise.resolve(initialData));
|
|
69
72
|
if (!data || data?.length === 0) {
|
|
70
73
|
setNextPage(undefined);
|