@agilant/toga-blox 1.0.46 → 1.0.48

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,31 +1,19 @@
1
- import { Accessor } from "react-table";
2
1
  import React from "react";
3
- import { ColumnInstance } from "react-table";
4
2
  import { searchDropdownIconProps } from "./SearchInput.types";
5
- type ColumnWithAccessor<T extends object> = ColumnInstance<T> & {
6
- accessor?: string | number | symbol | Accessor<T>;
7
- };
8
3
  type SearchNumberInputProps<T extends object> = {
9
- closeOutSearch: (value: number | null) => void;
10
- setResetSearch: React.Dispatch<React.SetStateAction<boolean>>;
11
- columHeader?: any;
12
- parentIndex?: number;
13
4
  pillColor?: string;
14
5
  textHighlight?: string;
15
- column: ColumnWithAccessor<T>;
16
- setEditingHeader: (value: number | null) => void;
17
6
  dropdownOptions?: string[];
18
7
  selectedDropdownOption?: string;
19
8
  onDropdownOptionSelect?: (option: string) => void;
20
9
  dropdownIconProp?: searchDropdownIconProps;
21
- searchItems?: string[];
22
- setSearchItems?: React.Dispatch<React.SetStateAction<string[]>>;
23
10
  toggleStatus?: boolean;
24
11
  setToggleStatus?: React.Dispatch<React.SetStateAction<boolean>>;
25
12
  minValue?: string;
26
13
  setMinValue?: React.Dispatch<React.SetStateAction<string>>;
27
14
  maxValue?: string;
28
15
  setMaxValue?: React.Dispatch<React.SetStateAction<string>>;
16
+ handleFilter?: () => void;
29
17
  };
30
- declare const SearchNumberInput: <T extends object>({ closeOutSearch, setResetSearch, setEditingHeader, textHighlight, column, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, }: SearchNumberInputProps<T>) => import("react/jsx-runtime").JSX.Element;
18
+ declare const SearchNumberInput: <T extends object>({ textHighlight, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, handleFilter, }: SearchNumberInputProps<T>) => import("react/jsx-runtime").JSX.Element;
31
19
  export default SearchNumberInput;
@@ -5,11 +5,11 @@ 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
- const SearchNumberInput = ({ closeOutSearch, setResetSearch, setEditingHeader, textHighlight = "text-sky-500", column, dropdownIconProp = {
8
+ const SearchNumberInput = ({ textHighlight = "text-sky-500", dropdownIconProp = {
9
9
  iconClasses: textHighlight,
10
10
  name: "chevronDown",
11
11
  weight: "solid",
12
- }, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, }) => {
12
+ }, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, handleFilter, }) => {
13
13
  const containerRef = useRef(null);
14
14
  const inputRef = useRef(null);
15
15
  // Focus the input when editing starts (if needed)
@@ -22,39 +22,20 @@ const SearchNumberInput = ({ closeOutSearch, setResetSearch, setEditingHeader, t
22
22
  const handleMaximumInputChange = (event) => {
23
23
  setMaxValue(event.target.value);
24
24
  };
25
- const handleSubmitClick = () => {
26
- let safeHeader;
27
- if (typeof column.Header === "string") {
28
- safeHeader = column.Header;
29
- }
30
- else {
31
- safeHeader = column.accessor || "Unnamed Column";
32
- }
33
- if (!minValue) {
34
- // Remove criterion if text is empty
35
- }
36
- else {
37
- // Update or add criterion
38
- }
39
- setEditingHeader(null);
40
- };
41
- const handleIconClick = (item) => {
42
- // Remove criterion
43
- const filteredItems = searchItems.filter((ele) => ele !== item);
44
- setSearchItems(filteredItems);
45
- setResetSearch((prevResetSearch) => !prevResetSearch);
46
- closeOutSearch(null);
47
- };
48
- const handleKeyDown = (e) => {
49
- if (e.key === "Enter") {
50
- e.preventDefault();
51
- // setSearchItems([...searchItems, localSearchText]);
52
- // setLocalSearchText("");
53
- handleSubmitClick();
54
- }
55
- };
56
- 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", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "number", onChange: handleInputChange, additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex border-2 focus:border-transparent ", 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", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "number", onChange: handleMaximumInputChange, additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex border-2 focus:border-transparent ", 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 border-r-2 w-auto", icon: dropdownIconProp }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: minValue, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "number", onChange: handleInputChange, additionalClasses: "min-w-[200px] h-10 text-gray flex ", placeholder: "Amount", hasIcons: true, iconPosition: "both" })] })) }), _jsxs("div", { className: "flex flex-[1] justify-between items-end bg-white px-2 rounded-md ", children: [_jsx(ToggleButton, { initialStatus: toggleStatus, onClick: () => {
25
+ // const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
26
+ // console.log("Key Pressed:", e.key);
27
+ // if (e.key === "Enter") {
28
+ // e.preventDefault();
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 border-2 focus:border-transparent ", 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-transparent ", 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 rounded-md ", children: [_jsx(ToggleButton, { initialStatus: toggleStatus, onClick: () => {
57
38
  setToggleStatus(!toggleStatus);
58
- }, 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: handleSubmitClick, shape: "rounded-full" })] })] }) }));
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" })] })] }) }));
59
40
  };
