@agilant/toga-blox 1.0.74 → 1.0.76
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/components/SearchInput/SearchDropdownInput.js +6 -12
- package/dist/components/SearchInput/SearchInput.js +1 -1
- package/dist/components/SearchInput/SearchInputDatePicker.js +4 -6
- package/dist/components/SearchInput/SearchNumberInput.d.ts +24 -1
- package/dist/components/SearchInput/SearchNumberInput.js +127 -22
- package/dist/components/SearchInput/SearchTextInput.js +4 -7
- package/dist/utils/updateLocalStorage.d.ts +2 -0
- package/dist/utils/updateLocalStorage.js +4 -0
- package/package.json +1 -1
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import MultiSelectInput from "../MultiSelect/MultiSelect";
|
|
4
|
+
import updateLocalStorage from "../../utils/updateLocalStorage";
|
|
4
5
|
const DEFAULT_STORAGE_KEY = "searchCriteria";
|
|
5
6
|
const SearchDropdownInput = ({ options = [], selectedValue = [], onChange, placeholder = "Select", disabled = false, hasSelectAll = true, bgColor = "bg-sky-500", textHighlight = "text-sky-700", handleFilter, searchItems = [], setSearchItems, setSearchCriteria, column, setEditingHeader, localStorageKey = DEFAULT_STORAGE_KEY, ...rest }) => {
|
|
6
7
|
// Are we able to store filters for this column?
|
|
7
8
|
const canStore = !!column?.id && !!setSearchCriteria;
|
|
8
|
-
/** Helper: write the entire searchCriteria array to localStorage */
|
|
9
|
-
const updateLocalStorage = (criteria) => {
|
|
10
|
-
localStorage.setItem(localStorageKey, JSON.stringify(criteria));
|
|
11
|
-
};
|
|
12
9
|
useEffect(() => {
|
|
13
10
|
if (!canStore)
|
|
14
11
|
return;
|
|
@@ -46,30 +43,27 @@ const SearchDropdownInput = ({ options = [], selectedValue = [], onChange, place
|
|
|
46
43
|
.join(",");
|
|
47
44
|
const isEmpty = !selectedLabels.trim();
|
|
48
45
|
if (!canStore) {
|
|
49
|
-
// If we have no place to store it, just do handleFilter
|
|
50
46
|
handleFilter?.();
|
|
51
47
|
return;
|
|
52
48
|
}
|
|
53
49
|
if (isEmpty) {
|
|
54
50
|
setSearchCriteria?.((prev) => {
|
|
55
51
|
const newCriteria = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
56
|
-
updateLocalStorage(newCriteria);
|
|
52
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
57
53
|
return newCriteria;
|
|
58
54
|
});
|
|
59
55
|
}
|
|
60
56
|
else {
|
|
61
|
-
if (!searchItems.includes(selectedLabels)) {
|
|
62
|
-
setSearchItems?.([...searchItems, selectedLabels]);
|
|
63
|
-
}
|
|
64
57
|
setSearchCriteria?.((prev) => {
|
|
58
|
+
const filtered = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
65
59
|
const newCriteria = [
|
|
66
|
-
...
|
|
60
|
+
...filtered,
|
|
67
61
|
{
|
|
68
62
|
searchColumn: column,
|
|
69
63
|
submittedSearchText: selectedLabels,
|
|
70
64
|
},
|
|
71
65
|
];
|
|
72
|
-
updateLocalStorage(newCriteria);
|
|
66
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
73
67
|
return newCriteria;
|
|
74
68
|
});
|
|
75
69
|
}
|
|
@@ -81,7 +75,7 @@ const SearchDropdownInput = ({ options = [], selectedValue = [], onChange, place
|
|
|
81
75
|
if (canStore) {
|
|
82
76
|
setSearchCriteria?.((prev) => {
|
|
83
77
|
const newCriteria = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
84
|
-
updateLocalStorage(newCriteria);
|
|
78
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
85
79
|
return newCriteria;
|
|
86
80
|
});
|
|
87
81
|
setSearchItems?.([]);
|
|
@@ -19,7 +19,7 @@ const SearchInput = ({ bgColor = "bg-sky-500", textHighlight = "text-sky-500", i
|
|
|
19
19
|
case "text":
|
|
20
20
|
return (_jsx(SearchTextInput, { dropdownIconProp: dropdownIconProp, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, searchItems: searchItems, setSearchItems: setSearchItems, handleFilter: handleFilter, setSearchCriteria: setSearchCriteria, column: column, setEditingHeader: setEditingHeader, pillColor: pillColor, firstIconClasses: firstIconClasses }));
|
|
21
21
|
case "number":
|
|
22
|
-
return (_jsx(SearchNumberInput, { dropdownIconProp: dropdownIconProp, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, minValue: minValue, maxValue: maxValue, setMinValue: setMinValue, setMaxValue: setMaxValue, handleFilter: handleFilter }));
|
|
22
|
+
return (_jsx(SearchNumberInput, { dropdownIconProp: dropdownIconProp, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, minValue: minValue, maxValue: maxValue, setMinValue: setMinValue, setMaxValue: setMaxValue, handleFilter: handleFilter, setSearchCriteria: setSearchCriteria, column: column }));
|
|
23
23
|
case "multiSelect":
|
|
24
24
|
return (_jsx(SearchDropdownInput, { options: dropdownOptions, placeholder: "Search", additionalClasses: "", onChange: onChange, selectedValue: selectedValue, bgColor: bgColor, textHighlight: textHighlight, handleFilter: handleFilter, column: column, setSearchCriteria: setSearchCriteria }));
|
|
25
25
|
case "date":
|
|
@@ -8,6 +8,7 @@ import BaseButton from "../BaseButton";
|
|
|
8
8
|
import Badge from "../Badge/Badge";
|
|
9
9
|
import Text from "../Text";
|
|
10
10
|
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
11
|
+
import updateLocalStorage from "../../utils/updateLocalStorage";
|
|
11
12
|
/**
|
|
12
13
|
* A helper to convert a Date object to 'YYYY-MM-DD'
|
|
13
14
|
* so we don't get slashes in the final string.
|
|
@@ -71,9 +72,6 @@ searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEd
|
|
|
71
72
|
document.addEventListener("mousedown", handleClickOutside);
|
|
72
73
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
73
74
|
}, []);
|
|
74
|
-
const updateLocalStorage = (criteria) => {
|
|
75
|
-
localStorage.setItem(localStorageKey, JSON.stringify(criteria));
|
|
76
|
-
};
|
|
77
75
|
/**
|
|
78
76
|
* Build a string in 'YYYY-MM-DD' (or range) format,
|
|
79
77
|
* so it won't break in your URL as "mm%2Fdd%2Fyyyy"
|
|
@@ -111,7 +109,7 @@ searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEd
|
|
|
111
109
|
if (canStore) {
|
|
112
110
|
setSearchCriteria?.((prev) => {
|
|
113
111
|
const newCriteria = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
114
|
-
updateLocalStorage(newCriteria);
|
|
112
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
115
113
|
return newCriteria;
|
|
116
114
|
});
|
|
117
115
|
}
|
|
@@ -130,7 +128,7 @@ searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEd
|
|
|
130
128
|
submittedSearchText: dateString,
|
|
131
129
|
},
|
|
132
130
|
];
|
|
133
|
-
updateLocalStorage(newCriteria);
|
|
131
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
134
132
|
return newCriteria;
|
|
135
133
|
});
|
|
136
134
|
}
|
|
@@ -188,7 +186,7 @@ searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEd
|
|
|
188
186
|
setSearchCriteria?.((prev) => {
|
|
189
187
|
const filtered = prev.filter((crit) => crit.submittedSearchText !==
|
|
190
188
|
item);
|
|
191
|
-
updateLocalStorage(filtered);
|
|
189
|
+
updateLocalStorage(filtered, localStorageKey);
|
|
192
190
|
return filtered;
|
|
193
191
|
});
|
|
194
192
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { ColumnInstance } from "react-table";
|
|
2
3
|
import { searchDropdownIconProps } from "./SearchInput.types";
|
|
4
|
+
/** The parent can pass these props to replicate local-storage filter usage. */
|
|
3
5
|
type SearchNumberInputProps<T extends object> = {
|
|
4
6
|
pillColor?: string;
|
|
5
7
|
textHighlight?: string;
|
|
@@ -13,7 +15,28 @@ type SearchNumberInputProps<T extends object> = {
|
|
|
13
15
|
setMinValue?: React.Dispatch<React.SetStateAction<string>>;
|
|
14
16
|
maxValue?: string;
|
|
15
17
|
setMaxValue?: React.Dispatch<React.SetStateAction<string>>;
|
|
18
|
+
/** Called after we store or remove the filter in localStorage. */
|
|
16
19
|
handleFilter?: () => void;
|
|
20
|
+
/** The array of “badges” (previously added filters) for this column. */
|
|
21
|
+
searchItems?: string[];
|
|
22
|
+
setSearchItems?: React.Dispatch<React.SetStateAction<string[]>>;
|
|
23
|
+
/** The full array of all filters for the table. */
|
|
24
|
+
setSearchCriteria?: React.Dispatch<React.SetStateAction<any[]>>;
|
|
25
|
+
/** The column object must have an .id so we know which filter is ours. */
|
|
26
|
+
column?: ColumnInstance<any> | {
|
|
27
|
+
id: string;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
/** If you want to close the popover or overlay once we filter/clear */
|
|
31
|
+
setEditingHeader?: React.Dispatch<React.SetStateAction<any>>;
|
|
32
|
+
/** localStorage key to store all the table’s filters (default "searchCriteria"). */
|
|
33
|
+
localStorageKey?: string;
|
|
17
34
|
};
|
|
18
|
-
|
|
35
|
+
/**
|
|
36
|
+
* A numeric filter component that:
|
|
37
|
+
* 1. Uses toggleStatus to switch single vs. range
|
|
38
|
+
* 2. On Filter => either remove or store a string in localStorage
|
|
39
|
+
* 3. On mount => read any existing filter for this column, parse, and set min/max
|
|
40
|
+
*/
|
|
41
|
+
declare const SearchNumberInput: <T extends object>({ textHighlight, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, handleFilter, searchItems, setSearchItems, setSearchCriteria, column, setEditingHeader, localStorageKey, }: SearchNumberInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
19
42
|
export default SearchNumberInput;
|
|
@@ -5,37 +5,142 @@ import Dropdown from "../Dropdown/Dropdown";
|
|
|
5
5
|
import ToggleButton from "../ToggleButton/ToggleButton";
|
|
6
6
|
import BaseButton from "../BaseButton";
|
|
7
7
|
import Text from "../Text";
|
|
8
|
+
import updateLocalStorage from "../../utils/updateLocalStorage";
|
|
9
|
+
const DEFAULT_STORAGE_KEY = "searchCriteria";
|
|
10
|
+
/**
|
|
11
|
+
* A numeric filter component that:
|
|
12
|
+
* 1. Uses toggleStatus to switch single vs. range
|
|
13
|
+
* 2. On Filter => either remove or store a string in localStorage
|
|
14
|
+
* 3. On mount => read any existing filter for this column, parse, and set min/max
|
|
15
|
+
*/
|
|
8
16
|
const SearchNumberInput = ({ textHighlight = "text-sky-500", dropdownIconProp = {
|
|
9
|
-
iconClasses:
|
|
17
|
+
iconClasses: "text-sky-500",
|
|
10
18
|
name: "chevronDown",
|
|
11
19
|
weight: "solid",
|
|
12
|
-
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, handleFilter,
|
|
20
|
+
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, toggleStatus = false, setToggleStatus, minValue = "", setMinValue, maxValue = "", setMaxValue, handleFilter,
|
|
21
|
+
// local-storage
|
|
22
|
+
searchItems = [], setSearchItems, setSearchCriteria, column, setEditingHeader, localStorageKey = DEFAULT_STORAGE_KEY, }) => {
|
|
13
23
|
const containerRef = useRef(null);
|
|
14
24
|
const inputRef = useRef(null);
|
|
15
|
-
|
|
25
|
+
const canStore = !!column?.id && !!setSearchCriteria;
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!canStore)
|
|
28
|
+
return;
|
|
29
|
+
const stored = localStorage.getItem(localStorageKey);
|
|
30
|
+
if (!stored)
|
|
31
|
+
return;
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(stored);
|
|
34
|
+
const existing = parsed.find((c) => c.searchColumn?.id === column.id);
|
|
35
|
+
if (existing) {
|
|
36
|
+
const savedString = existing.submittedSearchText;
|
|
37
|
+
if (savedString && typeof savedString === "string") {
|
|
38
|
+
if (savedString.includes(" - ")) {
|
|
39
|
+
setToggleStatus?.(true);
|
|
40
|
+
const [minPart, maxPart] = savedString.split(" - ");
|
|
41
|
+
setMinValue?.(minPart.trim());
|
|
42
|
+
setMaxValue?.(maxPart.trim());
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setToggleStatus?.(false);
|
|
46
|
+
const segments = savedString.split(" ");
|
|
47
|
+
if (segments.length > 1 &&
|
|
48
|
+
dropdownOptions.includes(segments[0])) {
|
|
49
|
+
onDropdownOptionSelect?.(segments[0]);
|
|
50
|
+
setMinValue?.(segments[1]);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// no special prefix => assume it's just the number
|
|
54
|
+
setMinValue?.(savedString);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Also set searchItems so the "badge" might show
|
|
58
|
+
setSearchItems?.([savedString]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error("Error reading stored number filter:", err);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
// Focus on mount if needed
|
|
16
67
|
useEffect(() => {
|
|
17
68
|
inputRef.current?.focus();
|
|
18
69
|
}, []);
|
|
19
|
-
|
|
20
|
-
|
|
70
|
+
/** Build the final string to store. Feel free to tweak logic here. */
|
|
71
|
+
const buildNumberString = () => {
|
|
72
|
+
if (toggleStatus) {
|
|
73
|
+
// Range mode => "min - max"
|
|
74
|
+
if (minValue && maxValue) {
|
|
75
|
+
return `${minValue} - ${maxValue}`;
|
|
76
|
+
}
|
|
77
|
+
else if (minValue) {
|
|
78
|
+
return `${minValue} - `;
|
|
79
|
+
}
|
|
80
|
+
else if (maxValue) {
|
|
81
|
+
return ` - ${maxValue}`;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return ""; // no input => empty
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Single value mode => e.g. "Exactly 123" or just "123"
|
|
89
|
+
// If you want "Less Than 123", you might do:
|
|
90
|
+
if (selectedDropdownOption && minValue) {
|
|
91
|
+
return `${selectedDropdownOption} ${minValue}`;
|
|
92
|
+
}
|
|
93
|
+
else if (minValue) {
|
|
94
|
+
return minValue; // fallback
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
21
100
|
};
|
|
22
|
-
|
|
23
|
-
|
|
101
|
+
/** Called when user clicks "Filter" button at the bottom. */
|
|
102
|
+
const handleFilterClick = () => {
|
|
103
|
+
const finalString = buildNumberString().trim();
|
|
104
|
+
if (!finalString) {
|
|
105
|
+
// If it's empty => remove existing filter for this column
|
|
106
|
+
if (canStore) {
|
|
107
|
+
setSearchCriteria?.((prev) => {
|
|
108
|
+
const newCriteria = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
109
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
110
|
+
return newCriteria;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// store it
|
|
116
|
+
if (!searchItems.includes(finalString)) {
|
|
117
|
+
setSearchItems?.([...searchItems, finalString]);
|
|
118
|
+
}
|
|
119
|
+
if (canStore) {
|
|
120
|
+
setSearchCriteria?.((prev) => {
|
|
121
|
+
// remove old for this column if you want to keep it unique
|
|
122
|
+
const filtered = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
123
|
+
const newCriteria = [
|
|
124
|
+
...filtered,
|
|
125
|
+
{
|
|
126
|
+
searchColumn: column,
|
|
127
|
+
submittedSearchText: finalString,
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
131
|
+
return newCriteria;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Optionally close the popover
|
|
136
|
+
setEditingHeader?.(null);
|
|
137
|
+
// Let the parent know a filter was applied
|
|
138
|
+
handleFilter?.();
|
|
24
139
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// };
|
|
31
|
-
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: `flex flex-col p-4 h-[130px] border-2 border-navy-200 rounded-md`, children: [_jsx("div", { className: `flex flex-[1] ${toggleStatus ? "" : "border-2"} h-full max-h-11 items-center justify-around`, children: toggleStatus ? (_jsxs(_Fragment, { children: [_jsx(Input, { focusRingColor: "focus:ring-2", hasAutoFocus: true, value: minValue, iconColor: "text-navy-400",
|
|
32
|
-
// onKeyDown={handleKeyDown}
|
|
33
|
-
required: false, id: "", name: "", type: "number", onChange: handleInputChange, additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex focus:border-l-2 ", placeholder: "Min" }), _jsx(Text, { size: "text-md", tag: "span", text: "to", additionalClasses: "px-2" }), _jsx(Input, { focusRingColor: "focus:ring-2", value: maxValue, iconColor: "text-navy-400",
|
|
34
|
-
// onKeyDown={handleKeyDown}
|
|
35
|
-
required: false, id: "", name: "", type: "number", onChange: handleMaximumInputChange, additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex border-2 focus:border-l-2 focus:border- ", placeholder: "Max", hasIcons: true, iconPosition: "both" })] })) : (_jsxs(_Fragment, { children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 h-full flex items-center", menuClasses: "bg-white w-min-[150px] top-[-8px] left-[-2px]", dropdownClasses: "border-0 w-auto", icon: dropdownIconProp }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: minValue, iconColor: "text-navy-400",
|
|
36
|
-
// onKeyDown={handleKeyDown}
|
|
37
|
-
required: false, id: "", name: "", type: "number", onChange: handleInputChange, additionalClasses: "min-w-[200px] h-10 text-gray flex border-l-2 ", placeholder: "Amount", hasIcons: true, iconPosition: "both" })] })) }), _jsxs("div", { className: "flex flex-[1] justify-between items-end bg-white px-2 ", children: [_jsx(ToggleButton, { initialStatus: toggleStatus, onClick: () => {
|
|
38
|
-
setToggleStatus(!toggleStatus);
|
|
39
|
-
}, activeColorBackground: "bg-sky-500", activeColorBorder: "border-sky-500", activeLabel: "Range", activeTextColor: "text-sky-500", additionalClasses: "flex items-center", inactiveColorBackground: "bg-gray-300", inactiveColorBorder: "border-gray-300", inactiveLabel: "Range", inactiveTextColor: "text-gray-500", pillHeight: "h-8", textPosition: "right", textSize: "text-sm", smallToggle: false, borderStyle: false }), _jsx(BaseButton, { text: "Filter", backgroundColor: "bg-sky-500", additionalClasses: "py-1.5 px-6 text-white", borderColor: "border-none", onClick: handleFilter, shape: "rounded-full" })] })] }) }));
|
|
140
|
+
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: "flex flex-col p-4 h-[130px] border-2 border-navy-200 rounded-md", children: [_jsx("div", { className: `flex flex-[1] ${toggleStatus ? "" : "border-2"} h-full max-h-11 items-center justify-around`, children: toggleStatus ? (
|
|
141
|
+
// Range mode
|
|
142
|
+
_jsxs(_Fragment, { children: [_jsx(Input, { focusRingColor: "focus:ring-2", hasAutoFocus: true, value: minValue, iconColor: "text-navy-400", required: false, id: "", name: "", type: "number", onChange: (e) => setMinValue?.(e.target.value), additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex focus:border-l-2 ", placeholder: "Min" }), _jsx(Text, { size: "text-md", tag: "span", text: "to", additionalClasses: "px-2" }), _jsx(Input, { focusRingColor: "focus:ring-2", value: maxValue, iconColor: "text-navy-400", required: false, id: "", name: "", type: "number", onChange: (e) => setMaxValue?.(e.target.value), additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex border-2 focus:border-l-2 ", placeholder: "Max" })] })) : (
|
|
143
|
+
// Single value mode
|
|
144
|
+
_jsxs(_Fragment, { children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 h-full flex items-center", menuClasses: "bg-white w-min-[150px] top-[-8px] left-[-2px]", dropdownClasses: "border-0 w-auto", icon: dropdownIconProp }), _jsx(Input, { ref: inputRef, focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: minValue, iconColor: "text-navy-400", required: false, id: "", name: "", type: "number", onChange: (e) => setMinValue?.(e.target.value), additionalClasses: "min-w-[200px] h-10 text-gray flex border-l-2 ", placeholder: "Amount", hasIcons: true, iconPosition: "both" })] })) }), _jsxs("div", { className: "flex flex-[1] justify-between items-end bg-white px-2", children: [_jsx(ToggleButton, { initialStatus: toggleStatus, onClick: () => setToggleStatus?.(!toggleStatus), activeColorBackground: "bg-sky-500", activeColorBorder: "border-sky-500", activeLabel: "Range", activeTextColor: "text-sky-500", additionalClasses: "flex items-center", inactiveColorBackground: "bg-gray-300", inactiveColorBorder: "border-gray-300", inactiveLabel: "Range", inactiveTextColor: "text-gray-500", pillHeight: "h-8", textPosition: "right", textSize: "text-sm", smallToggle: false, borderStyle: false }), _jsx(BaseButton, { text: "Filter", backgroundColor: "bg-sky-500", additionalClasses: "py-1.5 px-6 text-white", borderColor: "border-none", onClick: handleFilterClick, shape: "rounded-full" })] })] }) }));
|
|
40
145
|
};
|
|
41
146
|
export default SearchNumberInput;
|
|
@@ -6,6 +6,7 @@ import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
|
6
6
|
import Dropdown from "../Dropdown/Dropdown";
|
|
7
7
|
import Badge from "../Badge/Badge";
|
|
8
8
|
import Text from "../Text";
|
|
9
|
+
import updateLocalStorage from "../../utils/updateLocalStorage";
|
|
9
10
|
const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-500", dropdownIconProp = {
|
|
10
11
|
iconClasses: textHighlight,
|
|
11
12
|
name: "chevronDown",
|
|
@@ -31,10 +32,6 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
}, [column.id, localStorageKey]);
|
|
34
|
-
// Helper to update local storage.
|
|
35
|
-
const updateLocalStorage = (criteria) => {
|
|
36
|
-
localStorage.setItem(localStorageKey, JSON.stringify(criteria));
|
|
37
|
-
};
|
|
38
35
|
const handleInputChange = (event) => {
|
|
39
36
|
setLocalSearchText(event.target.value);
|
|
40
37
|
};
|
|
@@ -46,7 +43,7 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
46
43
|
// Remove corresponding criterion from searchCriteria.
|
|
47
44
|
setSearchCriteria((prev) => {
|
|
48
45
|
const newCriteria = prev.filter((crit) => crit.submittedSearchText !== item);
|
|
49
|
-
updateLocalStorage(newCriteria);
|
|
46
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
50
47
|
console.log("Removed badge criterion, newCriteria:", newCriteria);
|
|
51
48
|
return newCriteria;
|
|
52
49
|
});
|
|
@@ -70,7 +67,7 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
70
67
|
// Remove any criteria for this column.
|
|
71
68
|
setSearchCriteria((prev) => {
|
|
72
69
|
const newCriteria = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
73
|
-
updateLocalStorage(newCriteria);
|
|
70
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
74
71
|
console.log("Removed criterion, newCriteria:", newCriteria);
|
|
75
72
|
return newCriteria;
|
|
76
73
|
});
|
|
@@ -82,7 +79,7 @@ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-5
|
|
|
82
79
|
...prev,
|
|
83
80
|
{ searchColumn: column, submittedSearchText: trimmed },
|
|
84
81
|
];
|
|
85
|
-
updateLocalStorage(newCriteria);
|
|
82
|
+
updateLocalStorage(newCriteria, localStorageKey);
|
|
86
83
|
console.log("Appended criterion, newCriteria:", newCriteria);
|
|
87
84
|
return newCriteria;
|
|
88
85
|
});
|