@agilant/toga-blox 1.0.32 → 1.0.34

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.
Files changed (144) hide show
  1. package/dist/components/Dropdown/Dropdown.d.ts +4 -0
  2. package/dist/components/Dropdown/Dropdown.js +20 -0
  3. package/dist/components/Dropdown/Dropdown.stories.d.ts +8 -0
  4. package/dist/components/Dropdown/Dropdown.stories.js +110 -0
  5. package/dist/components/Dropdown/Dropdown.test.d.ts +1 -0
  6. package/dist/components/Dropdown/Dropdown.test.js +43 -0
  7. package/dist/components/Dropdown/Dropdown.types.d.ts +15 -0
  8. package/dist/components/Dropdown/Dropdown.types.js +1 -0
  9. package/dist/components/GenericList/GenericList.d.ts +2 -15
  10. package/dist/components/GenericList/GenericList.js +64 -51
  11. package/dist/components/GenericList/GenericList.stories.d.ts +8 -35
  12. package/dist/components/GenericList/GenericList.stories.js +46 -78
  13. package/dist/components/GenericList/GenericList.test.d.ts +1 -1
  14. package/dist/components/GenericList/GenericList.test.js +112 -22
  15. package/dist/components/GenericList/index.d.ts +2 -0
  16. package/dist/components/GenericList/index.js +2 -0
  17. package/dist/components/GenericList/types.d.ts +16 -0
  18. package/dist/components/GenericList/types.js +1 -0
  19. package/dist/components/Header/Header.stories.js +2 -4
  20. package/dist/components/Input/Input.d.ts +30 -3
  21. package/dist/components/Input/Input.js +70 -48
  22. package/dist/components/Input/Input.stories.js +3 -4
  23. package/dist/components/Input/Input.test.js +74 -42
  24. package/dist/components/InputAndCheck/InputAndCheck.d.ts +47 -0
  25. package/dist/components/InputAndCheck/InputAndCheck.js +74 -0
  26. package/dist/components/InputAndCheck/InputAndCheck.stories.d.ts +9 -0
  27. package/dist/components/InputAndCheck/InputAndCheck.stories.js +201 -0
  28. package/dist/components/InputAndCheck/InputAndCheck.test.d.ts +1 -0
  29. package/dist/components/InputAndCheck/InputAndCheck.test.js +307 -0
  30. package/dist/components/InputAndCheck/index.d.ts +0 -0
  31. package/dist/components/InputAndCheck/index.js +0 -0
  32. package/dist/components/InputAndCheck/types.d.ts +35 -0
  33. package/dist/components/InputAndCheck/types.js +1 -0
  34. package/dist/components/MagnifyingIcon/MagnifyingIcon.d.ts +4 -0
  35. package/dist/components/MagnifyingIcon/MagnifyingIcon.js +60 -0
  36. package/dist/components/MagnifyingIcon/MagnifyingIcon.stories.d.ts +9 -0
  37. package/dist/components/MagnifyingIcon/MagnifyingIcon.stories.js +72 -0
  38. package/dist/components/MagnifyingIcon/MagnifyingIcon.test.d.ts +1 -0
  39. package/dist/components/MagnifyingIcon/MagnifyingIcon.test.js +101 -0
  40. package/dist/components/MagnifyingIcon/index.d.ts +2 -0
  41. package/dist/components/MagnifyingIcon/index.js +2 -0
  42. package/dist/components/MagnifyingIcon/types.d.ts +20 -0
  43. package/dist/components/MagnifyingIcon/types.js +2 -0
  44. package/dist/components/MultiSelect/MultiSelect.d.ts +4 -0
  45. package/dist/components/MultiSelect/MultiSelect.js +30 -0
  46. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +10 -0
  47. package/dist/components/MultiSelect/MultiSelect.stories.js +162 -0
  48. package/dist/components/MultiSelect/MultiSelect.test.d.ts +1 -0
  49. package/dist/components/MultiSelect/MultiSelect.test.js +107 -0
  50. package/dist/components/MultiSelect/MultiSelect.types.d.ts +28 -0
  51. package/dist/components/MultiSelect/MultiSelect.types.js +1 -0
  52. package/dist/components/Page/ViewPageTemplate.stories.js +2 -3
  53. package/dist/components/PrimaryTableHeader/PrimaryTableHeader.d.ts +3 -0
  54. package/dist/components/PrimaryTableHeader/PrimaryTableHeader.js +72 -0
  55. package/dist/components/PrimaryTableHeader/PrimaryTableHeader.stories.d.ts +4 -0
  56. package/dist/components/PrimaryTableHeader/PrimaryTableHeader.stories.js +99 -0
  57. package/dist/components/PrimaryTableHeader/PrimaryTableHeader.test.d.ts +1 -0
  58. package/dist/components/PrimaryTableHeader/PrimaryTableHeader.test.js +124 -0
  59. package/dist/components/PrimaryTableHeader/index.d.ts +0 -0
  60. package/dist/components/PrimaryTableHeader/index.js +0 -0
  61. package/dist/components/PrimaryTableHeader/types.d.ts +35 -0
  62. package/dist/components/PrimaryTableHeader/types.js +2 -0
  63. package/dist/components/SearchInput/SearchInput.d.ts +1 -2
  64. package/dist/components/SearchInput/SearchInput.js +61 -11
  65. package/dist/components/SearchInput/SearchInput.stories.d.ts +2 -4
  66. package/dist/components/SearchInput/SearchInput.stories.js +80 -93
  67. package/dist/components/SearchInput/SearchInput.types.d.ts +37 -24
  68. package/dist/components/SearchInput/SearchNumberInput.d.ts +31 -0
  69. package/dist/components/SearchInput/SearchNumberInput.js +60 -0
  70. package/dist/components/SearchInput/SearchTextInput.d.ts +24 -0
  71. package/dist/components/SearchInput/SearchTextInput.js +65 -0
  72. package/dist/components/SortArrowIcon/SortArrowIcon.d.ts +4 -0
  73. package/dist/components/SortArrowIcon/SortArrowIcon.js +12 -0
  74. package/dist/components/SortArrowIcon/SortArrowIcon.stories.d.ts +17 -0
  75. package/dist/components/SortArrowIcon/SortArrowIcon.stories.js +77 -0
  76. package/dist/components/SortArrowIcon/SortArrowIcon.test.d.ts +1 -0
  77. package/dist/components/SortArrowIcon/SortArrowIcon.test.js +44 -0
  78. package/dist/components/SortArrowIcon/index.d.ts +2 -0
  79. package/dist/components/SortArrowIcon/index.js +2 -0
  80. package/dist/components/SortArrowIcon/types.d.ts +15 -0
  81. package/dist/components/SortArrowIcon/types.js +1 -0
  82. package/dist/components/SortArrows/SortArrows.d.ts +3 -0
  83. package/dist/components/SortArrows/SortArrows.js +33 -0
  84. package/dist/components/SortArrows/SortArrows.stories.d.ts +7 -0
  85. package/dist/components/SortArrows/SortArrows.stories.js +41 -0
  86. package/dist/components/SortArrows/SortArrows.test.d.ts +1 -0
  87. package/dist/components/SortArrows/SortArrows.test.js +150 -0
  88. package/dist/components/SortArrows/index.d.ts +2 -0
  89. package/dist/components/SortArrows/index.js +2 -0
  90. package/dist/components/SortArrows/types.d.ts +21 -0
  91. package/dist/components/SortArrows/types.js +1 -0
  92. package/dist/components/SortArrows/useSortArrowsViewModel.d.ts +30 -0
  93. package/dist/components/SortArrows/useSortArrowsViewModel.js +114 -0
  94. package/dist/components/SortArrows/useSortArrowsViewModel.test.d.ts +1 -0
  95. package/dist/components/SortArrows/useSortArrowsViewModel.test.js +100 -0
  96. package/dist/components/TableCell/TableCell.d.ts +3 -0
  97. package/dist/components/TableCell/TableCell.js +13 -0
  98. package/dist/components/TableCell/TableCell.stories.d.ts +16 -0
  99. package/dist/components/TableCell/TableCell.stories.js +99 -0
  100. package/dist/components/TableCell/TableCell.test.d.ts +1 -0
  101. package/dist/components/TableCell/TableCell.test.js +84 -0
  102. package/dist/components/TableCell/index.d.ts +2 -0
  103. package/dist/components/TableCell/index.js +2 -0
  104. package/dist/components/TableCell/types.d.ts +12 -0
  105. package/dist/components/TableCell/types.js +1 -0
  106. package/dist/components/TableHeaderContent/TableHeaderContent.d.ts +3 -0
  107. package/dist/components/TableHeaderContent/TableHeaderContent.js +5 -0
  108. package/dist/components/TableHeaderContent/TableHeaderContent.stories.d.ts +6 -0
  109. package/dist/components/TableHeaderContent/TableHeaderContent.stories.js +62 -0
  110. package/dist/components/TableHeaderContent/TableHeaderContent.test.d.ts +1 -0
  111. package/dist/components/TableHeaderContent/TableHeaderContent.test.js +41 -0
  112. package/dist/components/TableHeaderContent/index.d.ts +0 -0
  113. package/dist/components/TableHeaderContent/index.js +0 -0
  114. package/dist/components/TableHeaderContent/types.d.ts +5 -0
  115. package/dist/components/TableHeaderContent/types.js +1 -0
  116. package/dist/components/TableHeaderInput/TableHeaderInput.d.ts +3 -0
  117. package/dist/components/TableHeaderInput/TableHeaderInput.js +80 -0
  118. package/dist/components/TableHeaderInput/TableHeaderInput.stories.d.ts +10 -0
  119. package/dist/components/TableHeaderInput/TableHeaderInput.stories.js +82 -0
  120. package/dist/components/TableHeaderInput/TableHeaderInput.test.d.ts +1 -0
  121. package/dist/components/TableHeaderInput/TableHeaderInput.test.js +84 -0
  122. package/dist/components/TableHeaderInput/index.d.ts +1 -0
  123. package/dist/components/TableHeaderInput/index.js +1 -0
  124. package/dist/components/TableHeaderInput/types.d.ts +30 -0
  125. package/dist/components/TableHeaderInput/types.js +1 -0
  126. package/dist/components/TableRow/TableRow.d.ts +15 -0
  127. package/dist/components/TableRow/TableRow.js +21 -0
  128. package/dist/components/TableRow/TableRow.stories.d.ts +9 -0
  129. package/dist/components/TableRow/TableRow.stories.js +195 -0
  130. package/dist/components/TableRow/TableRow.test.d.ts +1 -0
  131. package/dist/components/TableRow/TableRow.test.js +44 -0
  132. package/dist/components/TableRow/index.d.ts +2 -0
  133. package/dist/components/TableRow/index.js +2 -0
  134. package/dist/components/TableRow/types.d.ts +11 -0
  135. package/dist/components/TableRow/types.js +1 -0
  136. package/dist/components/ToggleButton/ToggleButton.d.ts +4 -0
  137. package/dist/components/ToggleButton/ToggleButton.js +41 -0
  138. package/dist/components/ToggleButton/ToggleButton.stories.d.ts +11 -0
  139. package/dist/components/ToggleButton/ToggleButton.stories.js +111 -0
  140. package/dist/components/ToggleButton/ToggleButton.test.d.ts +1 -0
  141. package/dist/components/ToggleButton/ToggleButton.test.js +106 -0
  142. package/dist/components/ToggleButton/ToggleButton.types.d.ts +22 -0
  143. package/dist/components/ToggleButton/ToggleButton.types.js +1 -0
  144. package/package.json +11 -4
