@agilant/toga-blox 1.0.84 → 1.0.85

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.
@@ -5,13 +5,11 @@ const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange
5
5
  text: "Select...",
6
6
  icon: "",
7
7
  iconStyle: "regular",
8
- }, isSearchable = true, isOpen, hasSelectAll = false, disabled = false, isLoading = false, onMenuToggle, overrideStrings, className, width = "w-72", otherProps, }) => {
9
- // Convert your OptionType to the shape expected by react-multi-select-component.
8
+ }, isSearchable = true, isOpen, hasSelectAll = false, disabled = false, isLoading = false, onMenuToggle, overrideStrings, className, width = "w-72", isBoolean = false, otherProps, }) => {
10
9
  const multiSelectOptions = options.map((option) => ({
11
10
  label: option.name,
12
11
  value: option.value,
13
12
  }));
14
- // Convert the currently selected value(s) to the shape expected by the component.
15
13
  const multiSelectValue = selectedValue.map((item) => ({
16
14
  label: item.name,
17
15
  value: item.value,
@@ -22,27 +20,23 @@ const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange
22
20
  ? getFontAwesomeIcon(placeholder.icon)
23
21
  : null, placeholder?.text] }));
24
22
  }
25
- // If user selected ALL possible options, show "All items selected"
26
23
  if (selected.length === multiSelectOptions.length) {
27
- ``;
28
24
  return "All items selected";
29
25
  }
30
- // Default behavior: comma-separated labels
31
26
  return selected.map((s) => s.label).join(", ");
32
27
  };
33
- return (_jsx("div", { className: `${width}`, children: _jsx(MultiSelect, { id: id, name: name, className: className, options: multiSelectOptions, value: multiSelectValue, onChange: (selectedOptions) => {
34
- // Convert back to OptionType when passing to onChange
35
- const mapped = selectedOptions.map((opt) => ({
36
- name: opt.label,
37
- value: opt.value,
38
- }));
39
- onChange(mapped);
40
- },
41
- // Toggle search based on isSearchable
42
- disableSearch: !isSearchable,
43
- // Additional props from react-multi-select-component
44
- isOpen: isOpen, hasSelectAll: hasSelectAll, disabled: disabled, isLoading: isLoading, onMenuToggle: onMenuToggle, overrideStrings: {
45
- // selectSomeItems: placeholder,
28
+ const handleSelectionChange = (selectedOptions) => {
29
+ let finalSelection = selectedOptions;
30
+ if (isBoolean && selectedOptions.length > 0) {
31
+ finalSelection = [selectedOptions[selectedOptions.length - 1]];
32
+ }
33
+ const mapped = finalSelection.map((opt) => ({
34
+ name: opt.label,
35
+ value: opt.value,
36
+ }));
37
+ onChange(mapped);
38
+ };
39
+ return (_jsx("div", { className: width, children: _jsx(MultiSelect, { id: id, name: name, className: className, options: multiSelectOptions, value: multiSelectValue, onChange: handleSelectionChange, disableSearch: !isSearchable || isBoolean, isOpen: isOpen, hasSelectAll: hasSelectAll, disabled: disabled, isLoading: isLoading, onMenuToggle: onMenuToggle, overrideStrings: {
46
40
  ...overrideStrings,
47
41
  }, labelledBy: "Select", valueRenderer: valueRenderer, ...otherProps }) }));
48
42
  };
@@ -28,5 +28,6 @@ export interface MultiSelectInputProps {
28
28
  }>;
29
29
  className?: string;
30
30
  width?: string;
31
+ isBoolean?: boolean;
31
32
  otherProps?: any;
32
33
  }
@@ -26,6 +26,7 @@ interface SearchDropdownInputProps {
26
26
  clearTextColor?: string;
27
27
  buttonText?: string;
28
28
  buttonColor?: string;
29
+ isBoolean?: boolean;
29
30
  }
30
31
  declare const SearchDropdownInput: React.FC<SearchDropdownInputProps>;
31
32
  export default SearchDropdownInput;
@@ -3,7 +3,7 @@ import { useEffect } from "react";
3
3
  import MultiSelectInput from "../MultiSelect/MultiSelect";
4
4
  import updateLocalStorage from "../../utils/updateLocalStorage";
5
5
  const DEFAULT_STORAGE_KEY = "searchCriteria";
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, clearText = "Clear", clearTextColor = "text-sky-500", buttonText = "Filter", buttonColor = "bg-sky-500", localStorageKey = DEFAULT_STORAGE_KEY, ...rest }) => {
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, clearText = "Clear", clearTextColor = "text-sky-500", buttonText = "Filter", buttonColor = "bg-sky-500", localStorageKey = DEFAULT_STORAGE_KEY, isBoolean = false, ...rest }) => {
7
7
  // Are we able to store filters for this column?
8
8
  const canStore = !!column?.id && !!setSearchCriteria;
9
9
  useEffect(() => {
@@ -112,9 +112,9 @@ const SearchDropdownInput = ({ options = [], selectedValue = [], onChange, place
112
112
  text: placeholder,
113
113
  icon: "magnifyingGlass",
114
114
  iconStyle: "regular",
115
- }, disabled: disabled, hasSelectAll: hasSelectAll, otherProps: {
115
+ }, disabled: disabled, hasSelectAll: isBoolean ? false : true, otherProps: {
116
116
  ItemRenderer: itemRenderer,
117
117
  ...rest.otherProps,
118
- }, ...rest }));
118
+ }, isBoolean: isBoolean, ...rest }));
119
119
  };
