From 4f057179c01c244f4e9766df135d52f0e8be6ae6 Mon Sep 17 00:00:00 2001 From: Brent Ertz Date: Fri, 5 Aug 2022 12:05:41 -0600 Subject: [PATCH 1/5] [TableCell] Enable size prop overrides via module augmentation --- packages/mui-material/src/TableCell/TableCell.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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. */ From dd749ede3fcd67f3d481050783fb910b42a99c5e Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Mon, 8 Aug 2022 10:15:38 +0700 Subject: [PATCH 2/5] add module augmentation test --- .../tableCellCustomProps.spec.tsx | 33 +++++++++++++++++++ .../tableCellCustomProps.tsconfig.json | 4 +++ 2 files changed, 37 insertions(+) create mode 100644 packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx create mode 100644 packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.tsconfig.json 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..69b8a7f4fcdf09 --- /dev/null +++ b/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx @@ -0,0 +1,33 @@ +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: { + 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"] +} From a1ad2089e226d8bdbaccde3d4ee7a731f8feed51 Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Mon, 8 Aug 2022 12:18:41 +0700 Subject: [PATCH 3/5] fix missing styleOverrides --- .../moduleAugmentation/tableCellCustomProps.spec.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx b/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx index 69b8a7f4fcdf09..87365b068c0301 100644 --- a/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx +++ b/packages/mui-material/test/typescript/moduleAugmentation/tableCellCustomProps.spec.tsx @@ -19,11 +19,13 @@ declare module '@mui/material/TableCell' { const theme = createTheme({ components: { MuiTableCell: { - root: ({ ownerState }) => ({ - ...(ownerState.size === 'large' && { - paddingBlock: '1rem', + styleOverrides: { + root: ({ ownerState }) => ({ + ...(ownerState.size === 'large' && { + paddingBlock: '1rem', + }), }), - }), + }, }, }, }); From 9ecf3afba556ad9a8a7575a5c178908b1a5bf591 Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Mon, 8 Aug 2022 12:42:24 +0700 Subject: [PATCH 4/5] fix TableCell proptypes --- packages/mui-material/src/TableCell/TableCell.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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. */ From faa0d84f75b72cbcd0669bb6fa60fa0f541c15e5 Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Mon, 8 Aug 2022 13:09:10 +0700 Subject: [PATCH 5/5] run docs:api --- docs/pages/material-ui/api/table-cell.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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" } },