From 45c3664612fe26dbb4a756874e83e66f16d8a84a Mon Sep 17 00:00:00 2001 From: Sudhanshu Dasgupta Date: Mon, 11 Dec 2023 14:48:11 +0530 Subject: [PATCH] fix(configure): toolbar components Signed-off-by: Sudhanshu Dasgupta --- .../custom/CustomColumnVisibilityControl.tsx | 118 +++++++------ packages/components/src/custom/SearchBar.tsx | 23 ++- .../components/src/custom/UniversalFilter.tsx | 166 ++++++++++-------- 3 files changed, 167 insertions(+), 140 deletions(-) diff --git a/packages/components/src/custom/CustomColumnVisibilityControl.tsx b/packages/components/src/custom/CustomColumnVisibilityControl.tsx index 1e639c5a..374df7d4 100644 --- a/packages/components/src/custom/CustomColumnVisibilityControl.tsx +++ b/packages/components/src/custom/CustomColumnVisibilityControl.tsx @@ -15,6 +15,7 @@ export interface CustomColumnVisibilityControlProps { setColumnVisibility: React.Dispatch>>; }; style?: React.CSSProperties; + id: string; } export interface CustomColumn { @@ -24,6 +25,7 @@ export interface CustomColumn { export function CustomColumnVisibilityControl({ columns, + id, customToolsProps }: CustomColumnVisibilityControlProps): JSX.Element { const [open, setOpen] = React.useState(false); @@ -48,64 +50,66 @@ export function CustomColumnVisibilityControl({ return ( - } - arrow - /> - + } + arrow + /> + - - -
- - {columns.map((col) => ( - ) => - handleColumnVisibilityChange(col.name, e.target.checked) - } - /> - } - label={col.label} - /> - ))} - -
-
-
-
+ ]} + // transition + > + + +
+ + {columns.map((col) => ( + ) => + handleColumnVisibilityChange(col.name, e.target.checked) + } + /> + } + label={col.label} + /> + ))} + +
+
+
+
+
); } diff --git a/packages/components/src/custom/SearchBar.tsx b/packages/components/src/custom/SearchBar.tsx index cc959441..aad0600c 100644 --- a/packages/components/src/custom/SearchBar.tsx +++ b/packages/components/src/custom/SearchBar.tsx @@ -51,14 +51,25 @@ function SearchBar({ } }; - const handleClickAway = (): void => { - if (expanded) { - setExpanded(false); - } - }; + // const handleClickAway = (): void => { + // if (expanded) { + // setExpanded(false); + // } + // }; return ( - + { + const isTable = (event.target as HTMLElement)?.closest('#ref'); + + if (searchText !== '') { + return; + } + if (isTable) { + handleClearIconClick(); // Close the search bar as needed + } + }} + >
>>; handleApplyFilter: () => void; showAllOption?: boolean; + id: string; } function UniversalFilter({ @@ -28,7 +29,8 @@ function UniversalFilter({ selectedFilters, setSelectedFilters, handleApplyFilter, - showAllOption = true + showAllOption = true, + id }: UniversalFilterProps): JSX.Element { const [anchorEl, setAnchorEl] = React.useState(null); const [open, setOpen] = React.useState(false); @@ -53,7 +55,7 @@ function UniversalFilter({ }; const canBeOpen = open && Boolean(anchorEl); - const id = canBeOpen ? 'transition-popper' : undefined; + const idx = canBeOpen ? 'transition-popper' : undefined; const handleClose = () => { setAnchorEl(null); @@ -62,84 +64,94 @@ function UniversalFilter({ return ( - } arrow /> - + } + arrow + /> + -
- - +
+ - {Object.keys(filters).map((filterColumn) => { - const options = filters[filterColumn].options; - return ( -
- - {filters[filterColumn].name} - - -
- ); - })} + + {Object.keys(filters).map((filterColumn) => { + const options = filters[filterColumn].options; + return ( +
+ + {filters[filterColumn].name} + + +
+ ); + })} -
- -
-
-
-
- +
+ +
+
+
+
+
+
); }