diff --git a/docs/pages/material-ui/api/table-cell.json b/docs/pages/material-ui/api/table-cell.json index 873852592272e2..618a569192d78b 100644 --- a/docs/pages/material-ui/api/table-cell.json +++ b/docs/pages/material-ui/api/table-cell.json @@ -17,7 +17,12 @@ } }, "scope": { "type": { "name": "string" } }, - "size": { "type": { "name": "enum", "description": "'small'
| 'medium'" } }, + "size": { + "type": { + "name": "union", + "description": "'medium'
| 'small'
| string" + } + }, "sortDirection": { "type": { "name": "enum", "description": "'asc'
| 'desc'
| false" } }, diff --git a/packages/mui-material/src/TableCell/TableCell.d.ts b/packages/mui-material/src/TableCell/TableCell.d.ts index 73f9ba19edbaef..94b0c32a175338 100644 --- a/packages/mui-material/src/TableCell/TableCell.d.ts +++ b/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 {} + /** * `` will be rendered as an ``or `` depending * on the context it is used in. Where context literally is the @@ -46,7 +49,7 @@ export interface TableCellProps extends StandardProps; /** * Set aria-sort direction. */ diff --git a/packages/mui-material/src/TableCell/TableCell.js b/packages/mui-material/src/TableCell/TableCell.js index 0987a29d8852ef..f937b0798e386d 100644 --- a/packages/mui-material/src/TableCell/TableCell.js +++ b/packages/mui-material/src/TableCell/TableCell.js @@ -220,7 +220,10 @@ TableCell.propTypes /* remove-proptypes */ = { * Specify the size of the cell. * The prop defaults to the value (`'medium'`) inherited from the parent Table component. */ - size: PropTypes.oneOf(['small', 'medium']), + size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ + PropTypes.oneOf(['medium', 'small']), + PropTypes.string, + ]), /** * Set aria-sort direction. */ diff --git a/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx b/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx new file mode 100644 index 00000000000000..87365b068c0301 --- /dev/null +++ b/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx @@ -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', + }), + }), + }, + }, + }, +}); + + + +
; diff --git a/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.tsconfig.json b/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.tsconfig.json new file mode 100644 index 00000000000000..31638de5fb0220 --- /dev/null +++ b/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../../../tsconfig", + "files": ["tableCellCustomProps.spec.tsx"] +}