120
120
  export default SearchDropdownInput;
@@ -1,3 +1,3 @@
1
1
  import { SearchInputProps } from "./SearchInput.types";
2
- declare const SearchInput: <T extends object>({ bgColor, 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, }: SearchInputProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ declare const SearchInput: <T extends object>({ bgColor, 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, }: SearchInputProps<T>) => import("react/jsx-runtime").JSX.Element;
3
3
  export default SearchInput;
@@ -8,7 +8,7 @@ const SearchInput = ({ bgColor = "bg-sky-500", textHighlight = "text-sky-500", i
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, }) => {
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", }) => {
12
12
  const containerRef = useRef(null);
13
13
  const inputRef = useRef(null);
14
14
  useEffect(() => {
@@ -21,9 +21,9 @@ const SearchInput = ({ bgColor = "bg-sky-500", textHighlight = "text-sky-500", i
21
21
  case "number":
22
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
- return (_jsx(SearchDropdownInput, { options: dropdownOptions, placeholder: "Search", additionalClasses: "", onChange: onChange, selectedValue: selectedValue, bgColor: bgColor, clearText: "Clear", clearTextColor: "text-sky-500", buttonText: "Filter", handleFilter: handleFilter, column: column, setSearchCriteria: setSearchCriteria, textHighlight: textHighlight }));
24
+ return (_jsx(SearchDropdownInput, { options: dropdownOptions, placeholder: "Search", additionalClasses: "", onChange: onChange, selectedValue: selectedValue, bgColor: bgColor, clearText: "Clear", clearTextColor: "text-sky-500", buttonText: "Filter", handleFilter: handleFilter, column: column, setSearchCriteria: setSearchCriteria, textHighlight: textHighlight, isBoolean: isBoolean }));
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 }));
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 }));
27
27
  default:
28
28
  return null;
29
29
  }
@@ -164,6 +164,7 @@ BooleanInput.args = {
164
164
  disabled: false,
165
165
  isLoading: false,
166
166
  type: "multiSelect",
167
+ isBoolean: true,
167
168
  };
168
169
  export const DatePickerInput = Template.bind({});