60
41
  export default SearchNumberInput;
@@ -1,24 +1,15 @@
1
- import { Accessor } from "react-table";
2
1
  import React from "react";
3
- import { ColumnInstance } from "react-table";
4
2
  import { searchDropdownIconProps } from "./SearchInput.types";
5
- type ColumnWithAccessor<T extends object> = ColumnInstance<T> & {
6
- accessor?: string | number | symbol | Accessor<T>;
7
- };
8
3
  type SearchTextInputProps<T extends object> = {
9
- closeOutSearch: (value: number | null) => void;
10
- setResetSearch: React.Dispatch<React.SetStateAction<boolean>>;
11
- columHeader?: any;
12
4
  pillColor?: string;
13
5
  textHighlight?: string;
14
- column: ColumnWithAccessor<T>;
15
- setEditingHeader: (value: number | null) => void;
16
6
  dropdownIconProp?: searchDropdownIconProps;
17
7
  selectedDropdownOption?: string;
18
8
  onDropdownOptionSelect?: (option: string) => void;
19
9
  dropdownOptions?: string[];
20
10
  searchItems?: string[];
21
11
  setSearchItems?: React.Dispatch<React.SetStateAction<string[]>>;
12
+ handleFilter?: () => void;
22
13
  };
23
- declare const SearchTextInput: <T extends object>({ closeOutSearch, setResetSearch, setEditingHeader, pillColor, textHighlight, column, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, }: SearchTextInputProps<T>) => import("react/jsx-runtime").JSX.Element;
14
+ declare const SearchTextInput: <T extends object>({ pillColor, textHighlight, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, handleFilter, }: SearchTextInputProps<T>) => import("react/jsx-runtime").JSX.Element;
24
15
  export default SearchTextInput;
