All files / src/utils/components/tables heroTableStyles.js

100% Statements 15/15
66.66% Branches 4/6
100% Functions 5/5
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199          8x 426x 426x                                                   8x 345x 345x                       8x 641x 641x                                   8x 296x 296x                   8x 296x   296x                                                                                                                                                                                                                                        
import { alpha } from "@mui/material/styles";
import { getHeroTableTokens, HERO_TABLE_SPACING as spacing } from "@/utils/theme/themeSoftTokens";
 
export { getCatalogRowSoftSx } from "@/utils/theme/themeSoftTokens";
 
export const getHeroSoftSelectSx = (theme) => {
    const t = getHeroTableTokens(theme);
    return {
        "& .MuiOutlinedInput-root": {
            minHeight: 36,
            borderRadius: t.cellRadius,
            bgcolor: t.inputBg,
            color: t.bodyText,
            fontSize: "0.875rem",
            "& fieldset": { borderColor: t.border },
            "&:hover fieldset": {
                borderColor: theme.palette.mode === "dark" ? alpha(theme.palette.common.white, 0.2) : t.border,
            },
            "&.Mui-focused fieldset": { borderColor: t.accent },
        },
        "& .MuiSelect-select": {
            py: "6px",
            minHeight: "unset",
            display: "flex",
            alignItems: "center",
            lineHeight: 1.43,
        },
        "& .MuiSelect-icon": {
            color: t.headerText,
        },
    };
};
 
export const getHeroSoftToolbarSx = (theme) => {
    const t = getHeroTableTokens(theme);
    return {
        display: "flex",
        flexWrap: "wrap",
        gap: 1.25,
        alignItems: "center",
        px: spacing.toolbarPx,
        py: spacing.toolbarPy,
        bgcolor: t.toolbarBg,
        borderBottom: `1px dashed ${t.border}`,
    };
};
 
export const getHeroSoftSearchFieldSx = (theme) => {
    const t = getHeroTableTokens(theme);
    return {
        maxWidth: 280,
        minWidth: 160,
        flex: "1 1 160px",
        "& .MuiOutlinedInput-root": {
            borderRadius: t.cellRadius,
            bgcolor: t.inputBg,
            color: t.bodyText,
            fontSize: "0.875rem",
            "& fieldset": { borderColor: t.border },
            "&:hover fieldset": {
                borderColor: theme.palette.mode === "dark" ? alpha(theme.palette.common.white, 0.2) : t.border,
            },
            "&.Mui-focused fieldset": { borderColor: t.accent },
        },
    };
};
 
const getScrollbarSx = (theme) => {
    const t = getHeroTableTokens(theme);
    return {
        scrollbarWidth: "thin",
        scrollbarColor: `${t.border} transparent`,
        "&::-webkit-scrollbar": { width: 8, height: 8 },
        "&::-webkit-scrollbar-thumb": { bgcolor: t.border, borderRadius: "9999px" },
        "&::-webkit-scrollbar-track": { bgcolor: "transparent" },
    };
};
 
/** Material React Table props aligned with app table overrides */
export const getHeroSoftTableProps = (theme) => {
    const t = getHeroTableTokens(theme);
 
    return {
        layoutMode: "semantic",
        muiTablePaperProps: {
            elevation: 0,
            sx: {
                height: "100%",
                display: "flex",
                flexDirection: "column",
                borderRadius: t.radius,
                border: `1px solid ${t.border}`,
                boxShadow: theme.customShadows?.card || "none",
                overflow: "hidden",
                bgcolor: t.paper,
                color: t.bodyText,
            },
        },
        muiTableProps: {
            sx: {
                borderCollapse: "separate",
                borderSpacing: 0,
                bgcolor: t.paper,
                "& .MuiTableCell-head": {
                    py: spacing.headPy,
                    px: spacing.cellPx,
                    "&:first-of-type": { pl: spacing.edgePx },
                    "&:last-of-type": { pr: spacing.edgePx },
                },
                "& .MuiTableCell-body": {
                    py: spacing.cellPy,
                    px: spacing.cellPx,
                    "&:first-of-type": { pl: spacing.edgePx },
                    "&:last-of-type": { pr: spacing.edgePx },
                },
            },
        },
        muiTableBodyRowProps: {
            sx: {
                transition: "background-color 150ms ease",
                "&:hover td": {
                    bgcolor: `${t.rowHover} !important`,
                },
            },
        },
        muiTableHeadRowProps: {
            sx: {
                bgcolor: t.headerBg,
                boxShadow: "none",
            },
        },
        muiTableHeadCellProps: {
            sx: {
                fontFamily: theme.typography.fontFamily,
                fontWeight: 600,
                fontSize: "0.8125rem",
                lineHeight: 1.4,
                letterSpacing: "0.02em",
                color: t.headerText,
                textTransform: "none",
                borderBottom: `1px solid ${t.border}`,
                verticalAlign: "middle",
            },
        },
        muiTableBodyCellProps: {
            sx: {
                fontFamily: theme.typography.fontFamily,
                fontSize: "0.875rem",
                lineHeight: 1.5,
                color: t.bodyText,
                borderBottom: `1px dashed ${t.rowBorder}`,
                verticalAlign: "middle",
            },
        },
        muiTopToolbarProps: {
            sx: {
                bgcolor: t.toolbarBg,
                minHeight: "unset",
                color: t.bodyText,
            },
        },
        muiBottomToolbarProps: {
            sx: {
                borderTop: `1px dashed ${t.border}`,
                bgcolor: t.toolbarBg,
                minHeight: 64,
                px: spacing.footerPx,
                py: spacing.footerPy,
                boxShadow: "none",
                color: t.bodyText,
            },
        },
        muiTablePaginationProps: {
            shape: "rounded",
            showFirstButton: false,
            showLastButton: false,
        },
        muiSearchTextFieldProps: {
            size: "small",
            variant: "outlined",
            sx: getHeroSoftSearchFieldSx(theme),
        },
        muiTableContainerProps: {
            sx: {
                flex: 1,
                maxHeight: "100%",
                overflow: "auto",
                overflowX: "auto",
                bgcolor: t.paper,
                ...getScrollbarSx(theme),
                "& table": {
                    width: "100%",
                    tableLayout: "auto",
                },
            },
        },
    };
};