169
170
  DatePickerInput.args = {
@@ -191,6 +192,8 @@ DatePickerInput.args = {
191
192
  // Theming for DayPicker
192
193
  themeBgColor: "bg-sky-500",
193
194
  lightThemeBg: "bg-sky-100",
195
+ toggleTextColor: "text-green-500",
196
+ toggleColor: "bg-green-500",
194
197
  // If you want local-storage logic for date filtering:
195
198
  column: { id: "dateColumn" }, // real or mock
196
199
  };
@@ -42,6 +42,9 @@ export type SearchInputProps<T extends object> = {
42
42
  firstIconClasses?: string;
43
43
  dataPickerThemeColor?: string;
44
44
  dataPickerThemeColorAccent?: string;
45
+ isBoolean?: boolean;
46
+ toggleColor?: string;
47
+ toggleTextColor?: string;
45
48
  };
46
49
  export interface OptionType {
47
50
  uuid: string;
@@ -26,6 +26,8 @@ type SearchDatePickerInputProps<T extends object> = {
26
26
  column?: any;
27
27
  setEditingHeader?: React.Dispatch<React.SetStateAction<any>>;
28
28
  localStorageKey?: string;
29
+ toggleColor?: string;
30
+ toggleTextColor?: string;
29
31
  };
30
- declare const SearchDatePickerInput: <T extends object>({ themeBgColor, lightThemeBg, pillColor, textHighlight, dropdownOptions, dropdownIconProp, toggleStatus, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, searchItems, setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, buttonText, localStorageKey, }: SearchDatePickerInputProps<T>) => import("react/jsx-runtime").JSX.Element;
32
+ declare const SearchDatePickerInput: <T extends object>({ themeBgColor, lightThemeBg, pillColor, textHighlight, dropdownOptions, dropdownIconProp, toggleStatus, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, searchItems, setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, buttonText, localStorageKey, toggleColor, toggleTextColor, }: SearchDatePickerInputProps<T>) => import("react/jsx-runtime").JSX.Element;
31
33
  export default SearchDatePickerInput;
@@ -18,7 +18,7 @@ const SearchDatePickerInput = ({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
18
18
  iconClasses: "text-sky-500",
19
19
  name: "chevronDown",
20
20
  weight: "solid",
21
- }, toggleStatus = false, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, buttonText = "Filter", localStorageKey = "searchCriteria", }) => {
21
+ }, toggleStatus = false, setToggleStatus, selectedDate, onDateSelect, selectedStartDate, onStartDateSelect, selectedEndDate, onEndDateSelect, searchItems = [], setSearchItems, handleFilter, setSearchCriteria, column, setEditingHeader, buttonText = "Filter", localStorageKey = "searchCriteria", toggleColor = "bg-sky-500", toggleTextColor = "text-black", }) => {
22
22
  const containerRef = useRef(null);
23
23
  const [isDatePickerOpen, setIsDatePickerOpen] = useState(false);
24
24
  const [activeInput, setActiveInput] = useState(null);
@@ -139,6 +139,6 @@ const SearchDatePickerInput = ({ themeBgColor = "bg-sky-500", lightThemeBg = "bg
139
139
  return filtered;
140
140
  });
141
141
  }
142
- }, 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: buttonText, backgroundColor: themeBgColor, additionalClasses: "py-1.5 px-6 text-white", borderColor: "border-none", onClick: handleFilterClick, shape: "rounded-full" })] })] }));
142
+ }, 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: toggleColor, activeColorBorder: "border-sky-500", activeLabel: "Range", activeTextColor: toggleTextColor, 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: buttonText, backgroundColor: themeBgColor, additionalClasses: "py-1.5 px-6 text-white", borderColor: "border-none", onClick: handleFilterClick, shape: "rounded-full" })] })] }));
143
143
  };
144
144
  export default SearchDatePickerInput;
@@ -5,6 +5,7 @@ export type DropdownOption = {
5
5
  label: string;
6
6
  value: string;
7
7
  uuid?: string;
8
+ name?: string;
8
9
  };
9
10
  /** The parent can pass these props to replicate local-storage filter usage. */
10
11
  type SearchNumberInputProps<T extends object> = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilant/toga-blox",
3
3
  "private": false,
4
- "version": "1.0.84",
4
+ "version": "1.0.85",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",