@agilant/toga-blox 1.0.138 → 1.0.140
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/SearchInput.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.js +3 -3
- package/dist/components/SearchInput/SearchInput.stories.js +3 -0
- package/dist/components/SearchInput/SearchInput.types.d.ts +3 -0
- package/dist/components/SearchInput/SearchInputDatePicker.d.ts +4 -1
- package/dist/components/SearchInput/SearchInputDatePicker.js +3 -3
- package/dist/components/SearchInput/SearchNumberInput.d.ts +4 -1
- package/dist/components/SearchInput/SearchNumberInput.js +4 -4
- package/dist/components/TableRow/TableRow.d.ts +22 -2
- package/dist/components/TableRow/TableRow.js +27 -4
- package/dist/components/TableRow/TableRow.stories.js +2 -1
- package/dist/components/ToggleButton/ToggleButton.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SearchInputProps } from "./SearchInput.types";
|
|
2
|
-
declare const SearchInput: <T extends object>({ textHighlight, inputType, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean, toggleColor, toggleTextColor, fontFamily, removePattern, isSearchable, hasOperator, tooltipText, hoverBgColor, clearTextHoverColor, numberTypeIcon, firstIconTop, inactiveCircleColor, activeCircleColor, placeHolderColor, buttonPlaceHolderTextColor, }: SearchInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const SearchInput: <T extends object>({ textHighlight, inputType, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean, toggleColor, toggleTextColor, fontFamily, removePattern, isSearchable, hasOperator, tooltipText, hoverBgColor, clearTextHoverColor, numberTypeIcon, firstIconTop, inactiveCircleColor, activeCircleColor, placeHolderColor, buttonPlaceHolderTextColor, inactiveColorBackground, inactiveColorBorder, activeColorBorder, }: SearchInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default SearchInput;
|
|
@@ -8,7 +8,7 @@ const SearchInput = ({ textHighlight = "text-sky-500", inputType = "text", dropd
|
|
|
8
8
|
name: "chevronDown",
|
|
9
9
|
weight: "bold",
|
|
10
10
|
iconClasses: "text-black",
|
|
11
|
-
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus = false, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean = false, toggleColor = "bg-sky-500", toggleTextColor = "text-black", fontFamily, removePattern = /^[^:]*:/, isSearchable = false, hasOperator = false, tooltipText = "Clear filters to edit operator", hoverBgColor, clearTextHoverColor, numberTypeIcon, firstIconTop, inactiveCircleColor, activeCircleColor, placeHolderColor, buttonPlaceHolderTextColor = "text-red-500", }) => {
|
|
11
|
+
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus = false, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, onChange, selectedValue, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, handleFilter, column, setSearchCriteria, setEditingHeader, pillColor, firstIconClasses, dataPickerThemeColor, dataPickerThemeColorAccent, isBoolean = false, toggleColor = "bg-sky-500", toggleTextColor = "text-black", fontFamily, removePattern = /^[^:]*:/, isSearchable = false, hasOperator = false, tooltipText = "Clear filters to edit operator", hoverBgColor, clearTextHoverColor, numberTypeIcon, firstIconTop, inactiveCircleColor, activeCircleColor = "peer-checked:after:bg-purple-500", placeHolderColor, buttonPlaceHolderTextColor = "text-red-500", inactiveColorBackground = "bg-purple-300", inactiveColorBorder = "border-purple-300", activeColorBorder = "border-orange-900", }) => {
|
|
12
12
|
const containerRef = useRef(null);
|
|
13
13
|
const inputRef = useRef(null);
|
|
14
14
|
useEffect(() => {
|
|
@@ -19,11 +19,11 @@ const SearchInput = ({ textHighlight = "text-sky-500", inputType = "text", dropd
|
|
|
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, fontFamily: fontFamily, removePattern: removePattern, textHighlight: textHighlight, hasOperator: hasOperator, tooltipText: tooltipText }));
|
|
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, setSearchCriteria: setSearchCriteria, column: column, themeBgColor: dataPickerThemeColor, toggleColor: toggleColor, toggleTextColor: toggleTextColor, searchItems: searchItems, setSearchItems: setSearchItems, removePattern: removePattern, pillColor: pillColor, hasOperator: hasOperator, tooltipText: tooltipText, numberTypeIcon: numberTypeIcon, firstIconTop: firstIconTop, inactiveCircleColor: inactiveCircleColor, activeCircleColor: activeCircleColor, placeHolderColor: placeHolderColor }));
|
|
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, themeBgColor: dataPickerThemeColor, toggleColor: toggleColor, toggleTextColor: toggleTextColor, searchItems: searchItems, setSearchItems: setSearchItems, removePattern: removePattern, pillColor: pillColor, hasOperator: hasOperator, tooltipText: tooltipText, numberTypeIcon: numberTypeIcon, firstIconTop: firstIconTop, inactiveCircleColor: inactiveCircleColor, activeCircleColor: activeCircleColor, placeHolderColor: placeHolderColor, inactiveColorBackground: inactiveColorBackground, inactiveColorBorder: activeColorBorder }));
|
|
23
23
|
case "multiSelect":
|
|
24
24
|
return (_jsx(SearchDropdownInput, { options: dropdownOptions, placeholder: "Search", additionalClasses: "", onChange: onChange, selectedValue: selectedValue, bgColor: dataPickerThemeColor, clearText: "Clear", clearTextColor: "text-sky-500", buttonText: "Filter", handleFilter: handleFilter, column: column, setSearchCriteria: setSearchCriteria, textHighlight: textHighlight, isBoolean: isBoolean, isSearchable: isSearchable, setSearchItems: setSearchItems, fontFamily: fontFamily, pillColor: pillColor, hoverBgColor: hoverBgColor, clearTextHoverColor: clearTextHoverColor }));
|
|
25
25
|
case "date":
|
|
26
|
-
return (_jsx(SearchDatePickerInput, { textHighlight: textHighlight, dropdownOptions: dropdownOptions, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, selectedDate: selectedDate, onDateSelect: onDateSelect, selectedStartDate: selectedStartDate, onStartDateSelect: onStartDateSelect, selectedEndDate: selectedEndDate, onEndDateSelect: onEndDateSelect, handleFilter: handleFilter, themeBgColor: dataPickerThemeColor, lightThemeBg: dataPickerThemeColorAccent, setSearchCriteria: setSearchCriteria, column: column, setEditingHeader: setEditingHeader, searchItems: searchItems, setSearchItems: setSearchItems, pillColor: pillColor, toggleColor: toggleColor, toggleTextColor: toggleTextColor, fontFamily: fontFamily, removePattern: removePattern, dropdownIconProp: dropdownIconProp, hasOperator: hasOperator, tooltipText: tooltipText, inactiveCircleColor: inactiveCircleColor, activeCircleColor: activeCircleColor, placeHolderColor: placeHolderColor, firstIconTop: firstIconTop, buttonPlaceHolderTextColor: buttonPlaceHolderTextColor }));
|
|
26
|
+
return (_jsx(SearchDatePickerInput, { textHighlight: textHighlight, dropdownOptions: dropdownOptions, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, selectedDate: selectedDate, onDateSelect: onDateSelect, selectedStartDate: selectedStartDate, onStartDateSelect: onStartDateSelect, selectedEndDate: selectedEndDate, onEndDateSelect: onEndDateSelect, handleFilter: handleFilter, themeBgColor: dataPickerThemeColor, lightThemeBg: dataPickerThemeColorAccent, setSearchCriteria: setSearchCriteria, column: column, setEditingHeader: setEditingHeader, searchItems: searchItems, setSearchItems: setSearchItems, pillColor: pillColor, toggleColor: toggleColor, toggleTextColor: toggleTextColor, fontFamily: fontFamily, removePattern: removePattern, dropdownIconProp: dropdownIconProp, hasOperator: hasOperator, tooltipText: tooltipText, inactiveCircleColor: inactiveCircleColor, activeCircleColor: activeCircleColor, placeHolderColor: placeHolderColor, firstIconTop: firstIconTop, buttonPlaceHolderTextColor: buttonPlaceHolderTextColor, inactiveColorBackground: inactiveColorBackground, inactiveColorBorder: inactiveColorBorder, activeColorBorder: activeColorBorder }));
|
|
27
27
|
default:
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
@@ -214,4 +214,7 @@ DatePickerInput.args = {
|
|
|
214
214
|
toggleTextColor: "text-green-500",
|
|
215
215
|
toggleColor: "bg-green-500",
|
|
216
216
|
column: { id: "dateColumn" },
|
|
217
|
+
activeCircleColor: "peer-checked:after:bg-purple-500",
|
|
218
|
+
inactiveCircleColor: "after:bg-purple-300",
|
|
219
|
+
activeColorBorder: "border-purple-500",
|
|
217
220
|
};
|
|
@@ -61,6 +61,9 @@ export type SearchInputProps<T extends object> = {
|
|
|
61
61
|
inactiveCircleColor?: string;
|
|
62
62
|
placeHolderColor?: string;
|
|
63
63
|
buttonPlaceHolderTextColor?: string;
|
|
64
|
+
inactiveColorBackground?: string;
|
|
65
|
+
inactiveColorBorder?: string;
|
|
66
|
+
activeColorBorder?: string;
|
|
64
67
|
};
|
|
65
68
|
export interface OptionType {
|
|
66
69
|
uuid: string;
|
|
@@ -39,6 +39,9 @@ export interface SearchDatePickerInputProps<T extends object> {
|
|
|
39
39
|
placeHolderColor?: string;
|
|
40
40
|
firstIconTop?: string;
|
|
41
41
|
buttonPlaceHolderTextColor?: string;
|
|
42
|
+
inactiveColorBorder?: string;
|
|
43
|
+
inactiveColorBackground?: string;
|
|
44
|
+
activeColorBorder?: string;
|
|
42
45
|
}
|
|
43
|
-
declare function SearchDatePickerInput<T extends object>({ themeBgColor, lightThemeBg, pillColor, textHighlight, dropdownOptions, dropdownIconProp, toggleStatus, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, selectedDropdownOption, onDropdownOptionSelect, buttonText, buttonColor, searchItems, setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey, toggleColor, toggleTextColor, fontFamily, removePattern, hasOperator, tooltipText, inactiveCircleColor, activeCircleColor, placeHolderColor, firstIconTop, buttonPlaceHolderTextColor, }: SearchDatePickerInputProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
declare function SearchDatePickerInput<T extends object>({ themeBgColor, lightThemeBg, pillColor, textHighlight, dropdownOptions, dropdownIconProp, toggleStatus, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, selectedDropdownOption, onDropdownOptionSelect, buttonText, buttonColor, searchItems, setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey, toggleColor, toggleTextColor, fontFamily, removePattern, hasOperator, tooltipText, inactiveCircleColor, activeCircleColor, placeHolderColor, firstIconTop, buttonPlaceHolderTextColor, inactiveColorBorder, inactiveColorBackground, activeColorBorder, }: SearchDatePickerInputProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
44
47
|
export default SearchDatePickerInput;
|
|
@@ -66,7 +66,7 @@ function SearchDatePickerInput({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
|
|
|
66
66
|
iconClasses: "text-sky-500",
|
|
67
67
|
name: "chevronDown",
|
|
68
68
|
weight: "solid",
|
|
69
|
-
}, toggleStatus = false, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, selectedDropdownOption, onDropdownOptionSelect, buttonText = "Filter", buttonColor, searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey = "searchCriteria", toggleColor = "bg-sky-500", toggleTextColor = "text-black", fontFamily, removePattern, hasOperator, tooltipText, inactiveCircleColor = "after:bg-red-300", activeCircleColor = "peer-checked:after:bg-red-500 border-red-500", placeHolderColor, firstIconTop, buttonPlaceHolderTextColor, }) {
|
|
69
|
+
}, toggleStatus = false, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, selectedDropdownOption, onDropdownOptionSelect, buttonText = "Filter", buttonColor, searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, localStorageKey = "searchCriteria", toggleColor = "bg-sky-500", toggleTextColor = "text-black", fontFamily, removePattern, hasOperator, tooltipText, inactiveCircleColor = "after:bg-red-300", activeCircleColor = "peer-checked:after:bg-red-500 border-red-500", placeHolderColor, firstIconTop, buttonPlaceHolderTextColor, inactiveColorBorder, inactiveColorBackground, activeColorBorder, }) {
|
|
70
70
|
const containerRef = useRef(null);
|
|
71
71
|
// Local operator state.
|
|
72
72
|
const [localOperator, setLocalOperator] = useState(() => {
|
|
@@ -343,7 +343,7 @@ function SearchDatePickerInput({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
|
|
|
343
343
|
setIsDatePickerOpen(false);
|
|
344
344
|
setActiveInput(null);
|
|
345
345
|
}
|
|
346
|
-
}, firstIcon: getFontAwesomeIcon("calendar", "regular"), required: false, additionalClasses: "border-2 px-3 py-2 flex-
|
|
346
|
+
}, firstIcon: getFontAwesomeIcon("calendar", "regular"), required: false, additionalClasses: "border-2 px-3 py-2 flex-auto h-10 text-left rounded-r", hasAutoFocus: true, firstIconTop: firstIconTop, placeHolderColor: placeHolderColor }) })) : (_jsx(_Fragment, { children: _jsxs("button", { onClick: openSinglePicker, className: `${buttonPlaceHolderTextColor} border-2 px-3 py-2 flex-auto h-10 text-left rounded-r`, children: [_jsx("span", { className: "pr-2", children: getFontAwesomeIcon("calendar", "regular") }), localDate
|
|
347
347
|
? formatDateAsMonthDayYear(localDate)
|
|
348
348
|
: "mm/dd/yyyy"] }) }))] })) }), dayPicker, searchItems?.length ? (_jsx("div", { className: "flex flex-wrap bg-white py-2 px-2 mt-2 rounded-md", children: searchItems.map((item, index) => {
|
|
349
349
|
const cleanedText = getCleanedText(item, removePattern);
|
|
@@ -357,6 +357,6 @@ function SearchDatePickerInput({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
|
|
|
357
357
|
return filtered;
|
|
358
358
|
});
|
|
359
359
|
}, text: _jsx(Text, { color: "text-white", size: "text-sm", tag: "span", text: cleanedText }), 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));
|
|
360
|
-
}) })) : 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: toggleColor, activeColorBorder:
|
|
360
|
+
}) })) : 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: toggleColor, activeColorBorder: activeColorBorder, activeLabel: "Range", activeTextColor: toggleTextColor, additionalClasses: "flex items-center", inactiveColorBackground: inactiveColorBackground, inactiveColorBorder: inactiveColorBorder, inactiveLabel: "Range", inactiveTextColor: "text-gray-500", pillHeight: "h-8", textPosition: "right", textSize: "text-sm", smallToggle: true, borderStyle: true, inactiveCircleColor: inactiveCircleColor, activeCircleColor: activeCircleColor }), _jsx(BaseButton, { text: buttonText, backgroundColor: themeBgColor, additionalClasses: "py-0.5 px-6 text-white", borderColor: "border-none", onClick: handleFilterClick, shape: "rounded-full" })] })] }));
|
|
361
361
|
}
|
|
362
362
|
export default SearchDatePickerInput;
|
|
@@ -52,6 +52,9 @@ type SearchNumberInputProps<T extends object> = {
|
|
|
52
52
|
inactiveCircleColor: string;
|
|
53
53
|
activeCircleColor: string;
|
|
54
54
|
placeHolderColor?: string;
|
|
55
|
+
inactiveColorBorder?: string;
|
|
56
|
+
inactiveColorBackground?: string;
|
|
57
|
+
activeColorBorder?: string;
|
|
55
58
|
};
|
|
56
59
|
/**
|
|
57
60
|
* A numeric filter component that:
|
|
@@ -59,5 +62,5 @@ type SearchNumberInputProps<T extends object> = {
|
|
|
59
62
|
* 2. On Filter => either remove or store a string in localStorage
|
|
60
63
|
* 3. On mount => read any existing filter for this column, parse, and set min/max
|
|
61
64
|
*/
|
|
62
|
-
declare const SearchNumberInput: <T extends object>({ textHighlight, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, handleFilter, searchItems, setSearchItems, setSearchCriteria, column, setEditingHeader, localStorageKey, themeBgColor, toggleColor, toggleTextColor, pillColor, fontFamily, removePattern, hasOperator, tooltipText, numberTypeIcon, firstIconTop, inactiveCircleColor, activeCircleColor, placeHolderColor, }: SearchNumberInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
declare const SearchNumberInput: <T extends object>({ textHighlight, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, handleFilter, searchItems, setSearchItems, setSearchCriteria, column, setEditingHeader, localStorageKey, themeBgColor, toggleColor, toggleTextColor, pillColor, fontFamily, removePattern, hasOperator, tooltipText, numberTypeIcon, firstIconTop, inactiveCircleColor, activeCircleColor, placeHolderColor, inactiveColorBorder, inactiveColorBackground, activeColorBorder, }: SearchNumberInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
63
66
|
export default SearchNumberInput;
|
|
@@ -22,7 +22,7 @@ const SearchNumberInput = ({ textHighlight = "text-sky-500", dropdownIconProp =
|
|
|
22
22
|
weight: "solid",
|
|
23
23
|
}, dropdownOptions = [], selectedDropdownOption = { label: "", value: "" }, onDropdownOptionSelect, toggleStatus = false, setToggleStatus, minValue = "", setMinValue, maxValue = "", setMaxValue, handleFilter,
|
|
24
24
|
// local-storage
|
|
25
|
-
searchItems = [], setSearchItems, setSearchCriteria, column, setEditingHeader, localStorageKey = DEFAULT_STORAGE_KEY, themeBgColor = "bg-sky-500", toggleColor = "bg-sky-500", toggleTextColor = "text-black", pillColor, fontFamily, removePattern, hasOperator, tooltipText, numberTypeIcon = { icon: "x", weight: "regular" }, firstIconTop, inactiveCircleColor = "after:bg-gray-300", activeCircleColor = "peer-checked:after:bg-sky-500", placeHolderColor = "placeholder:text-gray-500", }) => {
|
|
25
|
+
searchItems = [], setSearchItems, setSearchCriteria, column, setEditingHeader, localStorageKey = DEFAULT_STORAGE_KEY, themeBgColor = "bg-sky-500", toggleColor = "bg-sky-500", toggleTextColor = "text-black", pillColor, fontFamily, removePattern, hasOperator, tooltipText, numberTypeIcon = { icon: "x", weight: "regular" }, firstIconTop, inactiveCircleColor = "after:bg-gray-300", activeCircleColor = "peer-checked:after:bg-sky-500", placeHolderColor = "placeholder:text-gray-500", inactiveColorBorder, inactiveColorBackground, activeColorBorder, }) => {
|
|
26
26
|
const containerRef = useRef(null);
|
|
27
27
|
const inputRef = useRef(null);
|
|
28
28
|
/** Decide if we can store for this column */
|
|
@@ -161,15 +161,15 @@ searchItems = [], setSearchItems, setSearchCriteria, column, setEditingHeader, l
|
|
|
161
161
|
return newCriteria;
|
|
162
162
|
});
|
|
163
163
|
};
|
|
164
|
-
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: "flex flex-col pt-4 p pb-1 border-2 border-navy-200 rounded-md", children: [_jsx("div", { className: `flex flex-[1] mx-4 ${toggleStatus ? "" : "border-2"}
|
|
164
|
+
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: "flex flex-col pt-4 p pb-1 border-2 border-navy-200 rounded-md", children: [_jsx("div", { className: `flex flex-[1] mx-4 rounded ${toggleStatus ? "" : "border-2"}
|
|
165
165
|
h-full max-h-11 items-center justify-around`, children: toggleStatus ? (_jsxs("div", { className: "flex items-center", 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 border-2 rounded", placeholder: "Min", placeHolderColor: placeHolderColor }), _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 rounded", placeholder: "Max", placeHolderColor: placeHolderColor })] })) : (
|
|
166
166
|
// Single value mode
|
|
167
167
|
_jsxs(_Fragment, { children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption || {
|
|
168
168
|
label: "",
|
|
169
169
|
value: "",
|
|
170
|
-
}, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 h-full flex items-center", menuClasses: "bg-white min-w-32xw rounded-md shadow-md top-12", dropdownClasses: "border-0 w-auto", icon: dropdownIconProp, isEnabled: !hasOperator, tooltipText: tooltipText }), _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 flex items-center", placeholder: "Amount", placeHolderColor: placeHolderColor, hasIcons: true, iconPosition: "both", firstIcon: numberTypeIcon?.icon ? (_jsx("div", { children: getFontAwesomeIcon(numberTypeIcon.icon, numberTypeIcon.weight) })) : null, firstIconTop: firstIconTop })] })) }),
|
|
170
|
+
}, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 h-full flex items-center", menuClasses: "bg-white min-w-32xw rounded-md shadow-md top-12", dropdownClasses: "border-0 w-auto", icon: dropdownIconProp, isEnabled: !hasOperator, tooltipText: tooltipText }), _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 flex items-center ", placeholder: "Amount", placeHolderColor: placeHolderColor, hasIcons: true, iconPosition: "both", firstIcon: numberTypeIcon?.icon ? (_jsx("div", { children: getFontAwesomeIcon(numberTypeIcon.icon, numberTypeIcon.weight) })) : null, firstIconTop: firstIconTop })] })) }), searchItems?.length ? (_jsx("div", { className: "py-2 ", children: _jsx("div", { className: "flex flex-wrap bg-white pt-2 px-4 rounded-md ", children: searchItems.map((item, index) => {
|
|
171
171
|
const cleanedText = getCleanedText(item, removePattern);
|
|
172
172
|
return (_jsx(Badge, { backgroundColor: pillColor, borderRadius: "rounded-full", hasRightIcon: true, icon: _jsx("div", { className: "text-white text-xxs", "data-testid": "item-clear-icon", children: getFontAwesomeIcon("xmark", "solid") }), iconSize: "text-sm", mobileIconLabel: item, onClick: () => handleSearchBadgeClick(item), text: _jsx(Text, { color: "text-white", fontFamily: fontFamily, size: "text-sm", tag: "span", text: cleanedText }), badgeContainerClasses: `${pillColor} cursor-pointer 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));
|
|
173
|
-
}) }) })) : null] }) }));
|
|
173
|
+
}) }) })) : null, _jsxs("div", { className: " flex flex-[1] justify-between items-end py-1 px-4 ", children: [_jsx(ToggleButton, { initialStatus: toggleStatus, onClick: () => setToggleStatus?.(!toggleStatus), activeColorBackground: toggleColor, activeColorBorder: activeColorBorder, activeLabel: "Range", activeTextColor: toggleTextColor, additionalClasses: "flex items-center", inactiveColorBackground: inactiveColorBackground, inactiveColorBorder: inactiveColorBorder, inactiveLabel: "Range", inactiveTextColor: "text-gray-500", pillHeight: "h-8", textPosition: "right", textSize: "text-sm", smallToggle: true, borderStyle: true, activeCircleColor: activeCircleColor, inactiveCircleColor: inactiveCircleColor }), _jsx(BaseButton, { text: "Filter", backgroundColor: themeBgColor, additionalClasses: "py-0.5 px-6 text-white", borderColor: "border-none", onClick: handleFilterClick, shape: "rounded-full" })] })] }) }));
|
|
174
174
|
};
|
|
175
175
|
export default SearchNumberInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
import { Row } from "react-table";
|
|
3
3
|
import { DataWithUUID } from "../TableCell";
|
|
4
4
|
/**
|
|
@@ -33,6 +33,26 @@ export interface TableRowProps<T extends DataWithUUID> {
|
|
|
33
33
|
onRowClick?: (index: number, rowUuid: string, event: React.MouseEvent<HTMLTableRowElement, MouseEvent>) => void;
|
|
34
34
|
/** Determines if this row should have an expandable drop down */
|
|
35
35
|
hasDropDown?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Optional function you can call on row click for making an API request (or any action).
|
|
38
|
+
* This might come directly from a custom hook or just be a function receiving rowUuid as a parameter.
|
|
39
|
+
*/
|
|
40
|
+
onFetchRowData?: (uuid: string) => Promise<void> | void;
|
|
41
|
+
/**
|
|
42
|
+
* Optional component or element to show when the row is loading data.
|
|
43
|
+
* Defaults to a simple `<span>Loading...</span>` if not provided.
|
|
44
|
+
*/
|
|
45
|
+
loadingIndicator?: ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Optional function that renders a custom error state. Receives the error object.
|
|
48
|
+
* If not provided, a default `<span>Error: {error.message}</span>` is shown.
|
|
49
|
+
*/
|
|
50
|
+
errorIndicator?: (error: Error) => ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Optional content to show when expanded (and there is no loading/error).
|
|
53
|
+
* Defaults to a simple `<span>drop down - {rowUuid}</span>` if not provided.
|
|
54
|
+
*/
|
|
55
|
+
expandedContent?: ReactNode;
|
|
36
56
|
}
|
|
37
|
-
declare const TableRow: <T extends DataWithUUID>({ row, prepareRow, activeIndex, globalTrimActive, rowUuid, columnInputs, activeRowColor, rowHoverClasses, onRowClick, hasDropDown, }: TableRowProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
declare const TableRow: <T extends DataWithUUID>({ row, prepareRow, activeIndex, globalTrimActive, rowUuid, columnInputs, activeRowColor, rowHoverClasses, onRowClick, hasDropDown, onFetchRowData, loadingIndicator, errorIndicator, expandedContent, }: TableRowProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
38
58
|
export default TableRow;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Fragment, useState } from "react";
|
|
3
3
|
import { motion, AnimatePresence } from "framer-motion";
|
|
4
4
|
import TableCell from "../TableCell";
|
|
5
|
-
const TableRow = ({ row, prepareRow, activeIndex, globalTrimActive, rowUuid, columnInputs, activeRowColor = "bg-pink-100", rowHoverClasses = "hover:bg-red-100 hover:cursor-pointer", onRowClick, hasDropDown = false, }) => {
|
|
5
|
+
const TableRow = ({ row, prepareRow, activeIndex, globalTrimActive, rowUuid, columnInputs, activeRowColor = "bg-pink-100", rowHoverClasses = "hover:bg-red-100 hover:cursor-pointer", onRowClick, hasDropDown = false, onFetchRowData, loadingIndicator, errorIndicator, expandedContent, }) => {
|
|
6
6
|
prepareRow(row);
|
|
7
7
|
const isActive = activeIndex === row.index;
|
|
8
8
|
let rowClasses = `border-primary`;
|
|
@@ -11,17 +11,40 @@ const TableRow = ({ row, prepareRow, activeIndex, globalTrimActive, rowUuid, col
|
|
|
11
11
|
}
|
|
12
12
|
// Local state for expansion, only used if hasDropDown is true.
|
|
13
13
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
14
|
-
|
|
14
|
+
// Optional local states to track loading/error from the API call
|
|
15
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
17
|
+
const handleRowClick = async (event) => {
|
|
15
18
|
onRowClick?.(row.index, rowUuid || "", event);
|
|
19
|
+
// If there's a dropdown, toggle it, and optionally call the API method
|
|
16
20
|
if (hasDropDown) {
|
|
17
21
|
setIsExpanded((prev) => !prev);
|
|
18
|
-
//
|
|
22
|
+
// If a fetch function is provided, call it with the rowUuid
|
|
23
|
+
if (onFetchRowData && rowUuid) {
|
|
24
|
+
try {
|
|
25
|
+
setIsLoading(true);
|
|
26
|
+
setError(null);
|
|
27
|
+
await onFetchRowData(rowUuid);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err instanceof Error) {
|
|
31
|
+
setError(err);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
setIsLoading(false);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
19
38
|
}
|
|
20
39
|
};
|
|
21
40
|
return (_jsxs(Fragment, { children: [_jsx("tr", { "data-testid": "table-row", className: `border-b border-b-navy-200 ${rowHoverClasses} ${rowClasses}`, ...(row.getRowProps ? row.getRowProps() : {}), onClick: handleRowClick, children: row.cells.map((cell, index) => {
|
|
22
41
|
const isLastCell = index === row.cells.length - 1;
|
|
23
42
|
const cellProps = cell.getCellProps();
|
|
24
43
|
return (_jsx(Fragment, { children: _jsx(TableCell, { cell: cell, rowUuid: rowUuid, globalTrimActive: globalTrimActive, columnInputs: columnInputs, isLastCell: isLastCell }) }, cellProps.key));
|
|
25
|
-
}) }, rowUuid), hasDropDown && (_jsx(AnimatePresence, { children: isExpanded && (_jsx("tr", { "data-testid": "expanded-row", children: _jsx("td", { colSpan: row.cells.length, className: "p-0", children: _jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.3 },
|
|
44
|
+
}) }, rowUuid), hasDropDown && (_jsx(AnimatePresence, { children: isExpanded && (_jsx("tr", { "data-testid": "expanded-row", children: _jsx("td", { colSpan: row.cells.length, className: "p-0", children: _jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.3 }, style: { display: "block" }, className: "overflow-hidden w-full", children: isLoading ? (loadingIndicator ?? (_jsx("span", { children: "Loading..." }))) : error ? (
|
|
45
|
+
// If there's an error, show the provided error indicator or default
|
|
46
|
+
errorIndicator ? (errorIndicator(error)) : (_jsxs("span", { className: "text-red-700", children: ["Error: ", error.message] }))) : (
|
|
47
|
+
// Otherwise, render the expanded content prop or fallback
|
|
48
|
+
expandedContent ?? (_jsxs("span", { children: ["drop down - ", rowUuid] }))) }, "expanded-dropdown-content") }) })) }))] }));
|
|
26
49
|
};
|
|
27
50
|
export default TableRow;
|
|
@@ -8,6 +8,7 @@ const sampleData = {
|
|
|
8
8
|
email: "john.doe@example.com",
|
|
9
9
|
phone: "+1 555-123-4567",
|
|
10
10
|
status: "Active",
|
|
11
|
+
expandedContent: (_jsx("div", { className: "size-96 bg-blue-300", children: "Custom element passed in - 12345" })),
|
|
11
12
|
};
|
|
12
13
|
const sampleData2 = {
|
|
13
14
|
uuid: "67890",
|
|
@@ -188,7 +189,7 @@ Default.parameters = {
|
|
|
188
189
|
},
|
|
189
190
|
},
|
|
190
191
|
};
|
|
191
|
-
export const MultipleRows = () => (_jsx("table", { children: _jsxs("tbody", { children: [_jsx(TableRow, { row: mockRow, prepareRow: prepareRow, globalTrimActive: true, rowUuid: sampleData.uuid, columnInputs: [], rowHoverClasses: "hover:bg-red-100 hover:cursor-pointer", hasDropDown: true }), _jsx(TableRow, { row: mockRow2, prepareRow: prepareRow, globalTrimActive: true, rowUuid: sampleData2.uuid, columnInputs: [], rowHoverClasses: "hover:bg-red-100 hover:cursor-pointer", hasDropDown: false })] }) }));
|
|
192
|
+
export const MultipleRows = () => (_jsx("table", { children: _jsxs("tbody", { children: [_jsx(TableRow, { row: mockRow, prepareRow: prepareRow, globalTrimActive: true, rowUuid: sampleData.uuid, columnInputs: [], rowHoverClasses: "hover:bg-red-100 hover:cursor-pointer", hasDropDown: true, expandedContent: _jsx("div", { className: "size-96 bg-blue-300", children: "Custom element passed in - 12345" }) }), _jsx(TableRow, { row: mockRow2, prepareRow: prepareRow, globalTrimActive: true, rowUuid: sampleData2.uuid, columnInputs: [], rowHoverClasses: "hover:bg-red-100 hover:cursor-pointer", hasDropDown: false })] }) }));
|
|
192
193
|
MultipleRows.parameters = {
|
|
193
194
|
docs: {
|
|
194
195
|
description: {
|
|
@@ -37,7 +37,7 @@ const ToggleButton = ({ initialStatus, onClick, id, textPosition, textSize,
|
|
|
37
37
|
// Background colors
|
|
38
38
|
activeColorBackground = "bg-red-600", inactiveColorBackground = "bg-red-200",
|
|
39
39
|
// Border colors (active is red and inactive is blue by default)
|
|
40
|
-
activeColorBorder = "border-
|
|
40
|
+
activeColorBorder = "border-orange-600", inactiveColorBorder = "border-red-600", activeLabel, inactiveLabel, additionalClasses, hasDisabledStatus, hasDivider, fontFamily, activeTextColor = "text-red-700", inactiveTextColor = "text-red-400", smallToggle, pillHeight, borderStyle, inactiveCircleColor = "after:bg-purple-300", activeCircleColor = "peer-checked:after:bg-purple-500", }) => {
|
|
41
41
|
const handleToggle = () => {
|
|
42
42
|
const newValue = !initialStatus;
|
|
43
43
|
onClick(newValue);
|