@@ -6,11 +6,11 @@ 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
- const SearchTextInput = ({ closeOutSearch, setResetSearch, setEditingHeader, pillColor = "bg-sky-500", textHighlight = "text-sky-500", column, dropdownIconProp = {
9
+ const SearchTextInput = ({ pillColor = "bg-sky-500", textHighlight = "text-sky-500", dropdownIconProp = {
10
10
  iconClasses: textHighlight,
11
11
  name: "chevronDown",
12
12
  weight: "solid",
13
- }, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, }) => {
13
+ }, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, handleFilter, }) => {
14
14
  const containerRef = useRef(null);
15
15
  const [localSearchText, setLocalSearchText] = useState("");
16
16
  const inputRef = useRef(null);
@@ -21,45 +21,26 @@ const SearchTextInput = ({ closeOutSearch, setResetSearch, setEditingHeader, pil
21
21
  const handleInputChange = (event) => {
22
22
  setLocalSearchText(event.target.value);
23
23
  };
24
- const handleSubmitClick = () => {
25
- const trimmedSearchText = localSearchText.trim();
26
- let safeHeader;
27
- if (typeof column.Header === "string") {
28
- safeHeader = column.Header;
29
- }
30
- else {
31
- safeHeader = column.accessor || "Unnamed Column";
32
- }
33
- if (trimmedSearchText === "") {
34
- // Remove criterion if text is empty
35
- }
36
- else {
37
- // Update or add criterion
38
- }
39
- setEditingHeader(null);
40
- };
41
24
  const handleIconClick = (item) => {
42
25
  // Remove criterion
43
26
  const filteredItems = searchItems.filter((ele) => ele !== item);
44
27
  setSearchItems(filteredItems);
45
- setResetSearch((prevResetSearch) => !prevResetSearch);
46
- closeOutSearch(null);
47
28
  };
48
29
  const handleKeyDown = (e) => {
49
30
  if (e.key === "Enter") {
50
31
  e.preventDefault();
51
32
  setSearchItems([...searchItems, localSearchText]);
52
33
  setLocalSearchText("");
53
- handleSubmitClick();
34
+ handleFilter();
54
35
  }
55
36
  };
56
37
  const pillClassnames = `${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`;
57
38
  return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: "flex flex-col border-2 border-navy-200 rounded-md", children: [_jsxs("div", { className: `flex ${searchItems.length ? "border-b-2" : ""} h-full`, children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 py-1 h-full flex items-center", menuClasses: "bg-white min-w-32", icon: dropdownIconProp, dropdownClasses: "border-0 border-r-2 w-auto" }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: localSearchText, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "text", onChange: handleInputChange, additionalClasses: " min-w-[250px] min-h-full text-gray flex", placeholder: "Search", hasIcons: true, firstIcon: localSearchText === "" ? (_jsx(AnimatePresence, { children: _jsx(motion.div, { initial: "initial", animate: "animate", exit: "exit", className: "text-navy-400", children: getFontAwesomeIcon("search", "regular") }) })) : undefined, iconPosition: "both", secondIcon: _jsx("div", { className: "border-transparent text-white min-w-9", children: _jsx(AnimatePresence, { children: localSearchText !== "" && (_jsxs(motion.div, { className: "flex justify-between items-center min-w-4 text-navy-400 hover:cursor-pointer hover:text-primary", initial: "initial", animate: "animate", exit: "exit", children: [_jsx("div", { className: "bg-navy-50 pr-2 pl-1 text-gray-500", onClick: () => {
58
39
  setLocalSearchText("");
59
- }, children: getFontAwesomeIcon("xmark", "regular") }), _jsx("div", { className: `${textHighlight} text-sm hover:text-primary`, children: getFontAwesomeIcon("search", "solid") })] })) }) }), onIconClick: () => {
40
+ }, "data-testid": "clear-icon", children: getFontAwesomeIcon("xmark", "regular") }), _jsx("div", { className: `${textHighlight} text-sm hover:text-primary`, children: getFontAwesomeIcon("search", "solid") })] })) }) }), onIconClick: () => {
60
41
  setLocalSearchText("");
61
42
  } })] }), searchItems?.length ? (_jsx("div", { className: " flex bg-white py-2 px-2 rounded-md ", children: searchItems?.map((item, index) => {
62
- return (_jsx(Badge, { backgroundColor: pillColor, borderRadius: "rounded-full", hasMobileStyle: true, hasRightIcon: true, icon: _jsx("div", { className: "text-white text-xxs", children: getFontAwesomeIcon("xmark", "solid") }), iconSize: "text-sm", mobileIconLabel: item, onClick: () => handleIconClick(item), text: _jsx(Text, { color: "text-white", fontFamily: "font-serif", size: "text-sm", tag: "span", text: item }), badgeContainerClasses: pillClassnames, type: "span" }));
43
+ return (_jsx(Badge, { backgroundColor: pillColor, borderRadius: "rounded-full", hasMobileStyle: true, 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: () => handleIconClick(item), text: _jsx(Text, { color: "text-white", fontFamily: "font-serif", size: "text-sm", tag: "span", text: item }), badgeContainerClasses: pillClassnames, type: "span" }));
63
44
  }) })) : null] }) }));
64
45
  };
65
46
  export default SearchTextInput;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilant/toga-blox",
3
3
  "private": false,
4
- "version": "1.0.46",
4
+ "version": "1.0.48",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -34,6 +34,7 @@
34
34
  "framer-motion": "^11.0.8",
35
35
  "nouislider": "^15.8.1",
36
36
  "react": "^18.2.0",
37
+ "react-day-picker": "^9.5.1",
37
38
  "react-dom": "^18.2.0",
38
39
  "react-multi-select-component": "^4.3.4",
39
40
  "react-router-dom": "^6.16.0",