Skip to content

Commit

Permalink
Explode rootProps
Browse files Browse the repository at this point in the history
  • Loading branch information
m4theushw committed Feb 15, 2023
1 parent dbd0a12 commit 0f87516
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions packages/grid/x-data-grid/src/components/GridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ const GridRow = React.forwardRef<
[apiRef, onClick, publish, rowId],
);

const {
components,
componentsProps,
classes: rootClasses,
disableColumnReorder,
getCellClassName,
rowReordering,
} = rootProps as any;

const getCell = React.useCallback(
(
column: GridStateColDef,
Expand All @@ -277,8 +286,8 @@ const GridRow = React.forwardRef<
});

const disableDragEvents =
(rootProps.disableColumnReorder && column.disableReorder) ||
(!(rootProps as any).rowReordering &&
(disableColumnReorder && column.disableReorder) ||
(!rowReordering &&
!!sortModel.length &&
treeDepth > 1 &&
Object.keys(editRowsState).length > 0);
Expand All @@ -300,7 +309,7 @@ const GridRow = React.forwardRef<
content = column.renderCell({ ...cellParams, api: apiRef.current });
// TODO move to GridCell
classNames.push(
clsx(gridClasses['cell--withRenderer'], rootProps.classes?.['cell--withRenderer']),
clsx(gridClasses['cell--withRenderer'], rootClasses?.['cell--withRenderer']),
);
}

Expand All @@ -318,12 +327,12 @@ const GridRow = React.forwardRef<

content = column.renderEditCell(params);
// TODO move to GridCell
classNames.push(clsx(gridClasses['cell--editing'], rootProps.classes?.['cell--editing']));
classNames.push(clsx(gridClasses['cell--editing'], rootClasses?.['cell--editing']));
}

if (rootProps.getCellClassName) {
if (getCellClassName) {
// TODO move to GridCell
classNames.push(rootProps.getCellClassName(cellParams));
classNames.push(getCellClassName(cellParams));
}

const hasFocus = focusedCell === column.field;
Expand All @@ -335,7 +344,7 @@ const GridRow = React.forwardRef<
});

return (
<rootProps.components.Cell
<components.Cell
key={column.field}
value={cellParams.value}
field={column.field}
Expand All @@ -354,22 +363,27 @@ const GridRow = React.forwardRef<
className={clsx(classNames)}
colSpan={cellProps.colSpan}
disableDragEvents={disableDragEvents}
{...rootProps.componentsProps?.cell}
{...componentsProps?.cell}
>
{content}
</rootProps.components.Cell>
</components.Cell>
);
},
[
apiRef,
rowId,
rootProps,
disableColumnReorder,
rowReordering,
sortModel.length,
treeDepth,
editRowsState,
getCellClassName,
focusedCell,
tabbableCell,
components,
rowHeight,
componentsProps?.cell,
rootClasses,
],
);

Expand Down

0 comments on commit 0f87516

Please sign in to comment.