@@ -1,112 +1,99 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import SearchInput from "./SearchInput";
3
3
  import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
4
+ import { useState } from "react";
4
5
  export default {
5
6
  title: "Components/SearchInput",
6
7
  component: SearchInput,
7
8
  tags: ["autodocs"],
8
9
  argTypes: {
9
- onButtonClick: { control: "none", table: { disable: true } },
10
- inputType: { control: "none", table: { disable: true } },
11
- inputName: { control: "none", table: { disable: true } },
12
- placeholder: { control: "none" },
13
- hasPlaceholder: { control: "none" },
14
- inputTextSize: { control: "none" },
15
- inputShape: { control: "none" },
16
- backgroundColor: { control: "none" },
17
- inputWidth: { control: "none" },
18
- inputBorderClasses: { control: "none" },
19
- buttonText: { control: "none", table: { disable: true } },
20
- buttonIcon: { control: "none", table: { disable: true } },
21
- buttonIconClasses: { control: "none" },
22
- buttonClasses: { control: "none" },
23
- containerClasses: { control: "none" },
10
+ inputType: {
11
+ control: {
12
+ type: "select",
13
+ options: ["text", "number", "boolean", "date", "multiSelect"],
14
+ },
15
+ },
16
+ closeOutSearch: { control: "none", table: { disable: true } },
17
+ setResetSearch: { control: "none", table: { disable: true } },
18
+ column: { control: "none", table: { disable: true } },
19
+ setEditingHeader: { control: "none", table: { disable: true } },
20
+ dropdownIconProp: {
21
+ control: "object",
22
+ description: "Icon configuration for dropdown",
23
+ },
24
+ dropdownOptions: {
25
+ control: "array",
26
+ description: "Available options for dropdown",
27
+ },
28
+ selectedDropdownOption: {
29
+ control: "text",
30
+ description: "Currently selected dropdown option",
31
+ },
32
+ onDropdownOptionSelect: {
33
+ action: "selected",
34
+ description: "Callback when dropdown option is selected",
35
+ },
24
36
  },
25
37
  parameters: { layout: "centered" },
26
38
  };
