Added TableRow customized style option (#1437)

This commit is contained in:
Alex
2022-01-22 13:26:16 -07:00
committed by GitHub
parent 276eff4f15
commit 6541938f16
2 changed files with 29 additions and 0 deletions

View File

@@ -1266,3 +1266,12 @@ export const textStyleUtils: any = {
color: "#8399AB",
},
};
// These classes are meant to be used as React.CSSProperties for TableWrapper
export const TableRowPredefStyles: any = {
deleted: {
color: "#ACACAC",
backgroundColor: "#FDFDFD",
fontStyle: "italic",
}
}

View File

@@ -38,6 +38,7 @@ import history from "../../../../history";
import {
checkboxIcons,
radioIcons,
TableRowPredefStyles,
} from "../FormComponents/common/styleLibrary";
//Interfaces for table Items
@@ -104,6 +105,11 @@ interface TableWrapperProps {
sortConfig?: ISortConfig;
disabled?: boolean;
onSelectAll?: () => void;
rowStyle?: ({
index,
}: {
index: number;
}) => "deleted" | "" | React.CSSProperties;
}
const borderColor = "#9c9c9c80";
@@ -458,6 +464,7 @@ const TableWrapper = ({
autoScrollToBottom = false,
disabled = false,
onSelectAll,
rowStyle,
}: TableWrapperProps) => {
const [columnSelectorOpen, setColumnSelectorOpen] = useState<boolean>(false);
const [anchorEl, setAnchorEl] = React.useState<any>(null);
@@ -637,6 +644,19 @@ const TableWrapper = ({
scrollToIndex={
autoScrollToBottom ? records.length - 1 : -1
}
rowStyle={(r) => {
if (rowStyle) {
const returnElement = rowStyle(r);
if (typeof returnElement === "string") {
return get(TableRowPredefStyles, returnElement, {});
}
return returnElement;
}
return {};
}}
>
{hasSelect && (
<Column