@agilant/toga-blox 1.0.71 → 1.0.73
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
|
-
import SearchTextInput from "./SearchTextInput";
|
|
3
|
+
import SearchTextInput from "./SearchTextInput"; // your working text
|
|
4
4
|
import SearchNumberInput from "./SearchNumberInput";
|
|
5
5
|
import SearchDropdownInput from "./SearchDropdownInput";
|
|
6
6
|
import SearchDatePickerInput from "./SearchInputDatePicker";
|
|
@@ -23,7 +23,11 @@ const SearchInput = ({ bgColor = "bg-sky-500", textHighlight = "text-sky-500", i
|
|
|
23
23
|
case "multiSelect":
|
|
24
24
|
return (_jsx(SearchDropdownInput, { options: dropdownOptions, isSearchable: true, placeholder: "Search", isMulti: true, hideSelectedOptions: true, closeMenuOnSelect: false, inputWidth: "w-full", inputTextSize: "text-sm", additionalClasses: "", customClassNames: {}, onChange: onChange, value: [], selectedValue: selectedValue, bgColor: bgColor, textHighlight: textHighlight, handleFilter: handleFilter }));
|
|
25
25
|
case "date":
|
|
26
|
-
return (_jsx(SearchDatePickerInput, { textHighlight: textHighlight, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, selectedDate: selectedDate, onDateSelect: onDateSelect, selectedStartDate: selectedStartDate, onStartDateSelect: onStartDateSelect, selectedEndDate: selectedEndDate, onEndDateSelect: onEndDateSelect, handleFilter: handleFilter, themeBgColor: dataPickerThemeColor, lightThemeBg: dataPickerThemeColorAccent
|
|
26
|
+
return (_jsx(SearchDatePickerInput, { textHighlight: textHighlight, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, selectedDate: selectedDate, onDateSelect: onDateSelect, selectedStartDate: selectedStartDate, onStartDateSelect: onStartDateSelect, selectedEndDate: selectedEndDate, onEndDateSelect: onEndDateSelect, handleFilter: handleFilter, themeBgColor: dataPickerThemeColor, lightThemeBg: dataPickerThemeColorAccent,
|
|
27
|
+
// pass the same local-storage props:
|
|
28
|
+
setSearchCriteria: setSearchCriteria, column: column, setEditingHeader: setEditingHeader, searchItems: searchItems, setSearchItems: setSearchItems, pillColor: pillColor }));
|
|
29
|
+
default:
|
|
30
|
+
return null;
|
|
27
31
|
}
|
|
28
32
|
})() }));
|
|
29
33
|
};
|
|
@@ -39,28 +39,40 @@ export default {
|
|
|
39
39
|
},
|
|
40
40
|
parameters: { layout: "centered" },
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Our 'Template' sets up local state for everything,
|
|
44
|
+
* so the SearchInput can function (adding/removing badges, toggling date range, etc.)
|
|
45
|
+
*/
|
|
42
46
|
const Template = (args) => {
|
|
43
47
|
const [selectedOption, setSelectedOption] = useState(args.selectedDropdownOption);
|
|
44
48
|
const [searchItems, setSearchItems] = useState([]);
|
|
45
49
|
const [toggleStatus, setToggleStatus] = useState(false);
|
|
46
50
|
const [minValue, setMinValue] = useState(undefined);
|
|
47
51
|
const [maxValue, setMaxValue] = useState(undefined);
|
|
52
|
+
// For multiSelect
|
|
48
53
|
const [selectedValue, setSelectedValue] = useState(args.selectedValue || []);
|
|
54
|
+
// For date pickers
|
|
49
55
|
const [selectedDate, setSelectedDate] = useState(args.selectedDate);
|
|
50
56
|
const [selectedStartDate, setSelectedStartDate] = useState(args.selectedStartDate);
|
|
51
57
|
const [selectedEndDate, setSelectedEndDate] = useState(args.selectedEndDate);
|
|
52
|
-
//
|
|
58
|
+
// For local-storage logic
|
|
53
59
|
const [searchCriteria, setSearchCriteria] = useState([]);
|
|
60
|
+
// For controlling "editingHeader"
|
|
54
61
|
const [editingHeader, setEditingHeader] = useState(0);
|
|
55
62
|
// Log current state to verify updates.
|
|
56
63
|
console.log("Template render: editingHeader =", editingHeader);
|
|
57
64
|
console.log("Template render: searchCriteria =", searchCriteria);
|
|
65
|
+
// For multiSelect changes (or other input changes)
|
|
58
66
|
const handleOnChange = (newSelected) => {
|
|
59
67
|
setSelectedValue(newSelected);
|
|
60
68
|
args.onChange?.(newSelected);
|
|
61
69
|
console.log("Selected items:", newSelected);
|
|
62
70
|
};
|
|
63
|
-
return (_jsx(SearchInput, { ...args, column: mockColumn,
|
|
71
|
+
return (_jsx(SearchInput, { ...args, column: mockColumn,
|
|
72
|
+
// Our local states
|
|
73
|
+
selectedDropdownOption: selectedOption, onDropdownOptionSelect: (option) => setSelectedOption(option), searchItems: searchItems, setSearchItems: setSearchItems, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, minValue: minValue, maxValue: maxValue, setMinValue: setMinValue, setMaxValue: setMaxValue, onChange: handleOnChange, selectedValue: selectedValue, selectedDate: selectedDate, onDateSelect: setSelectedDate, selectedStartDate: selectedStartDate, onStartDateSelect: setSelectedStartDate, selectedEndDate: selectedEndDate, onEndDateSelect: setSelectedEndDate, setSearchCriteria: setSearchCriteria, setEditingHeader: setEditingHeader,
|
|
74
|
+
// Keep handleFilter from the args or provide a custom
|
|
75
|
+
handleFilter: args.handleFilter }));
|
|
64
76
|
};
|
|
65
77
|
export const Default = Template.bind({});
|
|
66
78
|
Default.args = {
|
|
@@ -148,10 +160,18 @@ DatePickerInput.args = {
|
|
|
148
160
|
dropdownOptions: ["Exactly", "Before", "After"],
|
|
149
161
|
selectedDropdownOption: "Exactly",
|
|
150
162
|
onDropdownOptionSelect: (option) => console.log(`Option selected: ${option}`),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
/**
|
|
164
|
+
* IMPORTANT:
|
|
165
|
+
* DO NOT override 'searchItems' or 'setSearchItems' with no-ops
|
|
166
|
+
* or you lose the local state from the Template.
|
|
167
|
+
*
|
|
168
|
+
* DO NOT pass toggleStatus, setToggleStatus as no-ops, or you won't see range toggling.
|
|
169
|
+
*
|
|
170
|
+
* Keep them out so we use the Template's state-based hooking.
|
|
171
|
+
*/
|
|
172
|
+
// Theming for DayPicker
|
|
155
173
|
themeBgColor: "bg-sky-500",
|
|
156
174
|
lightThemeBg: "bg-sky-100",
|
|
175
|
+
// If you want local-storage logic for date filtering:
|
|
176
|
+
column: { id: "dateColumn" }, // real or mock
|
|
157
177
|
};
|
|
@@ -2,6 +2,9 @@ import React from "react";
|
|
|
2
2
|
import "react-day-picker/dist/style.css";
|
|
3
3
|
import { searchDropdownIconProps } from "./SearchInput.types";
|
|
4
4
|
type SearchDatePickerInputProps<T extends object> = {
|
|
5
|
+
themeBgColor?: string;
|
|
6
|
+
lightThemeBg?: string;
|
|
7
|
+
pillColor?: string;
|
|
5
8
|
textHighlight?: string;
|
|
6
9
|
dropdownOptions?: string[];
|
|
7
10
|
selectedDropdownOption?: string;
|
|
@@ -9,15 +12,19 @@ type SearchDatePickerInputProps<T extends object> = {
|
|
|
9
12
|
dropdownIconProp?: searchDropdownIconProps;
|
|
10
13
|
toggleStatus?: boolean;
|
|
11
14
|
setToggleStatus?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
|
-
themeBgColor?: string;
|
|
13
|
-
lightThemeBg?: string;
|
|
14
15
|
selectedDate?: Date;
|
|
15
|
-
onDateSelect?: (date: Date) => void;
|
|
16
|
+
onDateSelect?: (date: Date | undefined) => void;
|
|
16
17
|
selectedStartDate?: Date;
|
|
17
|
-
onStartDateSelect?: (date: Date) => void;
|
|
18
|
+
onStartDateSelect?: (date: Date | undefined) => void;
|
|
18
19
|
selectedEndDate?: Date;
|
|
19
|
-
onEndDateSelect?: (date: Date) => void;
|
|
20
|
+
onEndDateSelect?: (date: Date | undefined) => void;
|
|
21
|
+
searchItems?: string[];
|
|
22
|
+
setSearchItems?: React.Dispatch<React.SetStateAction<string[]>>;
|
|
20
23
|
handleFilter?: () => void;
|
|
24
|
+
setSearchCriteria?: React.Dispatch<React.SetStateAction<any[]>>;
|
|
25
|
+
column?: any;
|
|
26
|
+
setEditingHeader?: React.Dispatch<React.SetStateAction<any>>;
|
|
27
|
+
localStorageKey?: string;
|
|
21
28
|
};
|
|
22
|
-
declare function SearchDatePickerInput<T extends object>({ textHighlight, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, dropdownIconProp, toggleStatus, setToggleStatus,
|
|
29
|
+
declare function SearchDatePickerInput<T extends object>({ themeBgColor, lightThemeBg, pillColor, textHighlight, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, dropdownIconProp, toggleStatus, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, searchItems, setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey, }: SearchDatePickerInputProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
23
30
|
export default SearchDatePickerInput;
|
|
@@ -5,68 +5,204 @@ import "react-day-picker/dist/style.css";
|
|
|
5
5
|
import Dropdown from "../Dropdown/Dropdown";
|
|
6
6
|
import ToggleButton from "../ToggleButton/ToggleButton";
|
|
7
7
|
import BaseButton from "../BaseButton";
|
|
8
|
-
|
|
8
|
+
import Badge from "../Badge/Badge";
|
|
9
|
+
import Text from "../Text";
|
|
10
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
11
|
+
/**
|
|
12
|
+
* A helper to convert a Date object to 'YYYY-MM-DD'
|
|
13
|
+
* so we don't get slashes in the final string.
|
|
14
|
+
*/
|
|
15
|
+
function formatAsYMD(date) {
|
|
16
|
+
if (!date)
|
|
17
|
+
return "";
|
|
18
|
+
// date.toISOString() is 'YYYY-MM-DDTHH:mm:ss.sssZ'
|
|
19
|
+
// slice(0,10) => 'YYYY-MM-DD'
|
|
20
|
+
return date.toISOString().slice(0, 10);
|
|
21
|
+
}
|
|
22
|
+
function SearchDatePickerInput({
|
|
23
|
+
// theming
|
|
24
|
+
themeBgColor = "bg-sky-500", lightThemeBg = "bg-sky-100",
|
|
25
|
+
// style/config
|
|
26
|
+
pillColor = "bg-sky-500", textHighlight = "text-sky-700", dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, dropdownIconProp = {
|
|
9
27
|
iconClasses: "text-sky-500",
|
|
10
28
|
name: "chevronDown",
|
|
11
29
|
weight: "solid",
|
|
12
|
-
},
|
|
30
|
+
},
|
|
31
|
+
// toggle
|
|
32
|
+
toggleStatus = false, setToggleStatus,
|
|
33
|
+
// single date
|
|
34
|
+
selectedDate, onDateSelect,
|
|
35
|
+
// range
|
|
36
|
+
selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect,
|
|
37
|
+
// local-storage logic
|
|
38
|
+
searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey = "searchCriteria", }) {
|
|
13
39
|
const containerRef = useRef(null);
|
|
14
|
-
// Remove internal state for the date values (they come from props)
|
|
15
|
-
// Internal UI state for showing the calendar and active input remains:
|
|
16
40
|
const [isDatePickerOpen, setIsDatePickerOpen] = useState(false);
|
|
17
41
|
const [activeInput, setActiveInput] = useState(null);
|
|
42
|
+
const canStore = !!column?.id && !!setSearchCriteria;
|
|
43
|
+
// On mount: load existing filter for this column (the FIRST one we find)
|
|
18
44
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
45
|
+
if (!canStore)
|
|
46
|
+
return;
|
|
47
|
+
const stored = localStorage.getItem(localStorageKey);
|
|
48
|
+
if (stored) {
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(stored);
|
|
51
|
+
const existing = parsed.find((criterion) => criterion.searchColumn.id === column.id);
|
|
52
|
+
if (existing && setSearchItems) {
|
|
53
|
+
// e.g. "2025-02-27" or "2024-12-01 - 2024-12-28"
|
|
54
|
+
setSearchItems([existing.submittedSearchText]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
console.error("Error reading stored date filter:", err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [canStore, column?.id, localStorageKey, setSearchItems]);
|
|
62
|
+
// Close date pickers on outside click
|
|
22
63
|
useEffect(() => {
|
|
23
|
-
function handleClickOutside(
|
|
64
|
+
function handleClickOutside(e) {
|
|
24
65
|
if (containerRef.current &&
|
|
25
|
-
!containerRef.current.contains(
|
|
66
|
+
!containerRef.current.contains(e.target)) {
|
|
26
67
|
setIsDatePickerOpen(false);
|
|
27
68
|
setActiveInput(null);
|
|
28
69
|
}
|
|
29
70
|
}
|
|
30
71
|
document.addEventListener("mousedown", handleClickOutside);
|
|
31
|
-
return () =>
|
|
32
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
33
|
-
};
|
|
72
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
34
73
|
}, []);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
74
|
+
const updateLocalStorage = (criteria) => {
|
|
75
|
+
localStorage.setItem(localStorageKey, JSON.stringify(criteria));
|
|
76
|
+
};
|
|
77
|
+
// removing a date "badge"
|
|
78
|
+
const handleSearchBadgeClick = (item) => {
|
|
79
|
+
const newSearchItems = searchItems.filter((x) => x !== item);
|
|
80
|
+
setSearchItems?.(newSearchItems);
|
|
81
|
+
if (canStore) {
|
|
82
|
+
setSearchCriteria?.((prev) => {
|
|
83
|
+
const newCriteria = prev.filter((crit) => crit.submittedSearchText !== item);
|
|
84
|
+
updateLocalStorage(newCriteria);
|
|
85
|
+
return newCriteria;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Build a string in 'YYYY-MM-DD' (or range) format,
|
|
91
|
+
* so it won't break in your URL as "mm%2Fdd%2Fyyyy"
|
|
92
|
+
*/
|
|
93
|
+
const buildDateString = () => {
|
|
94
|
+
if (toggleStatus) {
|
|
95
|
+
// range mode
|
|
96
|
+
if (selectedStartDate && selectedEndDate) {
|
|
97
|
+
return `${formatAsYMD(selectedStartDate)} - ${formatAsYMD(selectedEndDate)}`;
|
|
98
|
+
}
|
|
99
|
+
else if (selectedStartDate) {
|
|
100
|
+
return `Start: ${formatAsYMD(selectedStartDate)}`;
|
|
101
|
+
}
|
|
102
|
+
else if (selectedEndDate) {
|
|
103
|
+
return `End: ${formatAsYMD(selectedEndDate)}`;
|
|
104
|
+
}
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// single-date mode
|
|
109
|
+
return selectedDate ? formatAsYMD(selectedDate) : "";
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* If empty => remove all queries for col
|
|
114
|
+
* If non-empty => APPEND
|
|
115
|
+
* (do NOT filter out old queries for that column)
|
|
116
|
+
*
|
|
117
|
+
* But now the stored string is "YYYY-MM-DD" or "YYYY-MM-DD - YYYY-MM-DD"
|
|
118
|
+
*/
|
|
119
|
+
const handleFilterClick = () => {
|
|
120
|
+
const dateString = buildDateString().trim();
|
|
121
|
+
if (!dateString) {
|
|
122
|
+
// remove existing for col
|
|
123
|
+
if (canStore) {
|
|
124
|
+
setSearchCriteria?.((prev) => {
|
|
125
|
+
const newCriteria = prev.filter((c) => c.searchColumn.id !== column.id);
|
|
126
|
+
updateLocalStorage(newCriteria);
|
|
127
|
+
return newCriteria;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// append
|
|
133
|
+
if (!searchItems.includes(dateString)) {
|
|
134
|
+
setSearchItems?.([...searchItems, dateString]);
|
|
135
|
+
}
|
|
136
|
+
if (canStore) {
|
|
137
|
+
setSearchCriteria?.((prev) => {
|
|
138
|
+
const newCriteria = [
|
|
139
|
+
...prev,
|
|
140
|
+
{
|
|
141
|
+
searchColumn: column,
|
|
142
|
+
submittedSearchText: dateString,
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
updateLocalStorage(newCriteria);
|
|
146
|
+
return newCriteria;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
setEditingHeader?.(null);
|
|
151
|
+
handleFilter?.();
|
|
39
152
|
setIsDatePickerOpen(false);
|
|
40
153
|
setActiveInput(null);
|
|
41
|
-
handleFilter();
|
|
42
154
|
};
|
|
155
|
+
// DayPicker styling
|
|
43
156
|
const modifiersClassNames = {
|
|
44
157
|
selected: `${themeBgColor} text-white rounded-full`,
|
|
45
158
|
today: `${lightThemeBg} ${textHighlight}`,
|
|
46
159
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
160
|
+
// open date pickers
|
|
161
|
+
const openStartPicker = () => {
|
|
162
|
+
setIsDatePickerOpen(true);
|
|
163
|
+
setActiveInput("start");
|
|
164
|
+
};
|
|
165
|
+
const openEndPicker = () => {
|
|
166
|
+
setIsDatePickerOpen(true);
|
|
167
|
+
setActiveInput("end");
|
|
168
|
+
};
|
|
169
|
+
const openSinglePicker = () => {
|
|
170
|
+
setActiveInput(null);
|
|
171
|
+
setIsDatePickerOpen((prev) => !prev);
|
|
172
|
+
};
|
|
173
|
+
return (_jsxs("div", { ref: containerRef, className: "relative w-[425px] border-2 p-4", children: [_jsx("div", { className: "flex items-center justify-between h-12 mb-2", children: toggleStatus ? (
|
|
174
|
+
// Range mode
|
|
175
|
+
_jsxs("div", { className: "flex items-center w-full", children: [_jsx("button", { onClick: openStartPicker, className: "border-2 px-3 py-2 flex-1 h-10 text-left", children: selectedStartDate
|
|
176
|
+
? formatAsYMD(selectedStartDate)
|
|
177
|
+
: "Start Date" }), _jsx("span", { className: "mx-2", children: "to" }), _jsx("button", { onClick: openEndPicker, className: "border-2 px-3 py-2 flex-1 h-10 text-left", children: selectedEndDate
|
|
178
|
+
? formatAsYMD(selectedEndDate)
|
|
53
179
|
: "End Date" })] })) : (
|
|
54
|
-
//
|
|
55
|
-
_jsxs(_Fragment, { children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 h-full flex items-center", menuClasses: "bg-white min-w-[150px] top-[-8px] left-[-2px]", dropdownClasses: "border-2 border-r-0 flex-[1] h-10 w-auto", icon: dropdownIconProp }), _jsx("button", { onClick:
|
|
56
|
-
? selectedDate
|
|
180
|
+
// Single-date mode
|
|
181
|
+
_jsxs(_Fragment, { children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 h-full flex items-center", menuClasses: "bg-white min-w-[150px] top-[-8px] left-[-2px]", dropdownClasses: "border-2 border-r-0 flex-[1] h-10 w-auto", icon: dropdownIconProp }), _jsx("button", { onClick: openSinglePicker, className: "border-2 px-3 py-2 flex-[2] h-10 text-left min-w-40", children: selectedDate
|
|
182
|
+
? formatAsYMD(selectedDate)
|
|
57
183
|
: "Select Date" })] })) }), toggleStatus
|
|
58
|
-
? activeInput && (_jsx("div", { className: "absolute p-4 top-16 w-auto z-50 shadow-lg bg-white", children: activeInput === "start" ? (_jsx(DayPicker, { mode: "single", selected: selectedStartDate, onSelect: (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
setActiveInput(null);
|
|
62
|
-
}, modifiersClassNames: modifiersClassNames })) : (_jsx(DayPicker, { mode: "single", selected: selectedEndDate, onSelect: (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
setActiveInput(null);
|
|
184
|
+
? activeInput && (_jsx("div", { className: "absolute p-4 top-16 w-auto z-50 shadow-lg bg-white", children: activeInput === "start" ? (_jsx(DayPicker, { mode: "single", selected: selectedStartDate, onSelect: (day) => {
|
|
185
|
+
onStartDateSelect?.(day || undefined);
|
|
186
|
+
setIsDatePickerOpen(false);
|
|
187
|
+
setActiveInput(null);
|
|
188
|
+
}, modifiersClassNames: modifiersClassNames })) : (_jsx(DayPicker, { mode: "single", selected: selectedEndDate, onSelect: (day) => {
|
|
189
|
+
onEndDateSelect?.(day || undefined);
|
|
190
|
+
setIsDatePickerOpen(false);
|
|
191
|
+
setActiveInput(null);
|
|
66
192
|
}, modifiersClassNames: modifiersClassNames })) }))
|
|
67
|
-
: isDatePickerOpen && (_jsx("div", { className: "absolute p-4 top-16 w-auto z-50 shadow-lg bg-white", children: _jsx(DayPicker, { mode: "single", selected: selectedDate, onSelect: (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
193
|
+
: isDatePickerOpen && (_jsx("div", { className: "absolute p-4 top-16 w-auto z-50 shadow-lg bg-white", children: _jsx(DayPicker, { mode: "single", selected: selectedDate, onSelect: (day) => {
|
|
194
|
+
onDateSelect?.(day || undefined);
|
|
195
|
+
}, modifiersClassNames: modifiersClassNames }) })), searchItems?.length ? (_jsx("div", { className: "flex flex-wrap bg-white py-2 px-2 mt-2 rounded-md", children: searchItems.map((item, index) => (_jsx(Badge, { backgroundColor: pillColor, borderRadius: "rounded-full", hasRightIcon: true, icon: _jsx("div", { className: "text-white text-xxs", children: getFontAwesomeIcon("xmark", "solid") }), iconSize: "text-sm", mobileIconLabel: item, onClick: () => {
|
|
196
|
+
const newSearchItems = searchItems.filter((x) => x !== item);
|
|
197
|
+
setSearchItems?.(newSearchItems);
|
|
198
|
+
if (canStore) {
|
|
199
|
+
setSearchCriteria?.((prev) => {
|
|
200
|
+
const filtered = prev.filter((crit) => crit.submittedSearchText !==
|
|
201
|
+
item);
|
|
202
|
+
updateLocalStorage(filtered);
|
|
203
|
+
return filtered;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}, text: _jsx(Text, { color: "text-white", fontFamily: "font-serif", size: "text-sm", tag: "span", text: item }), badgeContainerClasses: `${pillColor} p-1 max-w-fit min-w-20 rounded-full flex justify-between items-center text-white text-xs px-4 border-none mr-4 mb-1`, type: "span" }, index))) })) : null, _jsxs("div", { className: "flex justify-between items-end bg-white px-2 rounded-md mt-4", 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" })] })] }));
|
|
71
207
|
}
|
|
72
208
|
export default SearchDatePickerInput;
|