27
- const Template = (args) => _jsx(SearchInput, { ...args });
39
+ // Mock data for column
40
+ const mockColumn = {
41
+ id: "mockColumn",
42
+ Header: "Mock Column",
43
+ };
44
+ const Template = (args) => {
45
+ const [selectedOption, setSelectedOption] = useState(args.selectedDropdownOption);
46
+ const [searchItems, setSearchItems] = useState([]);
47
+ const [toggleStatus, setToggleStatus] = useState(false);
48
+ const [minValue, setMinValue] = useState();
49
+ const [maxValue, setMaxValue] = useState();
50
+ return (_jsx(SearchInput, { ...args, selectedDropdownOption: selectedOption, onDropdownOptionSelect: (option) => setSelectedOption(option), searchItems: searchItems, setSearchItems: setSearchItems, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, minValue: minValue, maxValue: maxValue, setMinValue: setMinValue, setMaxValue: setMaxValue }));
51
+ };
28
52
  export const Default = Template.bind({});
29
53
  Default.args = {
30
54
  inputType: "text",
31
- inputName: "default",
32
- hasPlaceholder: true,
33
- placeholder: "Type something...",
34
- inputTextSize: "text-base",
35
- inputShape: "rounded-md",
36
- backgroundColor: "bg-white",
37
- inputWidth: "w-80",
38
- inputBorderClasses: "border border-gray-300",
39
- buttonText: _jsx("span", { children: "Search" }),
40
- buttonClasses: "bg-blue-500 text-white px-4 py-2 rounded-md",
41
- buttonIcon: getFontAwesomeIcon("search"),
42
- buttonIconClasses: "text-white",
43
- containerClasses: "flex items-center space-x-2",
44
- onButtonClick: (value) => alert(`Button clicked with input: ${value}`),
45
- };
46
- export const CommerceSearchInput = Template.bind({});
47
- CommerceSearchInput.args = {
48
- inputType: "search",
49
- inputName: "commerceSearch",
50
- hasPlaceholder: true,
51
- placeholder: "Search for product...",
52
- inputTextSize: "text-sm",
53
- inputShape: "",
54
- backgroundColor: "bg-gray-50",
55
- inputWidth: "w-full",
56
- inputBorderClasses: "border border-gray-300 focus:outline-none rounded-l-md",
57
- buttonIcon: getFontAwesomeIcon("search"),
58
- buttonIconClasses: "text-white",
59
- buttonClasses: "bg-teal-600 p-2 rounded-r-md hover:bg-teal-700",
60
- containerClasses: "flex items-center shadow-sm overflow-hidden",
61
- onButtonClick: (value) => console.log(`Searching for: ${value}`),
62
- };
63
- export const WithIconButton = Template.bind({});
64
- WithIconButton.args = {
65
- inputType: "search",
66
- inputName: "searchIcon",
67
- hasPlaceholder: true,
68
- placeholder: "Search...",
69
- inputTextSize: "text-md",
70
- inputShape: "rounded-full",
71
- backgroundColor: "bg-gray-50",
72
- inputWidth: "w-64",
73
- inputBorderClasses: "border border-gray-400",
74
- buttonIcon: getFontAwesomeIcon("magnifying-glass"),
75
- buttonIconClasses: "text-blue-500",
76
- buttonClasses: "p-2",
77
- containerClasses: "flex items-center",
78
- onButtonClick: (value) => console.log(`Searching for: ${value}`),
55
+ column: mockColumn,
56
+ closeOutSearch: (value) => console.log(`Search cleared: ${value}`),
57
+ setResetSearch: () => console.log("Reset search triggered"),
58
+ setEditingHeader: (value) => console.log(`Editing header: ${value}`),
79
59
  };
