@agilant/toga-blox 1.0.144 → 1.0.146
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.
|
@@ -6,7 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
6
6
|
* A properly formed forwardRef component: exactly two parameters:
|
|
7
7
|
* (props, ref). We pass `ref` to the <input ref={ref} ...>.
|
|
8
8
|
*/
|
|
9
|
-
const InputField = forwardRef(function InputField({ label, placeholder, required, checked, id, name, type = "text", firstIcon, secondIcon, iconPosition = "before", iconColor = "primary", isValid = true, isReadOnly = false, onChange, value, readOnlyInfo = "", toolTipText = "", hasToolTip = false, additionalClasses = "", labelClasses = "", hasAutoFocus, onIconClick, onKeyDown, disabled, register, focusRingColor = "focus:ring-transparent", firstIconClasses, firstIconTop = "top-[8px]", placeHolderColor
|
|
9
|
+
const InputField = forwardRef(function InputField({ label, placeholder, required, checked, id, name, type = "text", firstIcon, secondIcon, iconPosition = "before", iconColor = "primary", isValid = true, isReadOnly = false, onChange, value, readOnlyInfo = "", toolTipText = "", hasToolTip = false, additionalClasses = "", labelClasses = "", hasAutoFocus, onIconClick, onKeyDown, disabled, register, focusRingColor = "focus:ring-transparent", firstIconClasses, firstIconTop = "top-[8px]", placeHolderColor, }, ref) {
|
|
10
10
|
const [isFocused, setIsFocused] = useState(false);
|
|
11
11
|
const hasValue = value != null && !!value.toString().trim();
|
|
12
12
|
const isNumberInput = type === "number";
|
|
@@ -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 = "peer-checked:after:bg-purple-500", placeHolderColor, buttonPlaceHolderTextColor = "text-
|
|
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 = "placeholder:text-green-500", buttonPlaceHolderTextColor = "text-purple-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(() => {
|
|
@@ -6,6 +6,7 @@ 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";
|
|
9
10
|
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
10
11
|
import updateLocalStorage from "../../utils/updateLocalStorage";
|
|
11
12
|
import { getCleanedText } from "../../utils/getCleanedText";
|
|
@@ -28,6 +29,24 @@ function formatDateAsMonthDayYear(date) {
|
|
|
28
29
|
const year = date.getFullYear();
|
|
29
30
|
return `${month}/${day}/${year}`;
|
|
30
31
|
}
|
|
32
|
+
function formatCleanedDateString(dateStr) {
|
|
33
|
+
if (!dateStr)
|
|
34
|
+
return "";
|
|
35
|
+
// Check if it's a range.
|
|
36
|
+
if (dateStr.includes(" - ")) {
|
|
37
|
+
const parts = dateStr.split(" - ").map((s) => s.trim());
|
|
38
|
+
const formattedParts = parts.map((part) => {
|
|
39
|
+
// Try to parse the date.
|
|
40
|
+
const parsed = parseUserDateInput(part);
|
|
41
|
+
return parsed ? formatDateAsMonthDayYear(parsed) : part;
|
|
42
|
+
});
|
|
43
|
+
return formattedParts.join(" - ");
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const parsed = parseUserDateInput(dateStr);
|
|
47
|
+
return parsed ? formatDateAsMonthDayYear(parsed) : dateStr;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
31
50
|
function formatDateAsYearMonthDay(date) {
|
|
32
51
|
if (!date)
|
|
33
52
|
return "";
|
|
@@ -327,7 +346,7 @@ function SearchDatePickerInput({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
|
|
|
327
346
|
setIsDatePickerOpen(false);
|
|
328
347
|
setActiveInput(null);
|
|
329
348
|
}
|
|
330
|
-
}, firstIcon: getFontAwesomeIcon("calendar", "regular"), required: false, firstIconTop: firstIconTop, additionalClasses: "border-2 px-3 py-2 flex-[2] h-10 text-left min-w-44 max-w-44 rounded", hasAutoFocus: true })) : (_jsxs("button", { onClick: openStartPicker, className: `${buttonPlaceHolderTextColor} border-2 px-3 py-2 flex-1 h-10 text-left min-w-44 max-w-44 rounded
|
|
349
|
+
}, firstIcon: getFontAwesomeIcon("calendar", "regular"), required: false, firstIconTop: firstIconTop, additionalClasses: "border-2 px-3 py-2 flex-[2] h-10 text-left min-w-44 max-w-44 rounded", hasAutoFocus: true })) : (_jsxs("button", { onClick: openStartPicker, className: `${buttonPlaceHolderTextColor} border-2 px-3 py-2 flex-1 h-10 text-left min-w-44 max-w-44 rounded `, children: [_jsx("span", { className: "pr-2", children: getFontAwesomeIcon("calendar", "regular") }), localStartDate
|
|
331
350
|
? formatDateAsMonthDayYear(localStartDate)
|
|
332
351
|
: "mm/dd/yyyy"] })), _jsx("span", { className: "mx-2", children: "to" }), activeInput === "end" ? (_jsx(Input, { type: "text", value: endDateInputValue, onChange: handleEndDateInputChange, placeholder: "mm/dd/yyy", placeHolderColor: placeHolderColor, onKeyDown: (e) => {
|
|
333
352
|
if (e.key === "Enter") {
|
|
@@ -343,27 +362,21 @@ function SearchDatePickerInput({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
|
|
|
343
362
|
}
|
|
344
363
|
}, firstIcon: getFontAwesomeIcon("calendar", "regular"), required: false, additionalClasses: "border-2 px-3 py-2 flex-auto h-10 text-left rounded-r min-w-52 max-w-52", 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 min-w-52 max-w-52 rounded-r`, children: [_jsx("span", { className: "pr-2", children: getFontAwesomeIcon("calendar", "regular") }), localDate
|
|
345
364
|
? formatDateAsMonthDayYear(localDate)
|
|
346
|
-
: "mm/dd/yyyy"] }) }))] })) }), dayPicker, searchItems.map((item, index) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
const formatted = `${month}/${day}/${year}`;
|
|
363
|
-
return formatted;
|
|
364
|
-
}
|
|
365
|
-
return cleanedText;
|
|
366
|
-
})(), 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));
|
|
367
|
-
}), _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" })] })] }));
|
|
365
|
+
: "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) => {
|
|
366
|
+
const cleanedText = getCleanedText(item, removePattern);
|
|
367
|
+
const formattedDate = formatCleanedDateString(cleanedText);
|
|
368
|
+
return (_jsx(Badge, { backgroundColor: pillColor, borderRadius: "rounded-full", hasRightIcon: true, icon: _jsx("div", { className: "text-white text-xxs", children: getFontAwesomeIcon("xmark", "solid") }), iconSize: "text-sm", onClick: () => {
|
|
369
|
+
const newSearchItems = searchItems.filter((it) => it !== item);
|
|
370
|
+
setSearchItems?.(newSearchItems);
|
|
371
|
+
setSearchCriteria?.((prev) => {
|
|
372
|
+
const filtered = prev.filter((crit) => crit.submittedSearchText !==
|
|
373
|
+
item);
|
|
374
|
+
updateLocalStorage(filtered, localStorageKey);
|
|
375
|
+
return filtered;
|
|
376
|
+
});
|
|
377
|
+
}, text: _jsx(Text, { color: "text-white", size: "text-sm", tag: "span", text: formattedDate
|
|
378
|
+
? formattedDate
|
|
379
|
+
: "mm/dd/yyyy" }), 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));
|
|
380
|
+
}) })) : 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" })] })] }));
|
|
368
381
|
}
|
|
369
382
|
export default SearchDatePickerInput;
|