Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filter support to datatable (#439)
- Loading branch information
Showing
15 changed files
with
196 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.vuuFilterIndicator { | ||
--menu-icon-size: 12px; | ||
--menu-item-icon-color: black; | ||
align-items: center; | ||
cursor: pointer; | ||
display: flex; | ||
flex: 0 0 18px; | ||
flex-direction: column; | ||
justify-content: center; | ||
position: relative; | ||
} | ||
|
||
.vuuFilterIndicator + .vuuTable-headerCell-inner { | ||
padding-left: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { KeyedColumnDescriptor } from "@finos/vuu-datagrid-types"; | ||
import { Filter } from "@finos/vuu-filter-types"; | ||
import { useContextMenu } from "@finos/vuu-popups"; | ||
import cx from "classnames"; | ||
import { HTMLAttributes, useCallback } from "react"; | ||
|
||
import "./filter-indicator.css"; | ||
|
||
export const Direction = { | ||
ASC: "asc", | ||
DSC: "dsc", | ||
}; | ||
|
||
export interface FilterIndicatorProps extends HTMLAttributes<HTMLDivElement> { | ||
column: KeyedColumnDescriptor; | ||
filter?: Filter; | ||
} | ||
|
||
export const FilterIndicator = ({ column, filter }: FilterIndicatorProps) => { | ||
//TODO handle this at header level | ||
const showContextMenu = useContextMenu(); | ||
|
||
const handleClick = useCallback( | ||
(evt) => { | ||
// if we do this through keyboard, need to get co-ords | ||
evt.stopPropagation(); | ||
showContextMenu(evt, "filter", { column, filter }); | ||
}, | ||
[column, filter, showContextMenu] | ||
); | ||
|
||
if (!column.filter) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
className={cx("vuuFilterIndicator")} | ||
data-icon="filter" | ||
onClick={handleClick} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.