From 543ad3e08162bb573ee296e575fa70060c554495 Mon Sep 17 00:00:00 2001 From: Santiago Palenque Date: Tue, 9 Jun 2026 16:02:58 -0300 Subject: [PATCH 1/3] chore: add cellSx and make disableProp affect actions --- src/components/mui/table/mui-table.js | 82 ++++++++++++++++----------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/src/components/mui/table/mui-table.js b/src/components/mui/table/mui-table.js index 53472aa5..136bf35e 100644 --- a/src/components/mui/table/mui-table.js +++ b/src/components/mui/table/mui-table.js @@ -47,7 +47,10 @@ const ARCHIVED_CELL_SX = { const ACTION_CELL_SX = { p: 0, textAlign: "center", - verticalAlign: "middle" + verticalAlign: "middle", + width: 40, + minWidth: 40, + maxWidth: 40 }; const MuiTable = ({ @@ -102,12 +105,32 @@ const MuiTable = ({ const {sortCol, sortDir} = options; - const getArchivedCellSx = (row) => - options.disableProp && row[options.disableProp] ? ARCHIVED_CELL_SX : null; + const getDisabledSx = (row) => + options.disableProp && row[options.disableProp] ? ARCHIVED_CELL_SX : {}; - const getCellSx = (row, baseSx = {}) => ({ - ...baseSx, - ...(getArchivedCellSx(row) || {}) + const getHeaderSx = (col) => ({ + ...(col.width && { + width: col.width, + minWidth: col.width, + maxWidth: col.width + }), + ...(col.headSx || {}), + }) + + const getCellSx = (row, col) => ({ + fontWeight: "normal", + ...(col.width && { + width: col.width, + minWidth: col.width, + maxWidth: col.width + }), + ...(col.cellSx || {}), + ...getDisabledSx(row) + }); + + const getActionCellSx = (row) => ({ + ...ACTION_CELL_SX, + ...getDisabledSx(row) }); const handleDelete = async (item) => { @@ -143,7 +166,7 @@ const MuiTable = ({ ); } - return {row[col.columnKey]}; + return {row[col.columnKey]}; }; return ( @@ -160,11 +183,7 @@ const MuiTable = ({ {columns.map((col) => ( {col.sortable ? ( @@ -191,10 +210,10 @@ const MuiTable = ({ )} ))} - {onEdit && } + {onEdit && } {onArchive && } - {onDelete && } - {onSelect && } + {onDelete && } + {onSelect && } @@ -207,15 +226,8 @@ const MuiTable = ({ {renderCell(row, col)} @@ -225,23 +237,23 @@ const MuiTable = ({ onEdit(row)} - sx={{ padding: 0 }} + sx={{padding: 0}} data-testid="action-edit" + disabled={options.disableProp && row[options.disableProp]} > - + )} - {/* Archive column */} {onArchive && (