80
- export const WithoutButton = Template.bind({});
81
- WithoutButton.args = {
60
+ export const TextInput = Template.bind({});
61
+ TextInput.args = {
82
62
  inputType: "text",
83
- inputName: "withoutButton",
84
- hasPlaceholder: true,
85
- placeholder: "No button here...",
86
- inputTextSize: "text-sm",
87
- inputShape: "rounded",
88
- backgroundColor: "bg-gray-100",
89
- inputWidth: "w-full",
90
- inputBorderClasses: "border border-gray-300",
91
- containerClasses: "flex items-center",
92
- onButtonClick: () => { },
63
+ column: mockColumn,
64
+ closeOutSearch: (value) => console.log(`Search cleared: ${value}`),
65
+ setResetSearch: () => console.log("Reset search triggered"),
66
+ setEditingHeader: (value) => console.log(`Editing header: ${value}`),
67
+ pillColor: "bg-sky-500",
68
+ textHighlight: "text-sky-500",
69
+ dropdownIconProp: {
70
+ iconClasses: "text-sky-500",
71
+ name: "chevronDown",
72
+ weight: "solid",
73
+ },
74
+ dropdownOptions: [
75
+ "Starts with",
76
+ "Ends with",
77
+ "Exactly",
78
+ "Includes",
79
+ "Excludes",
80
+ ],
81
+ selectedDropdownOption: "Starts with",
93
82
  };
94
- export const CustomizedButton = Template.bind({});
95
- CustomizedButton.args = {
96
- inputType: "text",
97
- inputName: "customButton",
98
- hasPlaceholder: true,
99
- placeholder: "Enter your query...",
100
- inputTextSize: "text-lg",
101
- inputShape: "rounded-lg",
102
- backgroundColor: "bg-white",
103
- inputWidth: "w-96",
104
- inputBorderClasses: "border border-blue-500",
105
- buttonText: (_jsxs("span", { className: "flex items-center space-x-1", children: [getFontAwesomeIcon("arrow-right"), _jsx("span", { children: "Go" })] })),
106
- buttonClasses: "bg-green-600 text-white hover:bg-green-700 transition-colors rounded-full px-5 py-2",
107
- buttonIcon: null,
108
- containerClasses: "flex items-center space-x-3",
109
- onButtonClick: (value) => alert(`Navigating with: ${value}`),
83
+ export const NumberInput = Template.bind({});
84
+ NumberInput.args = {
85
+ inputType: "number",
86
+ column: mockColumn,
87
+ closeOutSearch: (value) => console.log(`Search cleared: ${value}`),
88
+ setResetSearch: () => console.log("Reset search triggered"),
89
+ setEditingHeader: (value) => console.log(`Editing header: ${value}`),
90
+ dropdownIconProp: {
91
+ iconClasses: "text-sky-500",
92
+ name: "chevronDown",
93
+ weight: "solid",
94
+ },
95
+ dropdownOptions: ["Exactly", "Less Than", "Greater Than"],
96
+ selectedDropdownOption: "Exactly",
110
97
  };
111
98
  export const DisabledInput = Template.bind({});
112
99
  DisabledInput.args = {
@@ -1,25 +1,38 @@
1
1
  import React from "react";
2
- export interface SearchInputProps {
3
- onChange?: (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
4
- value?: string;
5
- label: React.ReactNode;
6
- role?: string;
7
- ariaLabel?: string;
8
- inputType: string;
9
- inputName: string;
10
- hasPlaceholder: boolean;
11
- placeholder: string;
12
- containerClasses?: string;
13
- inputTextSize?: string;
14
- inputWidth?: string;
15
- inputShape?: string;
16
- borderColor?: string;
17
- backgroundColor?: string;
18
- inputBorderClasses?: string;
19
- additionalClasses?: string;
20
- buttonText?: JSX.Element;
21
- buttonClasses?: string;
22
- buttonIcon?: JSX.Element | null;
23
- buttonIconClasses?: string;
24
- onButtonClick: (inputValue: string) => void;
25
- }
2
+ import { Control } from "react-hook-form";
3
+ import { Accessor, ColumnInstance } from "react-table";
4
+ type ColumnWithAccessor<T extends object> = ColumnInstance<T> & {
5
+ accessor?: string | number | symbol | Accessor<T>;
6
+ };
7
+ export type SearchInputProps<T extends object> = {
8
+ closeOutSearch: (value: number | null) => void;
9
+ setResetSearch: React.Dispatch<React.SetStateAction<boolean>>;
10
+ columHeader?: any;
11
+ column: ColumnWithAccessor<T>;
12
+ parentIndex?: number;
13
+ setEditingHeader: (value: number | null) => void;
14
+ pillColor?: string;
15
+ textHighlight?: string;
16
+ inputType?: string;
17
+ dropdownOptions?: string[];
18
+ selectedDropdownOption?: string;
19
+ onDropdownOptionSelect?: (option: string) => void;
20
+ dropdownIconProp?: searchDropdownIconProps;
21
+ searchItems?: string[] | number[];
22
+ setSearchItems?: React.Dispatch<React.SetStateAction<string[] | number[]>>;
23
+ toggleStatus?: boolean;
24
+ setToggleStatus?: React.Dispatch<React.SetStateAction<boolean>>;
25
+ minValue?: string;
26
+ setMinValue?: React.Dispatch<React.SetStateAction<string>>;
27
+ maxValue?: string;
28
+ setMaxValue?: React.Dispatch<React.SetStateAction<string>>;
29
+ control?: Control<any>;
30
+ valueKey?: string;
31
+ dynamicDefaultValue?: any;
32
+ };
33
+ export type searchDropdownIconProps = {
34
+ name: string;
35
+ weight: string;
36
+ iconClasses: string;
37
+ };
38
+ export {};
@@ -0,0 +1,31 @@
1
+ import { Accessor } from "react-table";
2
+ import React from "react";
3
+ import { ColumnInstance } from "react-table";
4
+ import { searchDropdownIconProps } from "./SearchInput.types";
5
+ type ColumnWithAccessor<T extends object> = ColumnInstance<T> & {
6
+ accessor?: string | number | symbol | Accessor<T>;
7
+ };
8
+ 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
+ pillColor?: string;
14
+ textHighlight?: string;
15
+ column: ColumnWithAccessor<T>;
16
+ setEditingHeader: (value: number | null) => void;
17
+ dropdownOptions?: string[];
18
+ selectedDropdownOption?: string;
19
+ onDropdownOptionSelect?: (option: string) => void;
20
+ dropdownIconProp?: searchDropdownIconProps;
21
+ searchItems?: string[];
22
+ setSearchItems?: React.Dispatch<React.SetStateAction<string[]>>;
23
+ toggleStatus?: boolean;
24
+ setToggleStatus?: React.Dispatch<React.SetStateAction<boolean>>;
25
+ minValue?: string;
26
+ setMinValue?: React.Dispatch<React.SetStateAction<string>>;
27
+ maxValue?: string;
28
+ setMaxValue?: React.Dispatch<React.SetStateAction<string>>;
29
+ };
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;
31
+ export default SearchNumberInput;
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import { Input } from "../Input";
4
+ import Dropdown from "../Dropdown/Dropdown";
5
+ import ToggleButton from "../ToggleButton/ToggleButton";
6
+ import BaseButton from "../BaseButton";
7
+ import Text from "../Text";
8
+ const SearchNumberInput = ({ closeOutSearch, setResetSearch, setEditingHeader, textHighlight = "text-sky-500", column, dropdownIconProp = {
9
+ iconClasses: textHighlight,
10
+ name: "chevronDown",
11
+ weight: "solid",
12
+ }, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, }) => {
13
+ const containerRef = useRef(null);
14
+ const inputRef = useRef(null);
15
+ // Focus the input when editing starts (if needed)
16
+ useEffect(() => {
17
+ inputRef.current?.focus();
18
+ }, []);
19
+ const handleInputChange = (event) => {
20
+ setMinValue(event.target.value);
21
+ };
22
+ const handleMaximumInputChange = (event) => {
23
+ setMaxValue(event.target.value);
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: "", children: _jsxs("div", { className: `flex flex-col p-4 w-[425px] 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 min-w-32 top-[-8px] left-[-2px]", dropdownClasses: "border-0 border-r-2", 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-[250px] max-w-[250px] 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: () => {
57
+ 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" })] })] }) }));
59
+ };
60
+ export default SearchNumberInput;
@@ -0,0 +1,24 @@
1
+ import { Accessor } from "react-table";
2
+ import React from "react";
3
+ import { ColumnInstance } from "react-table";
4
+ import { searchDropdownIconProps } from "./SearchInput.types";
5
+ type ColumnWithAccessor<T extends object> = ColumnInstance<T> & {
6
+ accessor?: string | number | symbol | Accessor<T>;
7
+ };
8
+ type SearchTextInputProps<T extends object> = {
9
+ closeOutSearch: (value: number | null) => void;
10
+ setResetSearch: React.Dispatch<React.SetStateAction<boolean>>;
11
+ columHeader?: any;
12
+ pillColor?: string;
13
+ textHighlight?: string;
14
+ column: ColumnWithAccessor<T>;
15
+ setEditingHeader: (value: number | null) => void;
16
+ dropdownIconProp?: searchDropdownIconProps;
17
+ selectedDropdownOption?: string;
18
+ onDropdownOptionSelect?: (option: string) => void;
19
+ dropdownOptions?: string[];
20
+ searchItems?: string[];
21
+ setSearchItems?: React.Dispatch<React.SetStateAction<string[]>>;
22
+ };
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;
24
+ export default SearchTextInput;
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { AnimatePresence, motion } from "framer-motion";
4
+ import { Input } from "../Input";
5
+ import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
6
+ import Dropdown from "../Dropdown/Dropdown";
7
+ import Badge from "../Badge/Badge";
8
+ import Text from "../Text";
9
+ const SearchTextInput = ({ closeOutSearch, setResetSearch, setEditingHeader, pillColor = "bg-sky-500", textHighlight = "text-sky-500", column, dropdownIconProp = {
10
+ iconClasses: textHighlight,
11
+ name: "chevronDown",
12
+ weight: "solid",
13
+ }, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, }) => {
14
+ const containerRef = useRef(null);
15
+ const [localSearchText, setLocalSearchText] = useState("");
16
+ const inputRef = useRef(null);
17
+ // Focus the input when editing starts (if needed)
18
+ useEffect(() => {
19
+ inputRef.current?.focus();
20
+ }, []);
21
+ const handleInputChange = (event) => {
22
+ setLocalSearchText(event.target.value);
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
+ 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
+ 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
+ return (_jsx("div", { ref: containerRef, className: "", 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" }), _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] max-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
+ setLocalSearchText("");
59
+ }, children: getFontAwesomeIcon("xmark", "regular") }), _jsx("div", { className: `${textHighlight} text-sm hover:text-primary`, children: getFontAwesomeIcon("search", "solid") })] })) }) }), onIconClick: () => {
60
+ setLocalSearchText("");
61
+ } })] }), 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" }));
63
+ }) })) : null] }) }));
64
+ };
65
+ export default SearchTextInput;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { SortArrowIconProps } from "./types";
3
+ declare const SortArrowIcon: React.FC<SortArrowIconProps>;
4
+ export default SortArrowIcon;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const SortArrowIcon = ({ direction, setColumn, slug, onClick, fillColor = "fill-blue-500", }) => {
3
+ const handleClick = () => {
4
+ const directionValue = direction === "up" ? "+" : "-";
5
+ setColumn?.({ [slug]: directionValue });
6
+ onClick?.();
7
+ };
8
+ const arrowContainerClassNames = `flex justify-center items-center pt-[1px] ${direction}`;
9
+ return (_jsx("div", { className: arrowContainerClassNames, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "8", height: "6", viewBox: "0 0 8 6", onClick: handleClick, className: "cursor-pointer", role: "img" // Add this line
10
+ , children: direction === "up" ? (_jsx("path", { className: fillColor, d: "M3.47265 0.960938C3.7539 0.65625 4.24609 0.65625 4.52734 0.960938L7.52734 3.96094C7.73828 4.17188 7.80859 4.5 7.6914 4.78125C7.57421 5.0625 7.3164 5.25 7.01171 5.25H1.01171C0.707027 5.25 0.425777 5.0625 0.308589 4.78125C0.191402 4.5 0.261714 4.17188 0.472652 3.96094L3.47265 0.960938Z" })) : (_jsx("path", { className: fillColor, d: "M3.47265 5.03906L0.472652 2.03906C0.261714 1.82812 0.191402 1.5 0.308589 1.21875C0.425777 0.9375 0.707027 0.75 1.01171 0.75H7.01171C7.29296 0.75 7.57421 0.9375 7.6914 1.21875C7.80859 1.5 7.73828 1.82812 7.52734 2.03906L4.52734 5.03906C4.24609 5.34375 3.7539 5.34375 3.47265 5.03906Z" })) }) }));
11
+ };
12
+ export default SortArrowIcon;
@@ -0,0 +1,17 @@
1
+ import { Meta } from "@storybook/react";
2
+ import SortArrowIcon from "./SortArrowIcon";
3
+ declare const _default: Meta<typeof SortArrowIcon>;
4
+ export default _default;
5
+ export declare const Default: any;
6
+ export declare const DownDirection: any;
7
+ export declare const UpDirection: any;
8
+ export declare const BothDirections: {
9
+ (): import("react/jsx-runtime").JSX.Element;
10
+ parameters: {
11
+ docs: {
12
+ description: {
13
+ story: string;
14
+ };
15
+ };
16
+ };
17
+ };
@@ -0,0 +1,77 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import SortArrowIcon from "./SortArrowIcon";
3
+ export default {
4
+ title: "Components/SortArrowIcon",
5
+ component: SortArrowIcon,
6
+ argTypes: {
7
+ direction: {
8
+ control: { type: "select", options: ["up", "down"] },
9
+ description: "Direction of the arrow (up or down).",
10
+ },
11
+ columnName: {
12
+ control: "text",
13
+ description: "Name of the column being sorted.",
14
+ },
15
+ setColumn: {
16
+ action: "setColumn",
17
+ description: "Callback function to set the sort column.",
18
+ },
19
+ isActive: {
20
+ control: "boolean",
21
+ description: "Whether the arrow is active (highlighted).",
22
+ },
23
+ parentIndex: {
24
+ control: "number",
25
+ description: "Index of the parent row (if applicable).",
26
+ },
27
+ slug: {
28
+ control: "text",
29
+ description: "Unique identifier for the column.",
30
+ },
31
+ onClick: {
32
+ action: "clicked",
33
+ description: "Callback function triggered when the arrow is clicked.",
34
+ },
35
+ darkMode: {
36
+ control: "boolean",
37
+ description: "Whether dark mode is enabled.",
38
+ },
39
+ },
40
+ tags: ["autodocs"],
41
+ parameters: {
42
+ layout: "centered",
43
+ docs: {
44
+ description: {
45
+ component: "A sort arrow icon component that indicates the sorting direction (up or down) and can be used in tables or other UI elements.",
46
+ },
47
+ },
48
+ },
49
+ };
50
+ const Template = (args) => (_jsx(SortArrowIcon, { ...args }));
51
+ // Default story
52
+ export const Default = Template.bind({});
53
+ Default.args = {
54
+ direction: "up",
55
+ columnName: "Name",
56
+ };
57
+ // Story for down direction
58
+ export const DownDirection = Template.bind({});
59
+ DownDirection.args = {
60
+ ...Default.args,
61
+ direction: "down",
62
+ };
63
+ // Story for inactive state
64
+ export const UpDirection = Template.bind({});
65
+ UpDirection.args = {
66
+ ...Default.args,
67
+ isActive: false,
68
+ };
69
+ // Story to show both up and down arrows
70
+ export const BothDirections = () => (_jsxs("div", { style: { display: "flex flex-column", gap: "16px" }, children: [_jsx("div", { className: "pb-2", children: _jsx(SortArrowIcon, { direction: "up", columnName: "Name", isActive: false, slug: "name" }) }), _jsx("div", { children: _jsx(SortArrowIcon, { direction: "down", columnName: "Name", isActive: false, slug: "name", fillColor: "fill-red-500" }) })] }));
71
+ BothDirections.parameters = {
72
+ docs: {
73
+ description: {
74
+ story: "Displays both up and down arrows side by side. This mimics how the arrows might appear in a table header for sorting. Also shows how the arrow colors are dynamic",
75
+ },
76
+ },
77
+ };
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen, fireEvent } from "@testing-library/react";
3
+ import SortArrowIcon from "./SortArrowIcon";
4
+ import { describe, expect, it, vi } from "vitest";
5
+ describe("SortArrowIcon Component", () => {
6
+ it("renders the up arrow correctly", () => {
7
+ render(_jsx(SortArrowIcon, { direction: "up", columnName: "test", isActive: true, slug: "test" }));
8
+ const svg = screen.getByRole("img");
9
+ expect(svg).toBeInTheDocument();
10
+ expect(svg).toHaveAttribute("viewBox", "0 0 8 6");
11
+ });
12
+ it("renders the down arrow correctly", () => {
13
+ render(_jsx(SortArrowIcon, { direction: "down", columnName: "test", isActive: true, slug: "test" }));
14
+ const svg = screen.getByRole("img");
15
+ expect(svg).toBeInTheDocument();
16
+ expect(svg).toHaveAttribute("viewBox", "0 0 8 6");
17
+ });
18
+ it("calls onClick and setColumn when the arrow is clicked", () => {
19
+ const onClick = vi.fn();
20
+ const setColumn = vi.fn();
21
+ render(_jsx(SortArrowIcon, { direction: "up", columnName: "test", isActive: true, slug: "test", onClick: onClick, setColumn: setColumn }));
22
+ const svg = screen.getByRole("img");
23
+ fireEvent.click(svg);
24
+ expect(onClick).toHaveBeenCalled();
25
+ expect(setColumn).toHaveBeenCalledWith({ test: "+" });
26
+ });
27
+ it("applies the correct fillColor class", () => {
28
+ render(_jsx(SortArrowIcon, { direction: "up", columnName: "test", isActive: true, slug: "test", fillColor: "fill-red-500" }));
29
+ const path = screen.getByRole("img").querySelector("path");
30
+ expect(path).toHaveClass("fill-red-500");
31
+ });
32
+ it("does not call setColumn if it is not provided", () => {
33
+ const onClick = vi.fn();
34
+ render(_jsx(SortArrowIcon, { direction: "up", columnName: "test", isActive: true, slug: "test", onClick: onClick }));
35
+ const svg = screen.getByRole("img");
36
+ fireEvent.click(svg);
37
+ expect(onClick).toHaveBeenCalled();
38
+ });
39
+ it("renders with default fillColor if not provided", () => {
40
+ render(_jsx(SortArrowIcon, { direction: "up", columnName: "test", isActive: true, slug: "test" }));
41
+ const path = screen.getByRole("img").querySelector("path");
42
+ expect(path).toHaveClass("fill-blue-500");
43
+ });
44
+ });
@@ -0,0 +1,2 @@
1
+ export { default } from "./SortArrowIcon";
2
+ export * from "./types";
@@ -0,0 +1,2 @@
1
+ export { default } from "./SortArrowIcon";
2
+ export * from "./types";
@@ -0,0 +1,15 @@
1
+ type SortDirection = "up" | "down";
2
+ export interface SortArrowIconProps {
3
+ direction: SortDirection;
4
+ columnName: string;
5
+ setColumn?: (column: {
6
+ [key: string]: string;
7
+ }) => void;
8
+ isActive: boolean;
9
+ parentIndex?: number;
10
+ slug: string;
11
+ onClick?: () => void;
12
+ darkMode?: boolean;
13
+ fillColor?: string;
14
+ }
15
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { SortArrowsProps } from "./types";
2
+ declare const SortArrows: <T extends object>({ column, setSortColumn, slug, isNested, parentIndex, onSortChange, renderPortalOverlay, onRequestClose, counterIcon, }: SortArrowsProps<T>) => JSX.Element | null;
3
+ export default SortArrows;