Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TableCell] Enable size prop overrides via module augmentation #33816

Merged
merged 5 commits into from Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/mui-material/src/TableCell/TableCell.d.ts
@@ -1,8 +1,11 @@
import * as React from 'react';
import { OverridableStringUnion } from '@mui/types';
import { SxProps } from '@mui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';
import { TableCellClasses } from './tableCellClasses';

export interface TableCellPropsSizeOverrides {}

/**
* `<TableCell>` will be rendered as an `<th>`or `<td>` depending
* on the context it is used in. Where context literally is the
Expand Down Expand Up @@ -46,7 +49,7 @@ export interface TableCellProps extends StandardProps<TableCellBaseProps, 'align
* Specify the size of the cell.
* The prop defaults to the value (`'medium'`) inherited from the parent Table component.
*/
size?: 'small' | 'medium';
size?: OverridableStringUnion<'small' | 'medium', TableCellPropsSizeOverrides>;
/**
* Set aria-sort direction.
*/
Expand Down
@@ -0,0 +1,35 @@
import * as React from 'react';
import Table from '@mui/material/Table';
import TableCell from '@mui/material/TableCell';
import { createTheme } from '@mui/material/styles';

declare module '@mui/material/Table' {
interface TablePropsSizeOverrides {
large: true;
}
}

declare module '@mui/material/TableCell' {
interface TableCellPropsSizeOverrides {
large: true;
}
}

// theme typings should work as expected
const theme = createTheme({
components: {
MuiTableCell: {
styleOverrides: {
root: ({ ownerState }) => ({
...(ownerState.size === 'large' && {
paddingBlock: '1rem',
}),
}),
},
},
},
});

<Table size="large">
<TableCell size="large" />
</Table>;
@@ -0,0 +1,4 @@
{
"extends": "../../../../../tsconfig",
"files": ["tableCellCustomProps.spec.tsx"]
}